This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Conjugated gradient with preconditioner

Tags: None
(comma "," separated)
learner
Registered Member
Posts
10
Karma
0
Dear all,

I have a very huge sparse matrix and i tried this small piece of code. It works but for my matrix takes 15 minutes.
I have implemented the conjugated gradient by myself with jacobian and solves the problem very fast.

Code: Select all
   Eigen::BiCGSTAB<MappedSparseMatrix<double>, Eigen::IncompleteLUT<double> >  BCGST;
    BCGST.compute(mat);
   //solver.setMaxIterations(maxIt);
    //solver.setTolerance(tol);
    BCGST.compute(mat);
    xx = BCGST.solve(bb);


so I would like to try the conjugated gradient of the library but with the preconditioner Incomplete LU
to check if it can go faster. I have tried like this but it crashes

Code: Select all
   Eigen::ConjugateGradient<MappedSparseMatrix<double>, Eigen::IncompleteLUT<double> >  BCGST;
    BCGST.compute(mat);
   //solver.setMaxIterations(maxIt);
    //solver.setTolerance(tol);
    BCGST.compute(mat);
    xx = BCGST.solve(bb);


I would like to know how to call the conjugate gradient with Incomplete LU preconditionter. And also if there
is a way to speed up the BiCGSTAB

Thanks
learner
Registered Member
Posts
10
Karma
0
Can it be so slow because the matrix is not compresed. Is it possible to compress a MappedSparseMatrix?.

Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
If your matrix is symmetric use a ConjugateGradient, there is no way that BiCGSTAB could be faster. Then, if you wanna try a more sophisticated preconditioner, then you need one that preserves symmetry, so no ILUT, but an incomplete LLT. There is an implementation (IncompleteCholesky) in unsupported/Eigen/SparseExtra. But since it is in unsupported I don't know if it is fully working.
learner
Registered Member
Posts
10
Karma
0
Thanks for your answer. I was wondering if there is any manual of
how to use the LUT with conjugate gradients

Code: Select all
  Eigen::ConjugateGradient< Eigen::SparseMatrix<double> > cg;
  cg.compute(M);
  x = cg.solve(b);


The incomplete cholesky takes me a long time. I tried in my code incomplete cholesky perconditioner
to solve the linear eq for z = M^-1 r but it takes a long time. So i would like to try cg with lut to see if it goes faster
than my code using jacobian

Thanks
Cheers
Royi
Registered Member
Posts
34
Karma
0
ggael wrote:If your matrix is symmetric use a ConjugateGradient, there is no way that BiCGSTAB could be faster. Then, if you wanna try a more sophisticated preconditioner, then you need one that preserves symmetry, so no ILUT, but an incomplete LLT. There is an implementation (IncompleteCholesky) in unsupported/Eigen/SparseExtra. But since it is in unsupported I don't know if it is fully working.

Hi,

Does Eigen use Intel MKL for Sparse Matrices?


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]