Re: [eigen] Permutation times Sparse matrix

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


hm, I think this is a bug on our side because:

- if L is dense, then we detect aliasing and apply the permutation in-place
- if L is sparse, then this should be fine because we never directly assign to a sparse matrix, but rather build a new one, and then perform a shallow copy (aka move-assignment).

After checking your example, it turns out that this has already been fixed in the 3.3 branch, but not in the 3.2 branch. A simple backport won't work here because the assignment/evaluation logic have been completely redesigned.

gael


On Mon, Sep 19, 2016 at 4:38 PM, Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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/