I'm a new to Eigen and I'm working with sparse LU problem. I found that if I create a vector b(n), Eigen could compute the x(n) for the Ax=b equation.
How to display the L & U, which is the factorization result of the original matrix A?
How to insert non-zeros in Eigen? Right now I just test with some small sparse matrix so I insert non-zeros one by one, but if I have a large-scale matrix, how can I input the matrix in my program?
If you'll use Eigen::FullPivLU::matrixLU()
to the original matrix, you'll receive LU decomposition matrix. To display L and U separately, you can use method triangularView<
mode>
. In Eigen wiki you can find good example of it. Inserting nonzeros into matrices depends on numbers, which you wan't to put. Eigen has convenient syntax, so you can easily insert values in loop:
for(int i=0;i<size;i++)
{
for(int j=size;j>someNumber;j--)
{
matrix(i,j)=yourClass.getNextNumber();
}
}