|
21 | 21 | Base.show(io::IO, x::SparseIdentificationResult) = print(io, "Sparse Identification Result with $(sum(x.sparsity)) active terms.") |
22 | 22 |
|
23 | 23 | @inline function Base.print(io::IO, x::SparseIdentificationResult) |
24 | | - println("Sparse Identification Result") |
25 | | - println("No. of Parameters : $(length(x.parameters))") |
26 | | - println("Active terms : $(sum(x.sparsity))") |
| 24 | + println(io,"Sparse Identification Result") |
| 25 | + println(io,"No. of Parameters : $(length(x.parameters))") |
| 26 | + println(io,"Active terms : $(sum(x.sparsity))") |
27 | 27 | for (i, si) in enumerate(x.sparsity) |
28 | | - println(" Equation $i : $si") |
| 28 | + println(io," Equation $i : $si") |
29 | 29 | end |
30 | | - println("Overall error (L2-Norm) : $(sum(x.error))") |
| 30 | + println(io,"Overall error (L2-Norm) : $(sum(x.error))") |
31 | 31 | for (i, ei) in enumerate(x.error) |
32 | | - println(" Equation $i : $ei") |
| 32 | + println(io," Equation $i : $ei") |
33 | 33 | end |
34 | | - println("AICC :") |
| 34 | + println(io,"AICC :") |
35 | 35 | for (i, ai) in enumerate(x.aicc) |
36 | | - println(" Equation $i : $ai") |
| 36 | + println(io," Equation $i : $ai") |
37 | 37 | end |
38 | 38 |
|
39 | | - print("\n$(x.opt)") |
| 39 | + print(io,"\n$(x.opt)") |
40 | 40 | if x.converged |
41 | | - println(" converged after $(x.iterations) iterations.") |
| 41 | + println(io," converged after $(x.iterations) iterations.") |
42 | 42 | else |
43 | | - println(" did not converge after $(x.iterations) iterations.") |
| 43 | + println(io," did not converge after $(x.iterations) iterations.") |
44 | 44 | end |
45 | 45 | end |
46 | 46 |
|
47 | 47 |
|
48 | 48 | """ |
49 | | - print_equations(res; show_parameter) |
| 49 | + print_equations([io,] res; show_parameter) |
50 | 50 |
|
51 | 51 | Print the equations stored inside the `SparseIdentificationResult` `res`. If `show_parameter` is set |
52 | 52 | to true, the numerical values will be used. Otherwise, the symbolic form will appear. |
53 | 53 | """ |
54 | | -function print_equations(r::SparseIdentificationResult; show_parameter::Bool = false) |
| 54 | +print_equations(r::SparseIdentificationResult;kwargs...) = print_equations(stdout,r;kwargs...) |
| 55 | +function print_equations(io::IO, r::SparseIdentificationResult; |
| 56 | + show_parameter::Bool = false) |
| 57 | + |
55 | 58 | if show_parameter |
56 | 59 | eqs = r.equations(variables(r.equations), parameters(r), independent_variable(r.equations)) |
57 | 60 | for (i, eq) in enumerate(eqs) |
58 | | - println("f_$i = ", eq) |
| 61 | + println(io,"f_$i = ", eq) |
59 | 62 | end |
60 | 63 | else |
61 | | - print(r.equations) |
| 64 | + println(io,r.equations) |
62 | 65 | end |
63 | 66 | end |
64 | 67 |
|
|
0 commit comments