I'v implemented the modulus of a matrix as follows, but it fails to compile :
const double dPI = std::acos( double(-1.) );
using baseSpaceVd = Matrix<double, 4, 1>;
baseSpaceVd M(0,1,2,3);
M = M.unaryExpr( []( const baseSpaceVd::Scalar x ) { return x%(2*dPI); } );
Compilation error message is :
../src/COpdCtrl.cpp: In lambda function:
../src/COpdCtrl.cpp:187:85: error: invalid operands of types ‘const Scalar {aka const double}’ and ‘double’ to binary ‘operator%’
curGDerr = curGDerr.unaryExpr( []( const baseSpaceVd::Scalar x ) { return x%(2*dPI); } );
This fix works but I'am afraid it degrades the performance :
M = M.unaryExpr( []( const baseSpaceVd::Scalar x ) { return fmod( x, (2*dPI); } );