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

conjugate gradient

Tags: None
(comma "," separated)
pidanchen
Registered Member
Posts
20
Karma
0

conjugate gradient

Thu Nov 24, 2011 5:08 am
Hello,

I am trying to use CG to solve A*X=B. Seems that CG is only available in the development branch right now?

Anyway, I have a strange compile error.

Code: Select all
#include <Eigen/SparseCore>
#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>

int n = 10000;
VectorXd x(n), b(n);
SparseMatrix<double> A(n,n);
// fill A and b
ConjugateGradient<SparseMatrix<double> > cg;
cg(A);
x = cg.solve(b);



It is directly copied from the document. However, there is a compile error here:

Error: no match for call to ‘(Eigen::ConjugateGradient<Eigen::SparseMatrix<double, 0, int>, 1, Eigen::DiagonalPreconditioner<double> >) (Eigen::SparseMatrix<double, 0, int>&)’


Am I missing something?
pidanchen
Registered Member
Posts
20
Karma
0

Re: conjugate gradient  Topic is solved

Thu Nov 24, 2011 5:24 am
I figured it out, it should be

cg.solver(A);


pidanchen wrote:Hello,

I am trying to use CG to solve A*X=B. Seems that CG is only available in the development branch right now?

Anyway, I have a strange compile error.

Code: Select all
#include <Eigen/SparseCore>
#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>

int n = 10000;
VectorXd x(n), b(n);
SparseMatrix<double> A(n,n);
// fill A and b
ConjugateGradient<SparseMatrix<double> > cg;
cg(A);
x = cg.solve(b);



It is directly copied from the document. However, there is a compile error here:

Error: no match for call to ‘(Eigen::ConjugateGradient<Eigen::SparseMatrix<double, 0, int>, 1, Eigen::DiagonalPreconditioner<double> >) (Eigen::SparseMatrix<double, 0, int>&)’


Am I missing something?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: conjugate gradient

Thu Nov 24, 2011 7:15 am
hm, no, it's rather:

cg.compute(A);

There is no such "solver" function.


Bookmarks



Who is online

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