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

Eigen 3.3: SparseMatrix B.col(i) = A.col(i): bad matrix

Tags: None
(comma "," separated)
joaoruileal
Registered Member
Posts
18
Karma
0
OS
Hello!

The following code snippet gives me incorrect results with Eigen 3.3:
Code: Select all
    Eigen::SparseMatrix<double> A(4, 3);
    A.coeffRef(0, 0) = 1.1;
    A.coeffRef(1, 0) = 2.2;
    A.coeffRef(2, 0) = 3.3;

    A.coeffRef(0, 1) = 4.4;
    A.coeffRef(1, 1) = 5.5;
    A.coeffRef(2, 1) = 6.6;
    A.coeffRef(3, 1) = 7.7;

    A.coeffRef(2, 2) = 8.8;
    A.coeffRef(3, 2) = 9.9;

    Eigen::SparseMatrix<double> B(4, 3);

    B.col(0) = A.col(0);
    B.col(1) = A.col(1);

    std::cout << B << std::endl;

The output is
Code: Select all
Nonzero entries:
(1.1,0) (2.2,1) (3.3,2) (1.1,0) (2.2,1) (3.3,2) (4.4,0)

Outer pointers:
0 3 7  $

1.1 1.1 4.4
2.2 2.2 0
3.3 3.3 0
0 0 0

Notice the duplicate elements and missing elements.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
joaoruileal
Registered Member
Posts
18
Karma
0
OS


Bookmarks



Who is online

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