Commit d3357038 authored by Frédéric Karamé's avatar Frédéric Karamé

Minor modifications.

parent 02eeaa34
......@@ -89,7 +89,6 @@ function dogleg!(x::Vector{Float64}, r::Matrix{Float64}, b::Vector{Float64}, d::
# gnorm = norm(s)
if gnorm>0
# Normalize and rescale → gradient direction.
temp0 = zero(Float64)
@inbounds for i = 1:n
s[i] /= gnorm*d[i]
end
......@@ -101,8 +100,8 @@ function dogleg!(x::Vector{Float64}, r::Matrix{Float64}, b::Vector{Float64}, d::
end
temp0 += temp1*temp1
end
sgnorm = gnorm/temp0
temp0 = sqrt(temp0)
sgnorm = gnorm/(temp0*temp0)
if sgnorm<=δ
# The scaled gradient direction is not acceptable…
# Compute the point along the dogleg at which the
......@@ -154,7 +153,7 @@ end
trustregion(f!::Function, j!::Function, y0::Vector{Float64}, factor::Float64, tolf::Float64, tolx::Float64, maxiter::Int, wa::TrustRegionWA)
Solves a system of nonlinear equations of several variables using a trust region method. This version requires a last argument of type `TrustRegionWA`
which holds various working arrays used in the function (avoiding array instantiations). Results of the solver are available in `wa.x` if `info=1`.
which holds various working arrays used in the function (avoiding array instantiations). Results of the solver are available in `wa.x` if `info=1`.
# Arguments
- `f!::Function`: Function evaluating the residuals of the nonlinear equations to be solved. This function admits two arguments, a vector holding the values of the residuals and the vector of unknowns (to be solved for).
......@@ -272,7 +271,7 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
if ratio<p1
# Reduction is much smaller than predicted… Reduce the radius of the trust region.
ncsucc = 0
δ = p5*δ
δ *= p5
else
ncsucc += 1
if ratio>=p5 || ncsucc>1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment