@@ -62,9 +62,12 @@ function DiffEqBase.__solve(
62
62
63
63
eval_string (" options = odeset('RelTol',reltol,'AbsTol',abstol);" )
64
64
algstr = string (typeof (alg). name. name)
65
- # algstr = replace(string(typeof(alg)),"MATLABDiffEq.","")
66
- eval_string (" [t,u] = $(algstr) (diffeqf,tspan,u0,options);" )
65
+ eval_string (" mxsol = $(algstr) (diffeqf,tspan,u0,options);" )
66
+ eval_string (" mxsolstats = struct(mxsol.stats);" )
67
+ solstats = get_variable (:mxsolstats )
68
+ eval_string (" t = mxsol.x;" )
67
69
ts = jvector (get_mvariable (:t ))
70
+ eval_string (" u = mxsol.y';" )
68
71
timeseries_tmp = jarray (get_mvariable (:u ))
69
72
70
73
# Reshape the result if needed
@@ -77,8 +80,22 @@ function DiffEqBase.__solve(
77
80
timeseries = timeseries_tmp
78
81
end
79
82
83
+ destats = buildDEStats (solstats)
84
+
80
85
DiffEqBase. build_solution (prob,alg,ts,timeseries,
81
- timeseries_errors = timeseries_errors)
86
+ timeseries_errors = timeseries_errors,destats = destats)
87
+ end
88
+
89
+ function buildDEStats (solverstats:: Dict )
90
+
91
+ destats = DiffEqBase. DEStats (0 )
92
+ destats. nf = if (haskey (solverstats, " nfevals" )) solverstats[" nfevals" ] else 0 end
93
+ destats. nreject = if (haskey (solverstats, " nfailed" )) solverstats[" nfailed" ] else 0 end
94
+ destats. naccept = if (haskey (solverstats, " nsteps" )) solverstats[" nsteps" ] else 0 end
95
+ destats. nsolve = if (haskey (solverstats, " nsolves" )) solverstats[" nsolves" ] else 0 end
96
+ destats. njacs = if (haskey (solverstats, " npds" )) solverstats[" npds" ] else 0 end
97
+ destats. nw = if (haskey (solverstats, " ndecomps" )) solverstats[" ndecomps" ] else 0 end
98
+ destats
82
99
end
83
100
84
101
end # module
0 commit comments