I’m using eigen matrix library.
How can I convert a matrix of 1* 1 to a number(float or others)?
It’s OK to do this
cout << ((MatrixXf(1,2) << 0, 2).finished()) * ((MatrixXf(2,1) << 0, 2).finished()) << endl;
But when I try to do this
MatrixXf mtemp(2,1);
mtemp(0,0) = ((MatrixXf(1,2) << 0, 2).finished()) * ((MatrixXf(2,1) << 0, 2).finished());
It said ‘cannot convert const Eigen::GeneralProduct to float in assignment’.
If
matis an 1-by-1 matrix, thenmat.value()is its only entry as a scalar.Thus, you can do