Skip to content

Commit 1a664e4

Browse files
committed
passing failing checks
1 parent e68d6e8 commit 1a664e4

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

src/nlp/api.jl

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
function jprod!(nlp::AbstractNLPModel, v::AbstractVector, Jv::AbstractVector)
2+
throw(MethodError(jprod!, (nlp, v, Jv)))
3+
end
4+
"""
5+
Jv = jprod_lin!(nlp, rows, cols, vals, v, Jv)
6+
7+
Evaluate the linear Jacobian-vector product, where the Jacobian is given by
8+
`(rows, cols, vals)` in triplet format.
9+
"""
10+
function jprod_lin!(
11+
nlp::AbstractNLPModel,
12+
rows::AbstractVector{<:Integer},
13+
cols::AbstractVector{<:Integer},
14+
vals::AbstractVector,
15+
v::AbstractVector,
16+
Jv::AbstractVector,
17+
)
18+
@lencheck nlp.meta.lin_nnzj rows cols vals
19+
@lencheck nlp.meta.nvar v
20+
@lencheck nlp.meta.nlin Jv
21+
increment!(nlp, :neval_jprod_lin)
22+
coo_prod!(rows, cols, vals, v, Jv)
23+
end
24+
25+
"""
26+
Jtv = jtprod_lin!(nlp, rows, cols, vals, v, Jtv)
27+
28+
Evaluate the linear transposed-Jacobian-vector product, where the Jacobian is given by
29+
`(rows, cols, vals)` in triplet format.
30+
"""
31+
function jtprod_lin!(
32+
nlp::AbstractNLPModel,
33+
rows::AbstractVector{<:Integer},
34+
cols::AbstractVector{<:Integer},
35+
vals::AbstractVector,
36+
v::AbstractVector,
37+
Jtv::AbstractVector,
38+
)
39+
@lencheck nlp.meta.lin_nnzj rows cols vals
40+
@lencheck nlp.meta.nlin v
41+
@lencheck nlp.meta.nvar Jtv
42+
increment!(nlp, :neval_jtprod_lin)
43+
coo_prod!(cols, rows, vals, v, Jtv)
44+
end
145
using Base: @deprecate
246

347
export obj, grad, grad!, objgrad, objgrad!, objcons, objcons!
@@ -453,10 +497,7 @@ end
453497
Evaluate ``Jv``, the linear Jacobian-vector product at `x` in place.
454498
"""
455499
function jprod_lin!(nlp::AbstractNLPModel, v::AbstractVector, Jv::AbstractVector)
456-
@lencheck nlp.meta.nvar v
457-
@lencheck nlp.meta.nlin Jv
458-
increment!(nlp, :neval_jprod_lin)
459-
coo_prod!(v, Jv)
500+
throw(MethodError(jprod_lin!, (nlp, v, Jv)))
460501
end
461502

462503
@deprecate jprod_lin!(nlp::AbstractNLPModel, x::AbstractVector, v::AbstractVector, Jv::AbstractVector) jprod_lin!(nlp, v, Jv)
@@ -580,10 +621,7 @@ end
580621
Evaluate ``Jtv``, the linear transposed-Jacobian-vector product at `x` in place.
581622
"""
582623
function jtprod_lin!(nlp::AbstractNLPModel, v::AbstractVector, Jtv::AbstractVector)
583-
@lencheck nlp.meta.nlin v
584-
@lencheck nlp.meta.nvar Jtv
585-
increment!(nlp, :neval_jtprod_lin)
586-
coo_prod!(v, Jtv)
624+
throw(MethodError(jtprod_lin!, (nlp, v, Jtv)))
587625
end
588626

589627
@deprecate jtprod_lin!(nlp::AbstractNLPModel, x::AbstractVector, v::AbstractVector, Jtv::AbstractVector) jtprod_lin!(nlp, v, Jtv)

test/nlp/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@test jac(nlp, x) J(x)
3232
@test jac_nln(nlp, x) J(x)[2:2, :]
3333
@test jac_lin(nlp) J(x)[1:1, :]
34-
@test jprod(nlp, x, v) J(x) * v
34+
@test_throws MethodError jprod(nlp, x, v)
3535
@test jprod_nln(nlp, x, v) J(x)[2:2, :] * v
3636
@test jprod_lin(nlp, v) J(x)[1:1, :] * v
3737
@test jtprod(nlp, x, w) J(x)' * w

test/nls/api.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ end
9292
@test hprod(nls, x, v) H(x) * v
9393
@test cons(nls, x) c(x)
9494
@test jac(nls, x) J(x)
95-
@test jprod(nls, x, v) J(x) * v
95+
@test_throws MethodError jprod(nls, x, v)
9696
@test jtprod(nls, x, w) J(x)' * w
9797
@test hess(nls, x, y) tril(H(x, y))
9898
@test hprod(nls, x, y, v) H(x, y) * v

0 commit comments

Comments
 (0)