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

operator <

Tags: None
(comma "," separated)
sgubian
Registered Member
Posts
2
Karma
0

operator <

Tue Dec 15, 2009 1:59 pm
Hi,

I am tring to use the < CWISE Binary Operator like this:
Code: Select all
#include <Eigen/Core>
#include <Eigen/Array>

int main(int argc, char** argv) {

    MatrixXf mat1(3, 3);
    MatrixXf mat2(3, 3);
    mat1 << 1, 2, 3, 4, 5, 6, 7, 8, 9;
    mat2 = mat1.cwise() < 5 ; // this does not compile
    // But this compiles
    std::cout << " Result:" << std::endl << (mat1.cwise() < 5)  << std::endl;
    return 0;
}


What's wrong here ?
Thank you for your help.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: operator <

Tue Dec 15, 2009 2:06 pm
hi,

mat1.cwise() < 5

returns a matrix of bool, so you have to cast it or directly do something with it, e.g.:

mat2 = (mat1.cwise() < 5).cast<float>();

ma2 = (mat1.cwise() < 5).select(0.f,mat1);
sgubian
Registered Member
Posts
2
Karma
0

Re: operator <

Tue Dec 15, 2009 2:23 pm
Great !

Thank you very much. This helps a lot.
Best regards,

Sylvain.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]