how to change a 1*1 matrix in Eigen to float?

eigen, matrix

Solution

If `mat` is an 1-by-1 matrix, then `mat.value()` is its only entry as a scalar.

Thus, you can do

mtemp(0,0) = (((MatrixXf(1,2) << 0, 2).finished()) 
              * ((MatrixXf(2,1) << 0, 2).finished())).value();

Problem

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'.

Original source