Re: [eigen] Permutation times Sparse matrix

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


This looks like an aliasing problem. Just assign the result to a new matrix. Ideally, we could implement a "permute{Rows,Cols}InPlace" method for that use case. And we should probably warn more explicitly that sparse products are not aliasing-save.

Christoph

On 2016-09-19 16:29, Brad Bell wrote:
When I execute the program below I expect to get
L=
1 0
0 1
But I get
L =
0 0
0 0

# include <Eigen/SparseCore>
# include <iostream>
int main()
{   Eigen::SparseMatrix<double> L(2,2);
    L.insert(0,0) = 1.0;
    L.insert(1,1) = 1.0;
    Eigen::PermutationMatrix<2,2> P;
    P.setIdentity();
    L = P * L;
    std::cout << "L =\n" << Eigen::Matrix<double,2,2>(L) << "\n";
    return 0;
}





--
 Dipl. Inf., Dipl. Math. Christoph Hertzberg

 Universität Bremen
 FB 3 - Mathematik und Informatik
 AG Robotik
 Robert-Hooke-Straße 1
 28359 Bremen, Germany

 Zentrale: +49 421 178 45-6611

 Besuchsadresse der Nebengeschäftsstelle:
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Tel.:    +49 421 178 45-4021
 Empfang: +49 421 178 45-6600
 Fax:     +49 421 178 45-4150
 E-Mail:  chtz@xxxxxxxxxxxxxxxxxxxxxxxx

 Weitere Informationen: http://www.informatik.uni-bremen.de/robotik



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