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

iterative solvers and dense matrices

Tags: None
(comma "," separated)
johndaily
Registered Member
Posts
3
Karma
0
Previously the 'Sparse' iterative solvers could be used with Dense matrices:

From
http://eigen.tuxfamily.org/dox/classEig ... dient.html
Template Parameters
_MatrixType the type of the matrix A, can be a dense or a sparse matrix.

However, since changeset a1a17c5 (Fix compilation of int*complex with gcc) this is no longer supported.
The last working changeset was ffcbcbb.

I have attached a simple example and error output with g++. It looks as though CongugateGradient now is only compatible with classes derived from SparseMatrixDerived. BiCGSTAB is similar.

Is this change going to be permanent? There are numerous uses for iterative solvers with dense matrices. But of course it's not too hard to roll your own.

If this will be a permanent change, can we change the documentation? I could file this as a bug, but I hesitate to if it's a necessary change.

Thanks,

-- Trevor

Code: Select all
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <iostream>

using namespace std;
using namespace Eigen;

int main() {
    int N = 20;
    Eigen::MatrixXd A = Eigen::MatrixXd::Zero( N, N );
    for (int i=0; i<N; ++i) {
        A(i,i) = 2;
        if (i > 0) {
            A(i, i-1) = -1;
        }
    }

    VectorXd b = VectorXd::Zero(N);
        b(N/2) = 1;
    VectorXd x = VectorXd::Zero(N);

    ConjugateGradient< MatrixXd, Eigen::Lower > cg;
    cg.compute(A);
    x = cg.solve(b);

    std::cout << A << std::endl;
    std::cout << b << std::endl;
    std::cout << x << std::endl;
}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
That's an unwelcome side effect. Will be fixed soon.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Fixed in changeset ef83bca1aeed.
johndaily
Registered Member
Posts
3
Karma
0
Thanks Gael!


Bookmarks



Who is online

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