Registered Member
|
Hi,
in order to be more efficient and avoid copying matrices, I wanted to swap the eigenvectors with an empty matrix with MatrixXd mX; eigensolver.eigenvectors().swap(mX); but eigenvectors() returns a const reference to the matrix. As I am not seeing any other solution, I am using a const_cast: MatrixXd mX; const_cast<Eigen::MatrixXd&>(eigensolver.eigenvectors()).swap(mX); Is there any other solution? Is this way of doing (somehow) right? Many thanks for any help Benjamin |
Moderator
|
I guess your goal is to avoid a deep copy right ? However note that this copy is completely negligible compared to the cost of computing the eigenvectors.
|
Registered Member
|
Yes, this was the goal. I know the cost is far from the cost of computing the eigenvalues, but at least it can be easily reduced to almost nothing.
Thanks Benjamin |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]