[eigen] Problem extending MatrixBase

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hello list,

I'm running into problems while trying to extending MatrixBase as explained in the wiki:
http://eigen.tuxfamily.org/dox/CustomizingEigen.html#ExtendingMatrixBase

I copied/pasted MatrixBaseAddons.h in my working directory. This code doesn't compile
(with g++-4.4 or g++-4.3, using Eigen 2.0.5, the version packaged in my Ubuntu distro) :

**************************************************************************************************************

#define EIGEN_MATRIXBASE_PLUGIN "/home/raphael/code/snippets/eigen/MatrixBaseAddons.h"
#include <Eigen/Core>
#include <Eigen/Array>

typedef Eigen::Matrix<float,1,Eigen::Dynamic> ArrayF;

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

  ArrayF a = ArrayF::Zero(100);

  return 0;
}

*****************************************************************************************************************
Error message follows :

*****************************************************************************************************************

In file included from /usr/include/eigen2/Eigen/Array:27,
                 from main.cpp:3:
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h: In instantiation of ‘Eigen::Cwise<Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’:
/home/raphael/code/snippets/eigen/MatrixBaseAddons.hpp:31:   instantiated from ‘Eigen::MatrixBase<Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Core/Matrix.h:124:   instantiated from ‘Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
main.cpp:9:   instantiated from here
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:302: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:316: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:330: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:344: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:363: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:382: error: no type named ‘ConstantReturnType’ in ‘class Eigen::Matrix<float, 1, 10000, 2, 1, 10000>’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h: In instantiation of ‘Eigen::Cwise<Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> > >’:
/home/raphael/code/snippets/eigen/MatrixBaseAddons.hpp:31:   instantiated from ‘Eigen::MatrixBase<Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> > >’
/usr/include/eigen2/Eigen/src/Core/CwiseNullaryOp.h:59:   instantiated from ‘Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
main.cpp:9:   instantiated from here
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:302: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:316: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:330: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:344: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:363: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’
/usr/include/eigen2/Eigen/src/Array/CwiseOperators.h:382: error: no type named ‘ConstantReturnType’ in ‘class Eigen::CwiseNullaryOp<Eigen::ei_scalar_constant_op<float>, Eigen::Matrix<float, 1, 10000, 2, 1, 10000> >’

****************************************************************************************************************************

However, If i comment out the last 2 declarations in MatrixBaseAddons.h (the ones with operator+),
it does compile. What am I doing wrong ?

Thanks,
Raphaël

P.S. Btw, I want to extend MatrixBase because I'm only using Array capabilities in Eigen
in my code atm, and want to get rid of all the cwise()


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/