[eigen] Bugs in Mat::Random, reductions

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


Hi all,

Based on the benchmarks and API, Eigen2 looks extremely attractive. But, I am having trouble executing even very simple operations advertised in the tutorial :(

As a first test of Eigen2, I'm porting some least-squares-based pose estimation code to use it. Currently the code uses OpenCV's linear algebra functions, which are very ugly. In the first few lines already I run into trouble. First of all,

Matrix3d P = Matrix3d::Random(); // for testing

gives a mess of compiler errors (attached). The first real work I want to do is calculate the centroid of a set of N points stored in a 3xN matrix. So I try something like:

typedef Matrix<double, 3, Dynamic> Matrix3xN;
Matrix3xN P = Matrix3xN::Constant(3, 10, 1);
Vector3d C = P.rowwise().sum() / P.cols();

but the compiler says:

error: invalid use of incomplete type 'const struct Eigen::PartialRedux<Eigen::Matrix<double, 3, 10000, 0, 3, 10000>, 0>'
/u/mihelich/packages/eigen2/Eigen/src/Core/util/ForwardDeclarations.h:100: error: declaration of 'const struct Eigen::PartialRedux<Eigen::Matrix<double, 3, 10000, 0, 3, 10000>, 0>'

Am I doing something wrong, and if not, surely these sorts of errors should be caught by unit tests? I notice there is a test/ directory, but I am unfamiliar with CMake and do not see instructions for running the tests anywhere. It's a little disconcerting when code more or less straight out of the tutorial doesn't work...

I get these results compiling against both the latest source tarball and the SVN code (r874622), using gcc 4.2.3 with no optimization flags.

Btw, am I right in surmising that Dynamic is defined as 10000? This seems a little odd to me. Why not use 0, -1 or even INT_MAX as a placeholder value? I'm also curious about Eigen2's policy on allocating memory. I don't see a completely explicit statement in the documentation, but I take it that fixed-size matrices are always stack-allocated? I could imagine it being useful to specify the dimensions of a large, dynamically-allocated matrix at compile time; e.g. if you know the inner dimension is a multiple of the level of loop unrolling, you can avoid some unnecessary code.

Cheers,
Patrick
eigen_example.cpp: In function â??int main(int, char**)â??:
eigen_example.cpp:65: error: invalid use of incomplete type â??const struct Eigen::PartialRedux<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 0>â??
/u/mihelich/packages/eigen2/Eigen/src/Core/util/ForwardDeclarations.h:100: error: declaration of â??const struct Eigen::PartialRedux<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 0>â??
mihelich@adt:~/projects/stuff$ g++ -I /u/mihelich/packages/eigen2/ eigen_example.cpp -o eigen_example
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h: In instantiation of â??Eigen::ei_traits<Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> > >â??:
/u/mihelich/packages/eigen2/Eigen/src/Core/MatrixBase.h:61:   instantiated from â??Eigen::MatrixBase<Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> > >â??
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h:64:   instantiated from â??Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >â??
eigen_example.cpp:59:   instantiated from here
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h:47: error: â??IsRepeatableâ?? is not a member of â??Eigen::ei_functor_traits<Eigen::ei_scalar_random_op<double> >â??
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h: In instantiation of â??Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >â??:
eigen_example.cpp:59:   instantiated from here
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h:109: error: â??Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::m_functorâ?? has incomplete type
/u/mihelich/packages/eigen2/Eigen/src/Core/util/ForwardDeclarations.h:83: error: declaration of â??const struct Eigen::ei_scalar_random_op<double>â??
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h: In member function â??const typename Eigen::ei_traits<Eigen::CwiseNullaryOp<NullaryOp, MatrixType> >::Scalar Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::coeff(int, int) const [with NullaryOp = Eigen::ei_scalar_random_op<double>, MatrixType = Eigen::Matrix<double, 3, 3, 0, 3, 3>]â??:
/u/mihelich/packages/eigen2/Eigen/src/Core/Coeffs.h:322:   instantiated from â??void Eigen::MatrixBase<Derived>::copyCoeff(int, int, const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, Derived = Eigen::Matrix<double, 3, 3, 0, 3, 3>]â??
/u/mihelich/packages/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<double, 3, 3, 0, 3, 3>, Derived2 = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, int Index = 0, int Stop = 9]â??
/u/mihelich/packages/eigen2/Eigen/src/Core/Assign.h:233:   instantiated from â??static void Eigen::ei_assign_impl<Derived1, Derived2, 3, 0>::run(Derived1&, const Derived2&) [with Derived1 = Eigen::Matrix<double, 3, 3, 0, 3, 3>, Derived2 = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >]â??
/u/mihelich/packages/eigen2/Eigen/src/Core/Assign.h:405:   instantiated from â??Derived& Eigen::MatrixBase<Derived>::lazyAssign(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, Derived = Eigen::Matrix<double, 3, 3, 0, 3, 3>]â??
/u/mihelich/packages/eigen2/Eigen/src/Core/Assign.h:420:   instantiated from â??static Derived& Eigen::ei_assign_selector<Derived, OtherDerived, false, false>::run(Derived&, const OtherDerived&) [with Derived = Eigen::Matrix<double, 3, 3, 0, 3, 3>, OtherDerived = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >]â??
/u/mihelich/packages/eigen2/Eigen/src/Core/Matrix.h:340:   instantiated from â??Eigen::Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::Matrix(const Eigen::MatrixBase<OtherDerived>&) [with OtherDerived = Eigen::CwiseNullaryOp<Eigen::ei_scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, _Scalar = double, int _Rows = 3, int _Cols = 3, int _StorageOrder = 0, int _MaxRows = 3, int _MaxCols = 3]â??
eigen_example.cpp:59:   instantiated from here
/u/mihelich/packages/eigen2/Eigen/src/Core/CwiseNullaryOp.h:83: error: using invalid field â??Eigen::CwiseNullaryOp<NullaryOp, MatrixType>::m_functorâ??


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