vendredi 30 mars 2018

Eigen class members empty after constructor

I need to solve a computational problem in C++. In order to achieve my tasks I organized my code in a class which contains several Eigen members (dense and sparse matrix). My class looks like:

class Myclass{
private:
 ...
 Eigen::MatrixXd M1;
 Eigen::SparseMatrix<double> M2;

 void fill_M1(..); // it fills matrix M1 of the problem
 void fill_M2(..); // it fills matrix M2 of the problem

public:
 Myclass(..): //some initializations
{
  fill_M1(..);
  fill_M2(..);
 }
 ...
 void print_all_matrixes(); // just print M1 and M2
}

If I try to use these matrixes outside the constructor (like with print_all_matrixes()) they result to be empty. It seems that the changes done in the constructor vanish out of the scope.

How can I avoid this behaviour?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire