Skip to content

Commit 818ec7b

Browse files
authored
Add eltype for NLPModels (#481)
1 parent 82100be commit 818ec7b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/nlp/utils.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,10 @@ macro default_counters(Model, inner)
141141
)
142142
ex
143143
end
144+
145+
"""
146+
eltype(nlp::AbstractNLPModel{T, S})
147+
148+
Element type of `nlp.meta.x0`.
149+
"""
150+
Base.eltype(nlp::AbstractNLPModel{T, S}) where {T, S} = eltype(nlp.meta.x0)

test/nlp/api.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
H(x, y) = H(x) + y[2] * [-0.5 0; 0 -2.0]
88

99
nlp = SimpleNLPModel()
10+
@test eltype(nlp) == Float64
1011
n = nlp.meta.nvar
1112
m = nlp.meta.ncon
1213

test/nls/api.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
HF(x, w) = w[2] * [-20.0 0; 0 0]
55

66
nls = SimpleNLSModel()
7+
@test eltype(nls) == Float64
78
n = nls.meta.nvar
89
m = nls.meta.ncon
910
ne = nls_meta(nls).nequ

0 commit comments

Comments
 (0)