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

why does this construct work and these others not

Tags: None
(comma "," separated)
kavvak
Registered Member
Posts
9
Karma
0
Hey beloved Eigen Team,

I was wondering why this construct work:


Code: Select all
RowVectorXd lamba(p);
for(i=0;i<p;++i)   lamba(i)=Fmedian(x2.col(i));
x2.rowwise()-=lamba;


but this one doesn't:


Code: Select all
x2.rowwise()/=lamba;


and I have to do:

Code: Select all
   for(i=0;i<p;++i)   x2.col(i).array()/=lambc(i);


thanks in advance!
CountChocula
Registered Member
Posts
4
Karma
0
i think the function you're looking for is cwiseQuotient
kavvak
Registered Member
Posts
9
Karma
0
CountChocula wrote:i think the function you're looking for is cwiseQuotient




No,

Code: Select all
x2.cwiseQuotient(lambc);


doesn't give the same result as:

for(i=0;i<p;++i) x2.col(i).array()/=lambc(i);
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
x2.rowwise()/=lamba;

means for each i, x2.row(i) = x2.row(i) / lambda. In terms of linear algebra, this operation does not make sense. So you need to move to arrays:

x2.array().rowwise() /= lambda.array();


Bookmarks



Who is online

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