Re: [eigen] Sparse non-SPD symmetric solving

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



Hi,

yes, since SparseLU is for general square problems, you need to build a full version explicitly using A.selfadjointView<Upper>(). Note that Upper is a template parameter, not an argument of the method.

On the other hand, solvers specialized for self-adjoint problems (e.g., Simplicial*, ConjugateGradient) read only the triangular part as specified by their 2nd template argument. For them, calling sefladjointView is thus not required, and even counter productive. Here is an example:

ConjugateGradient<SparseMatrix<double>, Upper> cg;
cg.compute(A);

cheers,
Gaël




On Fri, Jun 5, 2015 at 10:46 PM, Alberto Luaces <alberto.luaces@xxxxxxxxx> wrote:
Hi,

I want to solve a symmetric, non-definite positive sparse linear
system.  My input is a matrix whose values are stored into the upper
part.

I wonder if the following is the best way to solve the system.  I am
concerned about my handling of the symmetric matrix: should I use the
adjoint view or try to build an adjoint matrix from the beginning?

Eigen::SparseMatrix<double> A;
A.setFromTriplets(...);

Eigen::SparseLU<Eigen::SparseMatrix<double>> solver;

solver.isSymmetric(true);
solver.compute(A.selfadjointView(Eigen::Upper)).solve(b);

Thanks,

--
Alberto





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/