Add a getter for L and U matrices in SparseLU
Describe the feature you would like to be implemented.
I would like to add a method the returns the result of SparseLU module to users as standard SparseMatrix objects, i.e. a function that returnsSparseMatrix L, U; PermutationMatrix perm_c, perm_r; where L and U are true lower and upper trangular CSC format sparse matrices.
Currently, the SparseLU module doesn't expose its resulting matrices but only a solvemethod. The internal L is stored in SC format and contains some parts of U, while U is a normal CSC sparse matrix containing the rest of U, so they are not directly usable outside SuperLU module.
Would such a feature be useful for other users? Why?
This allows users to use the decomposition as a part of other calculations or using Eigen::SparseLU and other libraries at the same time. While the buildin solve module satisfy most usecases when using Eigen alone, this could be helpful if the user wants to do calculation with the LU decomposition with other libraries.
For my usecase, I'm implementing a shift-invert sparse eigensolver with CUDA acceleration. I need to upload the result of SparseLU to a GPU and perform solve (essentially matvec opperation on the inverse) on GPU.
Any hints on how to implement the requested feature?
U is stored internally as a normal CSC sparse matrix, so not much to worry. L is stored internally in a supernode matrix, which uses the SC format described in SuperLU's user guide. L's supernodes contains both below-diagonal parts belonged to L and above-diagonal parts belonged to U. A getter function would construct new CSC sparse matrices L and U, then fill them using data internally stored L, U. The code in SciPy's SuperLU wrapper has this part which can be directly used. https://github.com/scipy/scipy/blob/v1.10.0/scipy/sparse/linalg/_dsolve/_superluobject.c
Should I implement this as a getter, a member function of the class SparseLU?