|
9 | 9 | l_params = length(tunable_part) |
10 | 10 | length_u = M - l_params |
11 | 11 | cost_fun = @views function (u, p_orig) |
12 | | - newy = [u[i:(i + M - 1)] for i in 1:M:(length(u) - M + 1)] |
| 12 | + newy = eachcol(reshape(u, M, :)) |
13 | 13 | # Extract tunable params from first mesh point (same at all points) |
14 | 14 | params_from_u = u[(length_u + 1):M] |
15 | 15 | new_p = SciMLStructures.replace(SciMLStructures.Tunable(), p_orig, params_from_u) |
|
20 | 20 | length_u = M - length(p) |
21 | 21 | cost_fun = @views function (u, p) |
22 | 22 | # When fit_parameters=true, the state vector is augmented with tunable params |
23 | | - newy = [u[i:(i + M - 1)] for i in 1:M:(length(u) - M + 1)] |
| 23 | + newy = eachcol(reshape(u, M, :)) |
24 | 24 | params_from_u = u[(length_u + 1):M] |
25 | 25 | eval_sol = EvalSol(newy, mesh, cache) |
26 | 26 | return fun(eval_sol, params_from_u) |
27 | 27 | end |
28 | 28 | else |
29 | 29 | cost_fun = @views function (u, p) |
30 | 30 | # simple recursive unflatten |
31 | | - newy = [u[i:(i + M - 1)] for i in 1:M:(length(u) - M + 1)] |
| 31 | + newy = eachcol(reshape(u, M, :)) |
32 | 32 | eval_sol = EvalSol(newy, mesh, cache) |
33 | 33 | return fun(eval_sol, p) |
34 | 34 | end |
|
0 commit comments