diff --git a/Project.toml b/Project.toml index 0bd23b9..66f5dbb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "LeastSquaresOptim" uuid = "0fc2ff8b-aaa3-5acd-a817-1944a5e08891" -version = "0.7.6" +version = "0.8" [deps] FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" diff --git a/src/types.jl b/src/types.jl index 8910af9..2e50732 100644 --- a/src/types.jl +++ b/src/types.jl @@ -18,15 +18,14 @@ struct LeastSquaresProblem{Tx, Ty, Tf, TJ, Tg} end -function LeastSquaresProblem(x::Tx, y::Ty, f!::Tf, J::TJ, g!::Tg) where {Tx, Ty, Tf, TJ, Tg} - LeastSquaresProblem{Tx, Ty, Tf, TJ, Tg}(x, y, f!, J, g!) -end - - function LeastSquaresProblem(;x = error("initial x required"), y = nothing, f! = error("initial f! required"), g! = nothing, J = nothing, output_length = 0, autodiff = :central) if typeof(y) == Nothing if output_length == 0 - output_length = size(J, 2) + if typeof(J) == Nothing + error("specify J or output_length") + else + output_length = size(J, 2) + end end y = zeros(eltype(x), output_length) end @@ -148,12 +147,6 @@ function optimize!(nls::LeastSquaresProblem, optimizer::Union{Nothing, AbstractO end -Base.@deprecate optimize!(nls::LeastSquaresProblem, optimizer::AbstractOptimizer, solver::Union{Nothing, AbstractSolver}; kwargs...) optimize!(nls, typeof{optimizer}(solver); kwargs...) -Base.@deprecate optimize!(nls::LeastSquaresProblem, solver::AbstractSolver; kwargs...) optimize!(nls, Dogleg{solver}; kwargs...) -Base.@deprecate LeastSquaresProblemAllocated(nls::LeastSquaresProblem, optimizer::AbstractOptimizer, solver::AbstractSolver) LeastSquaresProblemAllocated(nls, default_optimizer(optimizer, solver)) - - - ############################################################################### @@ -204,4 +197,3 @@ function Base.show(io::IO, r::LeastSquaresResult) @printf io " * Multiplication Calls: %d\n" r.mul_calls return end - diff --git a/src/utils/lsmr.jl b/src/utils/lsmr.jl index 53df4ff..10d4e2d 100644 --- a/src/utils/lsmr.jl +++ b/src/utils/lsmr.jl @@ -86,6 +86,7 @@ function lsmr!(x, A, b, v, h, hbar; α = norm(v) α > 0 && rmul!(v, inv(α)) + # Initialize variables for 1st iteration. ζbar = α * β αbar = α