Registered Member
|
Hi, I have a problem as follows:
a.) A Dense matrix: e.g.,
b.) If I want to compute a row-wise mean of this matrix; which is easy c.) Now, Is there some function in Eigen that I can use in conjunction with unaryExpr but operated along the rows? Say based on the mean of every row, I would like to determine if an element is greater than or less than the mean of every row? Thanks for your help. Its been a pleasure of using EIgen and converting all data structures into Eigen |
Moderator
|
You cannot apply custom functors row-wise or column-wise, but it your case you can use replicate to achieve your goal:
MatrixXb mask = A > A.rowwise().mean().rowise().replicate(A.cols()) This constructs a matrix of bool such that: mask(i,j)==true <=> A(i,j) > A.row(i).mean() |
Registered Member
|
Hello Gael
Thanks for the information. I was trying to using this for computing the KL-divergence between two vectors that are located in two matrices. Is there some way we can vectorize this using Eigen? |
Registered Member
|
Gael
I have a question regarding this post: viewtopic.php?f=74&t=91378 In my Matrix listed above, I would like to do the following: (Using Matlab notation) for i = 1:5 x{i} = find (M(i,:) > mean(M(i,:))); y{i} = find (M(i,:) <= mean(M(i,:))); end Is there any way I can effect this using Eigen other than writing a for-loop? If I do want to write a custom operator for rowwise operation, where should I start? |
Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]