This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How can I convert a matrix of 1* 1 to a number(float or othe

Tags: None
(comma "," separated)
cwyalpha
Registered Member
Posts
1
Karma
0
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'.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Because the result of the matrix product is a matrix. If you use vectors instead of dynamically sized matrices, then Eigen will predict that the result is a 1x1 matrix and allow you to do the conversion. Also using vectors is much faster.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]