@@ -2,29 +2,28 @@ using SimpleNonlinearSolve,
2
2
StaticArrays, BenchmarkTools, DiffEqBase, LinearAlgebra, Test,
3
3
NNlib
4
4
5
- # Supported Solvers: BatchedBroyden, BatchedSimpleDFSane
5
+ # Supported Solvers: BatchedBroyden, BatchedSimpleDFSane, BatchedSimpleNewtonRaphson
6
6
function f! (du:: AbstractArray{<:Number, N} ,
7
7
u:: AbstractArray{<:Number, N} ,
8
8
p:: AbstractVector ) where {N}
9
9
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))
13
11
return du
14
12
end
15
13
16
14
function 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 , :)
18
16
return du
19
17
end
20
18
21
19
function f! (du:: AbstractVector , u:: AbstractVector , p:: AbstractVector )
22
- du .= sum (abs2, u) .- p
20
+ du .= sum (abs2, u) .- u .- p
23
21
return du
24
22
end
25
23
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 ))
28
27
@testset " T: $T " for T in (Float32, Float64)
29
28
p = rand (T, 5 )
30
29
@testset " size(u0): $sz " for sz in ((2 , 5 ), (1 , 5 ), (2 , 3 , 5 ))
0 commit comments