1
votes

I want to use Eigen to compute L_1^{-1}L_2, where both L_1 and L_2 are lower triangular matrices and are stored as column oriented sparse matrices in Eigen. I tried the Eigen triangular solver. However, that requires L_2 to be dense.

1
The inverse of a sparse matrix is usually dense, therefore L_1^{-1}*L_2 will be dense as well. Are you sure, you need to store the matrix, instead of just computing products/solving systems on the fly? - chtz
@chtz Thanks for your response. I actually have guarantee that L_1^{-1} is also sparse. - Ting

1 Answers

1
votes

The solve method in fact is not overloaded for sparse rhs, however you can use the solveInPlace method like so (I did not actually try this):

Eigen::SparseMatrix<double> foo(Eigen::SparseMatrix<double> const& L1, Eigen::SparseMatrix<double> const& L2)
{
    Eigen::SparseMatrix<double> res = L2;
    L1.triangularView<Eigen::Lower>().solveInPlace(res);
    return res;
}

Still you should consider if you actually need the full matrix.