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

How can I do such kind of multiplication?

Tags: None
(comma "," separated)
kde-crazy
Registered Member
Posts
20
Karma
0
Which is every column of a matrix multiplys a vector. Something like this:
Code: Select all
mat.colwise()  *= v;


If M is
M << 1, 2, 6, 9,
3, 1, 7, 2;
v is
v<<2, 3;

I want to get

2 4 12 18
9 3 21 6
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
in other word you want to scale each rows, so:

M = v.asDiagonal() * M;
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
btw, moving to the "array world" should work too:

M = M.array().colwise() * v.array();
kde-crazy
Registered Member
Posts
20
Karma
0
Thanks a lot!


Bookmarks



Who is online

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