Skip to content

Commit 90eb234

Browse files
authored
add prod tests in multiprecision (#108)
1 parent ce3b824 commit 90eb234

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/nlp/multiple-precision.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ function multiple_precision_nlp(
4747
nlp = nlp_from_T(T)
4848
S = typeof(nlp.meta.x0)
4949
x = fill!(S(undef, nlp.meta.nvar), 1)
50+
v = fill!(S(undef, nlp.meta.nvar), 2)
5051
@test obj exclude || typeof(obj(nlp, x)) == T
5152
@test grad exclude || typeof(grad(nlp, x)) == S
5253
@test hess exclude || eltype(hess(nlp, x)) == T
5354
@test hess_op exclude || eltype(hess_op(nlp, x)) == T
55+
@test hprod exclude || typeof(hprod(nlp, x, v)) == S
5456
if hess_coord exclude && hess_op exclude
5557
rows, cols = hess_structure(nlp)
5658
vals = hess_coord(nlp, x)
@@ -63,6 +65,8 @@ function multiple_precision_nlp(
6365
@test cons exclude || typeof(cons(nlp, x)) == S
6466
@test jac exclude || eltype(jac(nlp, x)) == T
6567
@test jac_op exclude || eltype(jac_op(nlp, x)) == T
68+
@test jprod exclude || typeof(jprod(nlp, x, v)) == S
69+
@test jtprod exclude || typeof(jtprod(nlp, x, y)) == S
6670
if linear_api && nlp.meta.nnln > 0
6771
@test cons exclude || typeof(cons_nln(nlp, x)) == S
6872
@test jac exclude || eltype(jac_nln(nlp, x)) == T
@@ -100,6 +104,7 @@ function multiple_precision_nlp(
100104
@test hess exclude || eltype(hess(nlp, x, y)) == T
101105
@test hess exclude || eltype(hess(nlp, x, y, obj_weight = one(T))) == T
102106
@test hess_op exclude || eltype(hess_op(nlp, x, y)) == T
107+
@test hprod exclude || typeof(hprod(nlp, x, y, v)) == S
103108
if hess_coord exclude && hess_op exclude
104109
rows, cols = hess_structure(nlp)
105110
vals = hess_coord(nlp, x, y)

src/nls/multiple-precision.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ function multiple_precision_nls(
4747
nls = nls_from_T(T)
4848
S = typeof(nls.meta.x0)
4949
x = fill!(S(undef, nls.meta.nvar), 1)
50+
v = fill!(S(undef, nls.meta.nvar), 2)
51+
y = fill!(S(undef, nls.meta.ncon), 2)
52+
w = fill!(S(undef, nls.nls_meta.nequ), 2)
5053
@test residual exclude || typeof(residual(nls, x)) == S
5154
@test jac_residual exclude || eltype(jac_residual(nls, x)) == T
5255
@test jac_op_residual exclude || eltype(jac_op_residual(nls, x)) == T
56+
@test jprod_residual exclude || typeof(jprod_residual(nls, x, v)) == S
57+
@test jtprod_residual exclude || typeof(jtprod_residual(nls, x, w)) == S
5358
if jac_coord_residual exclude && jac_op_residual exclude
5459
rows, cols = jac_structure_residual(nls)
5560
vals = jac_coord_residual(nls, x)
@@ -64,6 +69,11 @@ function multiple_precision_nls(
6469
@test eltype(hess_op_residual(nls, x, i)) == T
6570
end
6671
end
72+
if hprod_residual exclude
73+
for i = 1:(nls.nls_meta.nequ)
74+
@test typeof(hprod_residual(nls, x, i, v)) == S
75+
end
76+
end
6777
@test obj exclude || typeof(obj(nls, x)) == T
6878
@test grad exclude || typeof(grad(nls, x)) == S
6979
if nls.meta.ncon > 0
@@ -87,6 +97,8 @@ function multiple_precision_nls(
8797
Av = fill!(S(undef, nls.meta.ncon), 0)
8898
Atv = fill!(S(undef, nls.meta.nvar), 0)
8999
@test eltype(jac_op!(nls, rows, cols, vals, Av, Atv)) == T
100+
@test jprod exclude || typeof(jprod(nls, x, v)) == S
101+
@test jtprod exclude || typeof(jtprod(nls, x, y)) == S
90102
if linear_api && nls.meta.nnln > 0
91103
rows, cols = jac_nln_structure(nls)
92104
vals = jac_nln_coord(nls, x)

0 commit comments

Comments
 (0)