Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jac and jac_residual should not return linear operators #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/lls_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,6 @@ function NLPModels.jac_coord_residual!(
return vals
end

function NLPModels.jac_residual(
nls::LLSModel{T, S, M1, M2},
x::AbstractVector,
) where {T, S, M1 <: AbstractLinearOperator, M2 <: AbstractLinearOperator}
@lencheck nls.meta.nvar x
increment!(nls, :neval_jac_residual)
return nls.A
end

function NLPModels.jprod_residual!(
nls::LLSModel,
x::AbstractVector,
Expand Down Expand Up @@ -255,18 +246,6 @@ function NLPModels.hess_residual(nls::LLSModel, x::AbstractVector{T}, v::Abstrac
return spzeros(T, n, n)
end

function NLPModels.hess_residual(
nls::LLSModel{T, S, M1, M2},
x::AbstractVector{T},
v::AbstractVector,
) where {T, S, M1 <: AbstractLinearOperator, M2 <: AbstractLinearOperator}
@lencheck nls.meta.nvar x
@lencheck nls.nls_meta.nequ v
increment!(nls, :neval_hess_residual)
n = nls.meta.nvar
return opZeros(T, n, n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return spzeros(n, n)?

end

function NLPModels.hess_structure_residual!(
nls::LLSModel,
rows::AbstractVector{<:Integer},
Expand Down Expand Up @@ -297,17 +276,6 @@ function NLPModels.jth_hess_residual(nls::LLSModel, x::AbstractVector{T}, i::Int
return spzeros(T, n, n)
end

function NLPModels.jth_hess_residual(
nls::LLSModel{T, S, M1, M2},
x::AbstractVector{T},
i::Int,
) where {T, S, M1 <: AbstractLinearOperator, M2 <: AbstractLinearOperator}
@lencheck nls.meta.nvar x
increment!(nls, :neval_jhess_residual)
n = nls.meta.nvar
return opZeros(T, n, n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here?

end

function NLPModels.hprod_residual!(
nls::LLSModel,
x::AbstractVector,
Expand Down Expand Up @@ -352,15 +320,6 @@ function NLPModels.jac_coord!(
return vals
end

function NLPModels.jac(
nls::LLSModel{T, S, M1, M2},
x::AbstractVector,
) where {T, S, M1 <: AbstractLinearOperator, M2 <: AbstractLinearOperator}
@lencheck nls.meta.nvar x
increment!(nls, :neval_jac)
return nls.C
end

function NLPModels.jprod!(nls::LLSModel, x::AbstractVector, v::AbstractVector, Jv::AbstractVector)
@lencheck nls.meta.nvar x v
@lencheck nls.meta.ncon Jv
Expand Down
4 changes: 2 additions & 2 deletions test/test_lls_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ function lls_test()
x = [1.0; -1.0; 1.0]

@test isapprox(A * x - b, residual(nls, x), rtol = 1e-8)
@test A == jac_residual(nls, x)
@test_throws MethodError jac_residual(nls, x)
@test Matrix(hess_residual(nls, x, ones(nequ))) == zeros(nvar, nvar)
for i = 1:nequ
@test isapprox(zeros(nvar, nvar), Matrix(jth_hess_residual(nls, x, i)), rtol = 1e-8)
end
@show nls
@test C == jac(nls, x)
@test_throws MethodError jac(nls, x)

@test nls.meta.nlin == length(nls.meta.lin) == ncon
@test nls.meta.nnln == length(nls.meta.nln) == 0
Expand Down