Skip to content

Commit

Permalink
Merge pull request #109 from avik-pal/ap/patch_nonvec
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal authored Dec 17, 2023
2 parents 171cf42 + beabc41 commit 41ce280
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/SimpleNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SimpleNonlinearSolve"
uuid = "727e6d20-b764-4bd8-a329-72de5adea6c7"
authors = ["SciML"]
version = "1.0.2"
version = "1.0.3"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
8 changes: 4 additions & 4 deletions lib/SimpleNonlinearSolve/src/nlsolve/lbroyden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ end
d = dot(vᵀ, δf)
@bb @. δx = (δx - mvec) / d

selectdim(U, 2, mod1(i, η)) .= δx
selectdim(Vᵀ, 1, mod1(i, η)) .= vᵀ
selectdim(U, 2, mod1(i, η)) .= _vec(δx)
selectdim(Vᵀ, 1, mod1(i, η)) .= _vec(vᵀ)

_U = selectdim(U, 2, 1:min(η, i))
_Vᵀ = selectdim(Vᵀ, 1, 1:min(η, i))
Expand All @@ -93,7 +93,7 @@ function _rmatvec!!(y, xᵀU, U, Vᵀ, x)
x_ = vec(x)
xᵀU_ = view(xᵀU, 1:η)
@bb xᵀU_ = transpose(U) × x_
@bb y = transpose(Vᵀ) × xᵀU_
@bb y = transpose(Vᵀ) × vec(xᵀU_)
@bb @. y -= x
return y
end
Expand All @@ -108,7 +108,7 @@ function _matvec!!(y, Vᵀx, U, Vᵀ, x)
x_ = vec(x)
Vᵀx_ = view(Vᵀx, 1:η)
@bb Vᵀx_ = Vᵀ × x_
@bb y = U × Vᵀx_
@bb y = U × vec(Vᵀx_)
@bb @. y -= x
return y
end
Expand Down
4 changes: 2 additions & 2 deletions lib/SimpleNonlinearSolve/test/matrix_resizing_tests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using SimpleNonlinearSolve

ff(u, p) = u .* u .- p
u0 = rand(2, 2)
u0 = ones(2, 3)
p = 2.0
vecprob = NonlinearProblem(ff, vec(u0), p)
prob = NonlinearProblem(ff, u0, p)

@testset "$(alg)" for alg in (SimpleKlement(), SimpleBroyden(), SimpleNewtonRaphson(),
SimpleDFSane(), SimpleLimitedMemoryBroyden(), SimpleTrustRegion())
SimpleDFSane(), SimpleLimitedMemoryBroyden(; threshold = Val(2)), SimpleTrustRegion())
@test vec(solve(prob, alg).u) solve(vecprob, alg).u
end

0 comments on commit 41ce280

Please sign in to comment.