@@ -48,13 +48,16 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SIAMFANLEquationsJL, arg
48
48
sol = ptcsolsc (f, prob. u0; delta0 = delta, maxit = maxiters, atol, rtol,
49
49
printerr = ShT)
50
50
elseif method == :secant
51
- sol = secant (f, u ; maxit = maxiters, atol, rtol, printerr = ShT)
51
+ sol = secant (f, prob . u0 ; maxit = maxiters, atol, rtol, printerr = ShT)
52
52
elseif method == :anderson
53
- sol = aasol (f, u, m, __zeros_like (u, 1 , 2 * m + 4 ); maxit = maxiters,
53
+ f_aa, u, _ = NonlinearSolve. __construct_extension_f (prob; alias_u0,
54
+ make_fixed_point = Val (true ))
55
+ sol = aasol (f_aa, u, m, __zeros_like (u, 1 , 2 * m + 4 ); maxit = maxiters,
54
56
atol, rtol, beta)
55
57
end
56
58
else
57
- f, u, resid = NonlinearSolve. __construct_extension_f (prob; alias_u0)
59
+ f, u, resid = NonlinearSolve. __construct_extension_f (prob; alias_u0,
60
+ make_fixed_point = Val (method == :anderson ))
58
61
N = length (u)
59
62
FS = __zeros_like (u, N)
60
63
@@ -80,7 +83,7 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SIAMFANLEquationsJL, arg
80
83
sol = ptcsol (f, u, FS, FPS; atol, rtol, maxit = maxiters,
81
84
delta0 = delta, printerr = ShT)
82
85
elseif method == :anderson
83
- sol = aasol (f! , u, m, zeros (T, N, 2 * m + 4 ), atol, rtol,
86
+ sol = aasol (f, u, m, zeros (T, N, 2 * m + 4 ); atol, rtol,
84
87
maxit = maxiters, beta)
85
88
end
86
89
else
@@ -102,9 +105,9 @@ function SciMLBase.__solve(prob::NonlinearProblem, alg::SIAMFANLEquationsJL, arg
102
105
103
106
retcode = __siam_fanl_equations_retcode_mapping (sol)
104
107
stats = __siam_fanl_equations_stats_mapping (method, sol)
105
- resid = NonlinearSolve . evaluate_f ( prob, sol. solution)
106
- return SciMLBase . build_solution (prob, alg, sol . solution, resid; retcode, stats,
107
- original = sol)
108
+ res = prob. u0 isa Number && method === :anderson ? sol. solution[ 1 ] : sol . solution
109
+ resid = NonlinearSolve . evaluate_f (prob, res)
110
+ return SciMLBase . build_solution (prob, alg, res, resid; retcode, stats, original = sol)
108
111
end
109
112
110
113
end
0 commit comments