I want to move(or swap) an array of type Eigen::ArrayXXd to Eigen::MatrixXd. To achieve this, I tried,
#include <iostream>
#include <Eigen/Dense>
using namespace std;
int main(int , char** ) {
Eigen::ArrayXXd array(100,100);
auto mat2 = std::move(mat.matrix());
cout << array.size() << endl;
cout << mat.size() << endl;
}
The output shows that the both sizes are 10000, which means array was copied. To avoid copy, I also tried,
Eigen::MatrixXd mat;
mat.swap(array.matrix()); (runtime error assert failure)
// swap(array.matrix(), mat); (compile error)
The version of Eigen I tested is 3.2.0 beta1 and gcc 4.8.0 was used. From the experiment, it seems that the move semantic for Matrix and Arrays is not implemented yet. Is that right?
Is there a way I can safely move (without copy)?