Skip to content

Commit 160e6cc

Browse files
geoffroyleconteabelsiqueira
authored andcommitted
change outer constructor types
1 parent 52cb645 commit 160e6cc

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ authors = ["Dominique Orban <[email protected]>"]
44
version = "0.3.0"
55

66
[deps]
7-
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
87
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
98
LinearOperators = "5c8ed15e-5a4c-59e4-a42b-c7e8811fb125"
109
NLPModels = "a4795742-8479-5a88-8948-cc11e1c8c1a6"

src/qpmodel.jl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ mutable struct QuadraticModel{T, S} <: AbstractQuadraticModel{T, S}
3636
end
3737

3838
function QuadraticModel(
39-
c::AbstractVector{T},
39+
c::S,
4040
Hrows::AbstractVector{<:Integer},
4141
Hcols::AbstractVector{<:Integer},
42-
Hvals::AbstractVector;
42+
Hvals::S;
4343
Arows::AbstractVector{<:Integer} = Int[],
4444
Acols::AbstractVector{<:Integer} = Int[],
45-
Avals::AbstractVector = similar(c, 0),
46-
lcon::AbstractVector = similar(c, 0),
47-
ucon::AbstractVector = similar(c, 0),
48-
lvar::AbstractVector = fill!(similar(c, length(c)), T(-Inf)),
49-
uvar::AbstractVector = fill!(similar(c, length(c)), T(Inf)),
50-
c0::T = zero(T),
45+
Avals::S = S(undef, 0),
46+
lcon::S = S(undef, 0),
47+
ucon::S = S(undef, 0),
48+
lvar::S = fill!(S(undef, length(c)), eltype(c)(-Inf)),
49+
uvar::S = fill!(S(undef, length(c)), eltype(c)(Inf)),
50+
c0::T = zero(eltype(c)),
5151
kwargs...,
52-
) where {T}
52+
) where {T, S}
5353
nnzh = length(Hvals)
5454
if !(nnzh == length(Hrows) == length(Hcols))
5555
error("The length of Hrows, Hcols and Hvals must be the same")
@@ -87,16 +87,16 @@ function QuadraticModel(
8787
end
8888

8989
function QuadraticModel(
90-
c::AbstractVector{T},
90+
c::S,
9191
H::SparseMatrixCSC{T, Int};
9292
A::AbstractMatrix = similar(c, 0, length(c)),
93-
lcon::AbstractVector = similar(c, 0),
94-
ucon::AbstractVector = similar(c, 0),
95-
lvar::AbstractVector = fill!(similar(c, length(c)), T(-Inf)),
96-
uvar::AbstractVector = fill!(similar(c, length(c)), T(Inf)),
93+
lcon::S = S(undef, 0),
94+
ucon::S = S(undef, 0),
95+
lvar::S = fill!(S(undef, length(c)), T(-Inf)),
96+
uvar::S = fill!(S(undef, length(c)), T(Inf)),
9797
c0::T = zero(T),
9898
kwargs...,
99-
) where {T}
99+
) where {T, S}
100100
ncon, nvar = size(A)
101101
tril!(H)
102102
nnzh, Hrows, Hcols, Hvals = nnz(H), findnz(H)...
@@ -128,7 +128,7 @@ function QuadraticModel(
128128
)
129129
end
130130

131-
QuadraticModel(c::AbstractVector{T}, H::AbstractMatrix; args...) where {T} =
131+
QuadraticModel(c::S, H::AbstractMatrix; args...) where {S} =
132132
QuadraticModel(c, sparse(H); args...)
133133

134134
"""

0 commit comments

Comments
 (0)