Skip to content

Commit

Permalink
Generic _axpy!
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 24, 2023
1 parent 30f7873 commit 1e76861
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/broyden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function perform_step!(cache::GeneralBroydenCache{true})

mul!(_vec(du), J⁻¹, -_vec(fu))
α = perform_linesearch!(cache.lscache, u, du)
axpy!(α, du, u)
_axpy!(α, du, u)
f(fu2, u, p)

Check warning on line 82 in src/broyden.jl

View check run for this annotation

Codecov / codecov/patch

src/broyden.jl#L79-L82

Added lines #L79 - L82 were not covered by tests

cache.internalnorm(fu2) < cache.abstol && (cache.force_stop = true)
Expand Down
2 changes: 1 addition & 1 deletion src/klement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function perform_step!(cache::GeneralKlementCache{true})

# Line Search
α = perform_linesearch!(cache.lscache, u, du)
axpy!(α, du, u)
_axpy!(α, du, u)
f(cache.fu2, u, p)

Check warning on line 119 in src/klement.jl

View check run for this annotation

Codecov / codecov/patch

src/klement.jl#L117-L119

Added lines #L117 - L119 were not covered by tests

cache.internalnorm(cache.fu2) < cache.abstol && (cache.force_stop = true)
Expand Down
2 changes: 1 addition & 1 deletion src/lbroyden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function perform_step!(cache::LimitedMemoryBroydenCache{true})
T = eltype(u)

Check warning on line 93 in src/lbroyden.jl

View check run for this annotation

Codecov / codecov/patch

src/lbroyden.jl#L91-L93

Added lines #L91 - L93 were not covered by tests

α = perform_linesearch!(cache.lscache, u, du)
axpy!(α, du, u)
_axpy!(α, du, u)
f(cache.fu2, u, p)

Check warning on line 97 in src/lbroyden.jl

View check run for this annotation

Codecov / codecov/patch

src/lbroyden.jl#L95-L97

Added lines #L95 - L97 were not covered by tests

cache.internalnorm(cache.fu2) < cache.abstol && (cache.force_stop = true)
Expand Down
2 changes: 1 addition & 1 deletion src/raphson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function perform_step!(cache::NewtonRaphsonCache{true})

# Line Search
α = perform_linesearch!(cache.lscache, u, du)
axpy!(-α, du, u)
_axpy!(-α, du, u)
f(cache.fu1, u, p)

cache.internalnorm(fu1) < cache.abstol && (cache.force_stop = true)
Expand Down
6 changes: 6 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,13 @@ _try_factorize_and_check_singular!(::Nothing, x) = _issingular(x), false
_reshape(x, args...) = reshape(x, args...)
_reshape(x::Number, args...) = x

Check warning on line 261 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L260-L261

Added lines #L260 - L261 were not covered by tests

@generated function _axpy!(α, x, y)
hasmethod(axpy!, Tuple{α, x, y}) && return :(axpy!(α, x, y))
return :(@. y += α * x)

Check warning on line 265 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L265

Added line #L265 was not covered by tests
end

# Needs Square Matrix
# FIXME: Remove once https://github.com/SciML/LinearSolve.jl/pull/400 is merged and tagged
"""
needs_square_A(alg)
Expand Down
4 changes: 2 additions & 2 deletions test/nonlinear_least_squares.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ prob_iip = NonlinearLeastSquaresProblem(NonlinearFunction(loss_function;
nlls_problems = [prob_oop, prob_iip]
solvers = [
GaussNewton(),
GaussNewton(; linsolve = CholeskyFactorization()),
GaussNewton(; linsolve = LUFactorization()),
LevenbergMarquardt(),
LevenbergMarquardt(; linsolve = CholeskyFactorization()),
LevenbergMarquardt(; linsolve = LUFactorization()),
LeastSquaresOptimJL(:lm),
LeastSquaresOptimJL(:dogleg),
]
Expand Down

0 comments on commit 1e76861

Please sign in to comment.