@@ -2,29 +2,28 @@ using SimpleNonlinearSolve,
22 StaticArrays, BenchmarkTools, DiffEqBase, LinearAlgebra, Test,
33 NNlib
44
5- # Supported Solvers: BatchedBroyden, BatchedSimpleDFSane
5+ # Supported Solvers: BatchedBroyden, BatchedSimpleDFSane, BatchedSimpleNewtonRaphson
66function f! (du:: AbstractArray{<:Number, N} ,
77 u:: AbstractArray{<:Number, N} ,
88 p:: AbstractVector ) where {N}
99 u_ = reshape (u, :, size (u, N))
10- du .= reshape (sum (abs2, u_; dims = 1 ) .- reshape (p, 1 , :),
11- ntuple (_ -> 1 , N - 1 )... ,
12- size (u, N))
10+ du .= reshape (sum (abs2, u_; dims = 1 ) .- u_ .- reshape (p, 1 , :), size (u))
1311 return du
1412end
1513
1614function f! (du:: AbstractMatrix , u:: AbstractMatrix , p:: AbstractVector )
17- du .= sum (abs2, u; dims = 1 ) .- reshape (p, 1 , :)
15+ du .= sum (abs2, u; dims = 1 ) .- u .- reshape (p, 1 , :)
1816 return du
1917end
2018
2119function f! (du:: AbstractVector , u:: AbstractVector , p:: AbstractVector )
22- du .= sum (abs2, u) .- p
20+ du .= sum (abs2, u) .- u .- p
2321 return du
2422end
2523
26- @testset " Solver: $(nameof (typeof (solver))) " for solver in (Broyden (batched = true ),
27- SimpleDFSane (batched = true ))
24+ @testset " Solver: $(nameof (typeof (solver))) " for solver in (Broyden (; batched = true ),
25+ SimpleDFSane (; batched = true ),
26+ SimpleNewtonRaphson (; batched = true ))
2827 @testset " T: $T " for T in (Float32, Float64)
2928 p = rand (T, 5 )
3029 @testset " size(u0): $sz " for sz in ((2 , 5 ), (1 , 5 ), (2 , 3 , 5 ))
0 commit comments