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

How to carry out array operation on a block ?

Tags: None
(comma "," separated)
kde-crazy
Registered Member
Posts
20
Karma
0
Like this:

Code: Select all
MatrixXd m(5,3);
VectorXd v(2);

//what I want to do is this, but this won't work
 m.leftCols(2).array()*v.array();
//or this won't work too
 ((m.leftCols(2)).matrix()).array()*v.array();


So I just do it this way:
Code: Select all
MatrixXd tmp = m.leftCols(2);
tmp.array()*v.array();

This one works but I think it's redundant, how to make the block a matirx on the fly?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hm, you're multiplying coefficient-wise a 5x2 sub-matrix with a 2x1 vector !!! that cannot work!
kde-crazy
Registered Member
Posts
20
Karma
0
ggael wrote:hm, you're multiplying coefficient-wise a 5x2 sub-matrix with a 2x1 vector !!! that cannot work!

Ahh, yeah, I made a mistake.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]