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

bsxfun equivelent in Eigen

Tags: None
(comma "," separated)
rorymullan
Registered Member
Posts
3
Karma
0

bsxfun equivelent in Eigen

Wed Jun 06, 2012 5:07 pm
Code: Select all
>> A = [1 2 3;4 5 6;7 8 9]

A =

     1     2     3
     4     5     6
     7     8     9

>> v = [3,2,1]

v =

     3     2     1

>> bsxfun(@times,A,v)

ans =

     3     4     3
    12    10     6
    21    16     9


bsxfun is a matlab function that allows me to multiply each value in a column by a single values, stored in a seperate vector as shown above. I'm trying to work out the equivelent way of doing this in Eigen and cant seem to find anything in the documentation. Any suggestions?

Thanks

Rory
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: bsxfun equivelent in Eigen  Topic is solved

Wed Jun 06, 2012 5:39 pm
this is a diagonal-matrix product:

A * v.asDiagonal()
rorymullan
Registered Member
Posts
3
Karma
0

Re: bsxfun equivelent in Eigen

Wed Jun 06, 2012 5:41 pm
Thanks Alot!


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell