Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add COO constructor and update method #91

Merged
merged 2 commits into from
Apr 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions src/wrapper/qr_mumps_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,35 @@ for (fname, lname, elty, subty) in (("sqrm_spmat_init_c", libsqrm, Float32 , F
return spmat
end

function qrm_spmat_init!(spmat :: qrm_spmat{$elty}, A :: SparseMatrixCSC{$elty,I}; sym :: Bool=false) where I <: Integer
function qrm_spmat_init!(spmat :: qrm_spmat{$elty}, m :: Integer, n :: Integer, irn :: AbstractVector{I}, jcn :: AbstractVector{I}, val :: AbstractVector{$elty}; sym :: Bool=false) where I <: Integer
nz = length(irn)
@assert nz == length(jcn)
@assert nz == length(val)
err = ccall(($fname, $lname), Cint, (Ref{c_spmat{$elty}},), spmat)
(err ≠ 0) && throw(ErrorException(error_handling(err)))
spmat.irn, spmat.jcn, spmat.val = findnz(A)
spmat.mat.m, spmat.mat.n = size(A)
spmat.mat.nz = nnz(A)
spmat.irn = irn
spmat.jcn = jcn
spmat.val = val
spmat.mat.m = m
spmat.mat.n = n
spmat.mat.nz = nz
spmat.mat.sym = sym
spmat.mat.irn = pointer(spmat.irn)
spmat.mat.jcn = pointer(spmat.jcn)
spmat.mat.val = pointer(spmat.val)
return nothing
end

function qrm_spmat_init(m :: Integer, n :: Integer, irn :: AbstractVector{I}, jcn :: AbstractVector{I}, val :: AbstractVector{$elty}; sym :: Bool=false) where I <: Integer
spmat = qrm_spmat{$elty}()
qrm_spmat_init!(spmat, m, n, irn, jcn, val; sym = sym)
return spmat
end

function qrm_spmat_init!(spmat :: qrm_spmat{$elty}, A :: SparseMatrixCSC{$elty,I}; sym :: Bool=false) where I <: Integer
qrm_spmat_init!(spmat, size(A)..., findnz(A)...; sym = sym)
end

function qrm_spmat_init(A :: SparseMatrixCSC{$elty,I}; sym :: Bool=false) where I <: Integer
spmat = qrm_spmat{$elty}()
qrm_spmat_init!(spmat, A, sym=sym)
Expand Down Expand Up @@ -823,7 +839,11 @@ function qrm_finalize()
return nothing
end

function qrm_update!(spmat :: qrm_spmat{T}, A :: SparseMatrixCSC{T,I}) where {T, I <: Integer}
spmat.val .= A.nzval
function qrm_update!(spmat :: qrm_spmat{T}, val :: AbstractVector{T}) where T
spmat.val .= val
return nothing
end

function qrm_update!(spmat :: qrm_spmat{T}, A :: SparseMatrixCSC{T,I}) where {T, I <: Integer}
qrm_update!(spmat, A.nzval)
end
Loading