Registered Member
|
Is there an efficient Eigen way of doing the following?
I need to examine a matrix coefficientWise for values great than zero and assign a zero or 1 to a corresponding element in a new matrix
It seems I read some where something like this might be possible: mtxfBinary = (mtxfCold > 0).somefunction(); Thanks |
Moderator
|
for instance:
MatrixXd mtxfBinary; mtxfBinary = (mtxCold > 0).cast<double>() replace double by the scalar type you like, (mtxCold > 0) returns an expression of double. |
Registered Member
|
Thx ggael,
I tried this since both matricies were floats mtxfBinary = ( mtxfCorrelation > 0).cast<float>(); However I'm getting compile errors after that implementation: error C2784: 'bool std::operator >(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'Eigen::MatrixXf' 1> c:\Program Files\Microsoft Visual Studio 10.0\VC\include\memory(2602) : see declaration of 'std::operator >' First in a series of about 60 of them. Would this be a MSVS 2010 compiler issue? |
Moderator
|
oh, you need to go to the array world for such comparisons: dest = (mat.array() > 0).cast<float>();
|
Registered Member
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]