From 9c4d0a7b5cd7d97f746473eed440cfb87e4bd6a5 Mon Sep 17 00:00:00 2001 From: Abel Soares Siqueira Date: Fri, 28 Jan 2022 20:02:04 +0100 Subject: [PATCH] jac and jac_residual should not return linear operators --- src/lls_model.jl | 41 ----------------------------------------- test/test_lls_model.jl | 4 ++-- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/src/lls_model.jl b/src/lls_model.jl index 08ecbb0..fe2a8c5 100644 --- a/src/lls_model.jl +++ b/src/lls_model.jl @@ -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, @@ -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) -end - function NLPModels.hess_structure_residual!( nls::LLSModel, rows::AbstractVector{<:Integer}, @@ -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) -end - function NLPModels.hprod_residual!( nls::LLSModel, x::AbstractVector, @@ -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 diff --git a/test/test_lls_model.jl b/test/test_lls_model.jl index b2b88c2..7010387 100644 --- a/test/test_lls_model.jl +++ b/test/test_lls_model.jl @@ -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