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
Direct solver LinSolverDirectKLU will accept as an input any matrix::Sparse object, however, it will quietly assume the input matrix is in CSC format. This will likely lead to incorrect result if a nonsymmetric CSR matrix is passed as the input. It would be good to enable LinSolverDirectKLU to operate correctly on general CSR matrices in addition to CSC.
Rationale
Typically sparse matrices are represented in CSR format and most of the Re::Solve use cases of interest involve CSR matrices.
Description
As the first step, LinSolverDirectKLU should check the matrix type ID, and exit immediately if the matrix is neither CSC nor CSR.
If the matrix is CSC, the computation currently implemented should be executed.
If the matrix is CSR, we could use the fact that $\mathrm{csc}(A) = \mathrm{csr}(A^T)$. Passing CSR matrix to KLU factorization should then give factors like
$$A^T = (LU)^T = U^T L^T$$
Based on this, we can implement getLFactor and getUFactor to return proper output when $A$ is a CSR matrix.
KLU provides function klu_tsolve which will do backward-forward substitution for $A^T$, which is de facto matrix stored in CSR format.
Additional information
SUNDIALS wrapper for KLU could provide ideas how to implement similar in LinSolverDirectKLU.
The text was updated successfully, but these errors were encountered:
@pelesh - attempting to fix this here. Not sure why such a simple fix makes the test fail. I haven't even created a test with CSR yet, this is still running the old test.
See here.
I commented out these lines just to verify that this is indeed what is making the tests fail. If I convert the matrix to csc, all KLU tests fail the residual norm test.
Summary
Direct solver
LinSolverDirectKLU
will accept as an input anymatrix::Sparse
object, however, it will quietly assume the input matrix is in CSC format. This will likely lead to incorrect result if a nonsymmetric CSR matrix is passed as the input. It would be good to enableLinSolverDirectKLU
to operate correctly on general CSR matrices in addition to CSC.Rationale
Typically sparse matrices are represented in CSR format and most of the Re::Solve use cases of interest involve CSR matrices.
Description
As the first step,
LinSolverDirectKLU
should check the matrix type ID, and exit immediately if the matrix is neither CSC nor CSR.If the matrix is CSC, the computation currently implemented should be executed.
If the matrix is CSR, we could use the fact that$\mathrm{csc}(A) = \mathrm{csr}(A^T)$ . Passing CSR matrix to KLU factorization should then give factors like
Based on this, we can implement$A$ is a CSR matrix.
getLFactor
andgetUFactor
to return proper output whenKLU provides function$A^T$ , which is de facto matrix stored in CSR format.
klu_tsolve
which will do backward-forward substitution forAdditional information
SUNDIALS wrapper for KLU could provide ideas how to implement similar in
LinSolverDirectKLU
.The text was updated successfully, but these errors were encountered: