You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quoting from the docs: "When unsafe=true is passed, if the type of A is already consistent with the type of mumps, then pointers to A's memory are passed directly to MUMPS, so modifying A will modify the matrix in mumps." MUMPS requires the matrix to be in coordinate form: the code calls findnz, then sets the mumps object's pointers to the result. So changes in A's data aren't reflected in the mumps object.
Short demonstration of this:
using MUMPS, MPI, SparseArrays
MPI.Init()
A = sparse([1, 1, 2, 2], [1, 2, 1, 2], [1.0, 0.0, 0.0, 1.0])
# A is [1.0 0.0; 0.0 1.0], but with all 4 elements structurally nonzero.
rhs = [1.0, 0.0]
mumps = Mumps{Float64}(mumps_unsymmetric, default_icntl, default_cntl64)
associate_matrix!(mumps, A; unsafe = true)
associate_rhs!(mumps, rhs)
A[1,1] = 0.0; A[1, 2] = 1.0; A[2,1] = 1.0; A[2,2] = 0.0 # now A is [0.0 1.0; 1.0 0.0]
factorize!(mumps); solve!(mumps)
x = MUMPS.get_sol(mumps)
@assert A*x == rhs # nope! x is [1.0, 0.0], the solution before we changed A.
The easy fix to this would be to simply change the docs. However, I'm hoping to use this functionality. Let's see...maybe add SparseArraysCOO.jl as a dependency and implement associate_matrix!(A::SparseMatrixCOO)?
If adding that dependency is ok, I'd be willing to write the implementation.
The text was updated successfully, but these errors were encountered:
I am wondering if we should not create a function to update the pointer only for the nonzeros of A.
It is the only vector that we expect to have new values inside.
Compared to the COO format, only colptr needs to be transformed from a sparse CSC matrix. findnz is maybe not the most efficient routine if we don't want to allocate storage.
Quoting from the docs: "When
unsafe=true
is passed, if the type ofA
is already consistent with the type of mumps, then pointers toA
's memory are passed directly to MUMPS, so modifyingA
will modify the matrix in mumps." MUMPS requires the matrix to be in coordinate form: the code callsfindnz
, then sets the mumps object's pointers to the result. So changes in A's data aren't reflected in the mumps object.Short demonstration of this:
The easy fix to this would be to simply change the docs. However, I'm hoping to use this functionality. Let's see...maybe add SparseArraysCOO.jl as a dependency and implement
associate_matrix!(A::SparseMatrixCOO)
?If adding that dependency is ok, I'd be willing to write the implementation.
The text was updated successfully, but these errors were encountered: