Skip to content

Commit 16208a4

Browse files
authored
SparseMatrix with abstract Tv (#18)
1 parent bde5dff commit 16208a4

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/conic_form.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function get_conic_form(::Type{T}, model::M, con_idx) where {T, M <: MOI.Abstrac
2929
cones = _set_type.(con_idx)
3030
cones = unique(cones)
3131

32-
conic = ConicForm{T, SparseMatrixCSRtoCSC{Int}, Array{T, 1}}(Tuple(cones))
32+
conic = ConicForm{T, SparseMatrixCSRtoCSC{T, Int}, Vector{T}}(Tuple(cones))
3333

3434
idxmap = MOI.copy_to(conic, model)
3535

src/sparse_matrix.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
mutable struct SparseMatrixCSRtoCSC{T}
1+
mutable struct SparseMatrixCSRtoCSC{Tv,Ti<:Integer}
22
m::Int # Number of rows
33
n::Int # Number of columns
4-
colptr::Vector{T}
5-
rowval::Vector{T}
6-
nzval::Vector{Float64}
7-
function SparseMatrixCSRtoCSC{T}(n) where T
4+
colptr::Vector{Ti}
5+
rowval::Vector{Ti}
6+
nzval::Vector{Tv}
7+
function SparseMatrixCSRtoCSC{Tv, Ti}(n) where {Tv, Ti<:Integer}
88
A = new()
99
A.n = n
10-
A.colptr = zeros(T, n + 1)
10+
A.colptr = zeros(Ti, n + 1)
1111
return A
1212
end
1313
end
14-
function allocate_nonzeros(A::SparseMatrixCSRtoCSC{T}) where T
14+
function allocate_nonzeros(A::SparseMatrixCSRtoCSC{Tv, Ti}) where {Tv, Ti}
1515
for i in 3:length(A.colptr)
1616
A.colptr[i] += A.colptr[i - 1]
1717
end
18-
A.rowval = Vector{T}(undef, A.colptr[end])
19-
A.nzval = Vector{Float64}(undef, A.colptr[end])
18+
A.rowval = Vector{Ti}(undef, A.colptr[end])
19+
A.nzval = Vector{Tv}(undef, A.colptr[end])
2020
end
2121
function final_touch(A::SparseMatrixCSRtoCSC)
2222
for i in length(A.colptr):-1:2

0 commit comments

Comments
 (0)