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

Array coefficient wise operator (newbie question)

Tags: None
(comma "," separated)
jrabary
Registered Member
Posts
1
Karma
0
Hi all,

I'm new to eigen and try to use it in my code.

I need to find all coefficients that is above a threshold in a vector but I can't figure out how to do this.

Here is what I already do :

VectorXf v(5);
v << 1,4,5,2,3;

if I do

v.array() > 3;

it returns a binary vector but I can't do some thing like :

v[v.array() > 3];

neither

VectorXb mask = v.array() > 3;

What is the correct way to do this ?

Thanks for your help,

Jaonary
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hm, VectorXb mask = v.array() > 3; should be ok. And then you will have to do some manual job to mimic the MatLab feature:

v[v.array() > 3];

that we plane to support asap...
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
oh, if

VectorXb mask = v.array() > 3;

does not work, then rather do:

VectorXb mask ;
mask = v.array() > 3;


that's just some usual C++ annoyance.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]