Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cast Eigen::MatrixXd to Eigen::MatrixXf

Tags:

c++

I am using Eigen on a C++ program.

I wonder if there is a way to cast from Eigen::MatrixXd to Eigen::MatrixXf.
static_cast <Eigen::MatrixXf> doesn't seem to work and neither A.cast<MatrixXf> (this is the cast method from Eigen).

Any solution for this type of cast?

like image 292
Sapiens Avatar asked Jul 15 '14 17:07

Sapiens


1 Answers

Try this:

Eigen::MatrixXd d;                       // Matrix of doubles.
Eigen::MatrixXf f = d.cast <float> ();   // Matrix of floats.
like image 168
Gluttton Avatar answered Oct 22 '22 16:10

Gluttton