[eigen] Bug with "vec.cwise() + scalar"?

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


Hi,

Find attached a little test which fails to compile with Eigen 2.0.1 (and SVN):

../eigen2/Eigen/src/Core/CwiseUnaryOp.h: In instantiation of ‘Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >’:
test_vector_add.cpp:13:   instantiated from here
../eigen2/Eigen/src/Core/CwiseUnaryOp.h:97: error: ‘Eigen::CwiseUnaryOp<UnaryOp, MatrixType>::m_functor’ has incomplete type
../eigen2/Eigen/src/Core/util/ForwardDeclarations.h:89: error: declaration of ‘const struct Eigen::ei_scalar_add_op<float>’
.../eigen2/Eigen/src/Core/CwiseUnaryOp.h: In member function ‘const typename Eigen::ei_traits<Eigen::CwiseUnaryOp<UnaryOp, MatrixType> >::Scalar Eigen::CwiseUnaryOp<UnaryOp, MatrixType>::coeff(int, int) const [with UnaryOp = Eigen::ei_scalar_add_op<float>, MatrixType = Eigen::Matrix<float, 4, 1, 0, 4, 1>]’:
.../eigen2/Eigen/src/Core/Coeffs.h:331:   instantiated from ‘void Eigen::MatrixBase<Derived>::copyCoeff(int, int, const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >, Derived = Eigen::Matrix<float, 4, 1, 0, 4, 1>]’
.../eigen2/Eigen/src/Core/Assign.h:117:   instantiated from ‘static void Eigen::ei_assign_novec_CompleteUnrolling<Derived1, Derived2, Index, Stop>::run(Derived1&, const Derived2&) [with Derived1 = Eigen::Matrix<float, 4, 1, 0, 4, 1>, Derived2 = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >, int Index = 0, int Stop = 4]’
.../eigen2/Eigen/src/Core/Assign.h:233:   instantiated from ‘static void Eigen::ei_assign_impl<Derived1, Derived2, 3, 2>::run(Derived1&, const Derived2&) [with Derived1 = Eigen::Matrix<float, 4, 1, 0, 4, 1>, Derived2 = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >]’
.../eigen2/Eigen/src/Core/Assign.h:407:   instantiated from ‘Derived& Eigen::MatrixBase<Derived>::lazyAssign(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >, Derived = Eigen::Matrix<float, 4, 1, 0, 4, 1>]’
.../eigen2/Eigen/src/Core/Assign.h:422:   instantiated from ‘static Derived& Eigen::ei_assign_selector<Derived, OtherDerived, false, false>::run(Derived&, const OtherDerived&) [with Derived = Eigen::Matrix<float, 4, 1, 0, 4, 1>, OtherDerived = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >]’
.../eigen2/Eigen/src/Core/Matrix.h:532:   instantiated from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::_set_noalias(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >, _Scalar = float, int _Rows = 4, int _Cols = 1, int _Options = 0, int _MaxRows = 4, int _MaxCols = 1]’
.../eigen2/Eigen/src/Core/Matrix.h:410:   instantiated from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseUnaryOp<Eigen::ei_scalar_add_op<float>, Eigen::Matrix<float, 4, 1, 0, 4, 1> >, _Scalar = float, int _Rows = 4, int _Cols = 1, int _Options = 0, int _MaxRows = 4, int _MaxCols = 1]’
test_vector_add.cpp:13:   instantiated from here
../eigen2/Eigen/src/Core/CwiseUnaryOp.h:75: error: using invalid field ‘Eigen::CwiseUnaryOp<UnaryOp, MatrixType>::m_functor’


I don't know if it is a bug or it's not the way it is supposed to be used.

I wish I had found this before 2.0.1 release, but I have been a bit occupied with other things (new job).
Anyway, as soon as I get some free time I'm back to doing the small and simple stuff I can for Eigen.

--
ricard
http://www.ricardmarxer.com
http://www.caligraft.com
#include <Eigen/Core>

// import most common Eigen types 
USING_PART_OF_NAMESPACE_EIGEN

int main(int, char *[])
{
  Vector4f v4(1, 2, 3, 4);

  //float stdev = (v4.cwise() - 2.5).cwise().square().sum();
  //std::cout << "stdev: " << stdev << std::endl;
  
  Vector4f dcremoved = (v4.cwise() - 2.5);
  std::cout << "dcremoved: " << dcremoved << std::endl;
}





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