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

Logical operations on matrices

Tags: None
(comma "," separated)
matriza
Registered Member
Posts
17
Karma
0

Logical operations on matrices

Thu Jan 17, 2013 11:11 am
Hi,

A while back there was some code posted for doing logical operations on matrices, but I can't get it to work on eigen 3.1.2 on OSX 10.7.5:

test.cpp:

Code: Select all
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/Eigen>

using namespace Eigen;

void test()
{
   MatrixXf X(10, 10);
   Matrix<bool,Dynamic,Dynamic> Y = X > 40;
}


Compilation fails:

Code: Select all
$ /usr/local/bin/g++-4.7 -I/usr/local/include/eigen3 -c test.cpp -o test.otest.cpp: In function 'void test()':
test.cpp:10:41: error: no match for 'operator>' in 'X > 40'


Any ideas?
Thanks.
fbeyer
Registered Member
Posts
8
Karma
0
These coefficient-wise operators only work on arrays, not matrices. You can get an array view using the array() method:

Code: Select all
MatrixXf X(10, 10);
Array<bool, Dynamic, Dynamic> Y = X.array() > 40;


For a list of all supported opeators, see http://eigen.tuxfamily.org/dox/QuickRefPage.html#QuickRef_Coeffwise
matriza
Registered Member
Posts
17
Karma
0

Re: Logical operations on matrices

Mon Jan 21, 2013 5:37 am
thanks!


Bookmarks



Who is online

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