I am trying to solve linear equations in c++ using the Eigen library. For the simple equation Ax=b, I have a sparse matrix A that is n x n, and known values for b which is n x 1, but I need to find the values for x. I tried using
x = A.colPivHouseholderQr().solve(b);
but this solves it for a dense matrix and since my "n" value is quite large, I need to find a way to do this using an implementation that is specific to sparse matrices. I looked into using SparseLU but I've been having trouble trying figure out the syntax behind it. Eigen online says to write something like this :
SparseLU<SparseMatrix<scalar>, COLAMDOrdering<Index>> solver; solver.analyzePattern(A); solver.factorize(A); x = solver.solve(b);
but when I run this, I get errors saying that they don't know what scalar and Index are. Has anyone used SparseLU and know the syntax behind implementing it?