Reply to topic

Logical operations on matrices

matriza
Registered Member
Posts
15
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
15
Karma
0

Re: Logical operations on matrices

Mon Jan 21, 2013 5:37 am
thanks!

 
Reply to topic

Bookmarks



Who is online

Registered users: AElfwine, alake, anditosan, Artmessiah, Baidu [Spider], Bing [Bot], edmael, Exabot [Bot], garthecho, geaplanet, Google [Bot], google01103, Horus, inksi, Joif, ken300, La Ninje, lazyit, pedrorodriguez, pvonz, thalesgava, tienhung, VP1986, Yahoo [Bot]