New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 153 - Make EIGEN2_SUPPORT fully compatible with Eigen2 and tested
Summary: Make EIGEN2_SUPPORT fully compatible with Eigen2 and tested
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.0
Hardware: All All
: --- Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.0
  Show dependency treegraph
 
Reported: 2011-01-14 16:28 UTC by Benoit Jacob
Modified: 2011-02-13 01:37 UTC (History)
3 users (show)



Attachments
eigen2 regression test results (6.83 KB, text/plain)
2011-01-26 23:15 UTC, Tully Foote
no flags Details

Description Benoit Jacob 2011-01-14 16:28:09 UTC
As discussed on the thread: Eigen2 to Eigen3 Migration Path

To do:
 * when EIGEN2_SUPPORT is defined, relax const correctness at least in Map constructors
 * add back all Eigen2 features when EIGEN2_SUPPORT is defined
 * if some Eigen2 feature has an unsolvable conflict with Eigen3, consider options. Could ignore if it's a very minor feature, or add a separate EIGEN2_FULL_SUPPORT_BREAK_EIGEN3 option.
 * import the eigen2 test suite into the eigen3 test suite, though we could drop some variants of tests for lighter compilation.
 * do not aim at ABI compatibility with Eigen2, that's a lost cause (different template parameter default values, different index types). Instead aim at API compatibility so people can just flip a flag and recompile.
Comment 1 Benoit Jacob 2011-01-19 16:18:13 UTC
Imported Eigen2 test suite. enable by defining cmake variable EIGEN_TEST_EIGEN2.

Now need to make that stuff compile...
Comment 2 Benoit Jacob 2011-01-19 17:10:35 UTC
Some core functionality tests (basicstuff, adjoint, linearstructure...) already compile.
Comment 3 Tully Foote 2011-01-25 04:35:30 UTC
I'm trying out the current head from hg to test building against repos.  

I've found that the Eigen3 EIGEN2_SUPPORT version of USING_PART_OF_NAMESPACE_EIGEN is colliding with posix methods when used outside of a namespace as it is in projects like kdl.  

{{{
cd /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/build/src && /usr/lib/ccache/c++   -Dorocos_kdl_EXPORTS -DEIGEN_USE_NEW_STDVECTOR -DEIGEN2_SUPPORT -O3 -DNDEBUG -fPIC -I/home/tfoote/geometry_trunk/geometry/eigen/include     -I/home/tfoote/geometry_trunk/geometry/eigen/include -o CMakeFiles/orocos-kdl.dir/path_circle.cpp.o -c /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/path_circle.cpp
In file included from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/treeiksolvervel_wdls.cpp:10:
/home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/utilities/svd_eigen_HH.hpp:31: error: ‘random’ is already declared in this scope
}}}

replacing 

using Eigen::internal::random;

with 

namspace ei_random = Eigen::internal::random

lets me compile farther. I think this should be done for all the methods in  this macro.
Comment 4 Gael Guennebaud 2011-01-25 08:06:30 UTC
Tully, you are right, and there is no point to export these functions without the ei_ prefix anyway since they don't exist in Eigen2. Doing it right now.
Comment 5 Benoit Jacob 2011-01-25 14:03:34 UTC
fixed.
Comment 6 Tully Foote 2011-01-26 23:14:24 UTC
I'm attaching three more failures from my regression tests.
Comment 7 Tully Foote 2011-01-26 23:15:41 UTC
Created attachment 72 [details]
eigen2 regression test results

Errors from regression test today http://build.willowgarage.com/job/prerelease_unstable_geometry_maverick_amd64/13/consoleText
Comment 8 Benoit Jacob 2011-01-26 23:24:17 UTC
Could you please point me to the failures? This is a very big log.
Comment 9 Benoit Jacob 2011-01-26 23:24:51 UTC
D'oh! sorry. ignore me.
Comment 10 Benoit Jacob 2011-01-26 23:33:02 UTC
Comment on attachment 72 [details]
eigen2 regression test results

>Mined from output of http://build.willowgarage.com/job/prerelease_unstable_geometry_maverick_amd64/13/consoleText
>
>
>ERROR:
>
>[100%] Built target solvertest
>In file included from /home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/Core:345,
>                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/jacobian.hpp:27,
>                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/jntarray.hpp:27,
>                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/frames_io.hpp:82,
>                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/tests/inertiatest.cpp:4:
>/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h: In member function âconst _MatrixType& Eigen::TriangularView<MatrixType, Mode>::nestedExpression() const [with _MatrixType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, unsigned int _Mode = 1u]â:
>/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:696:   instantiated from âvoid Eigen::TriangularBase<Derived>::evalToLazy(Eigen::MatrixBase<OtherDerived>&) const [with DenseDerived = Eigen::Matrix<double, 3, 3, 0, 3, 3>, Derived = Eigen::TriangularView<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, 1u>]â
>/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:95:   instantiated from âtypename Eigen::internal::traits<T>::DenseMatrixType Eigen::TriangularBase<Derived>::toDenseMatrix() const [with Derived = Eigen::TriangularView<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, 1u>]â
>/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/SelfAdjointView.h:193:   instantiated from âEigen::SelfAdjointView<MatrixType, Mode>& Eigen::SelfAdjointView<MatrixType, Mode>::operator=(const Eigen::TriangularView<OtherMatrixType, OtherMode>&) [with OtherMatrixType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, unsigned int OtherMode = 1u, MatrixType = Eigen::Map<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 0, Eigen::Stride<0, 0> >, unsigned int UpLo = 2u]â
>/home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/tests/inertiatest.cpp:139:   instantiated from here
>/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:238: error: invalid initialization of reference of type âconst Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >&â from expression of type âconst Eigen::Matrix<double, 3, 3, 0, 3, 3>â
>
>
>CODE:
>        Fx = m_vForceData[0]; Fy = m_vForceData[1]; Fz = m_vForceData[2];


This one seems bogus to me. The CODE line does not match the compiler output, it can't be the actual error line. The compiler output is about the same exact error that I fixed already, and for which I added your testcase to our unit tests. So I think that something is wrong here. Do you have a stale copy of Eigen somewhere? Is your Eigen working copy clean? `hg diff` should be empty and `hg parent` should point to current revision.

>
>
>ERROR:
>  In file included from /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_cost.h:41,
>                   from /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/src/chomp_cost.cpp:37:
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:148: error: ISO C++ forbids declaration of 'BlockReturnType' with no type
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:148: error: invalid use of '::'
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:148: error: expected ';' before '<' token
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:153: error: ISO C++ forbids declaration of 'BlockReturnType' with no type
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:153: error: invalid use of '::'
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:153: error: expected ';' before '<' token
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:252: error: expected initializer before '<' token
>  /tmp/install_dir/depends_on_overlay/motion_planners/chomp_motion_planner/include/chomp_motion_planner/chomp_trajectory.h:257: error: expected initializer before '<' token
>  make[3]: *** [CMakeFiles/chomp.dir/src/chomp_cost.o] Error 1
>
>
>
>CODE:
>  /**                                                                                                                                                                                                   
>   * \brief Gets the block of the trajectory which can be optimized                                                                                                                                     
>   */
>  Eigen::BlockReturnType<Eigen::MatrixXd>::Type getFreeTrajectoryBlock();

This code is using internal eigen2 stuff. Eigen2 was not very good at making it clear that stuff is internal. If you really want, I can add this to eigen2support. But I'd rather recommend that you rewrite this as:

   Eigen::Block<Eigen::MatrixXd, Eigen::Dynamic, Eigen::Dynamic> getFreeTrajectoryBlock();

Which will work on both eigen2 and eigen3.

>
>
>ERROR:
>/tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp: In member function 'void articulation_models::PCAGPModel::buildGPs()':
>  /tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp:181: error: wrong number of template arguments (1, should be 3)
>  /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Core/util/ForwardDeclarations.h:101: error: provided for 'template<class _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime> class Eigen::DiagonalMatrix'
>  /tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp:181: error: invalid type in declaration before '(' token
>  /tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp:181: error: cannot convert 'const Eigen::VectorXf' to 'int' in initialization
>  In file included from /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/SVD:30,
>                   from /tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp:15:
>  /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Eigen2Support/SVD.h: In member function 'bool Eigen::SVD<MatrixType>::solve(const Eigen::MatrixBase<OtherDerived>&, ResultType*) const [with OtherDerived = Eigen::Matrix<float, -0x00000000000000001, 1, 0, -0x00000000000000001, 1>, ResultType = Eigen::VectorXf, MatrixType = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]':
>  /tmp/install_dir/depends_on_overlay/articulation/articulation_models/src/models/pca_gp_model.cpp:175:   instantiated from here
>  /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Eigen2Support/SVD.h:528: warning: unused variable 'rows'
>  make[3]: *** [CMakeFiles/articulation_models.dir/src/models/pca_gp_model.o] Error 1
>
>CODE:
>        DiagonalMatrix<Eigen::VectorXf> S2(S);
>

Here, we have a plain API conflict between eigen2 and eigen3, however one could also argue that this code was using quite internal stuff (DiagonalMatrix was only meant to be the return type of asDiagonal() in eigen2).

Would you be OK to fix that on your side by rewriting this as

        DiagonalWrapper<Eigen::VectorXf> S2(S);

or do you want me to handle this in eigen2support?
Comment 11 Tully Foote 2011-01-26 23:48:24 UTC
(In reply to comment #10)
> Comment on attachment 72 [details]
> eigen2 regression test results
> 
> >Mined from output of http://build.willowgarage.com/job/prerelease_unstable_geometry_maverick_amd64/13/consoleText
> >
> >
> >ERROR:
> >
> >[100%] Built target solvertest
> >In file included from /home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/Core:345,
> >                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/jacobian.hpp:27,
> >                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/jntarray.hpp:27,
> >                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/src/frames_io.hpp:82,
> >                 from /home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/tests/inertiatest.cpp:4:
> >/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h: In member function âconst _MatrixType& Eigen::TriangularView<MatrixType, Mode>::nestedExpression() const [with _MatrixType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, unsigned int _Mode = 1u]â:
> >/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:696:   instantiated from âvoid Eigen::TriangularBase<Derived>::evalToLazy(Eigen::MatrixBase<OtherDerived>&) const [with DenseDerived = Eigen::Matrix<double, 3, 3, 0, 3, 3>, Derived = Eigen::TriangularView<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, 1u>]â
> >/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:95:   instantiated from âtypename Eigen::internal::traits<T>::DenseMatrixType Eigen::TriangularBase<Derived>::toDenseMatrix() const [with Derived = Eigen::TriangularView<Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, 1u>]â
> >/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/SelfAdjointView.h:193:   instantiated from âEigen::SelfAdjointView<MatrixType, Mode>& Eigen::SelfAdjointView<MatrixType, Mode>::operator=(const Eigen::TriangularView<OtherMatrixType, OtherMode>&) [with OtherMatrixType = Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >, unsigned int OtherMode = 1u, MatrixType = Eigen::Map<Eigen::Matrix<double, 3, 3, 0, 3, 3>, 0, Eigen::Stride<0, 0> >, unsigned int UpLo = 2u]â
> >/home/tfoote/geometry_trunk/geometry/kdl/build/kdl-tar/tests/inertiatest.cpp:139:   instantiated from here
> >/home/tfoote/geometry_trunk/geometry/eigen/include/Eigen/src/Core/TriangularMatrix.h:238: error: invalid initialization of reference of type âconst Eigen::CwiseNullaryOp<Eigen::internal::scalar_random_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> >&â from expression of type âconst Eigen::Matrix<double, 3, 3, 0, 3, 3>â
> >
> >
> >CODE:
> >        Fx = m_vForceData[0]; Fy = m_vForceData[1]; Fz = m_vForceData[2];
> 
> 
> This one seems bogus to me. The CODE line does not match the compiler output,
> it can't be the actual error line. The compiler output is about the same exact
> error that I fixed already, and for which I added your testcase to our unit
> tests. So I think that something is wrong here. Do you have a stale copy of
> Eigen somewhere? Is your Eigen working copy clean? `hg diff` should be empty
> and `hg parent` should point to current revision.

Sorry cut and paste mistake proper error below:

  In file included from /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/Core:298,
                   from /tmp/install_dir/depends_on_overlay/cob_driver/cob_forcetorque/common/include/cob_forcetorque/ForceTorqueCtrl.h:8,
                   from /tmp/install_dir/depends_on_overlay/cob_driver/cob_forcetorque/common/src/ForceTorqueCtrl.cpp:1:
  /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Core/DenseCoeffsBase.h: In member function 'typename Eigen::internal::traits<T>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::operator[](typename Eigen::internal::traits<T>::Index) [with Derived = Eigen::Matrix<float, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]':
  /tmp/install_dir/depends_on_overlay/cob_driver/cob_forcetorque/common/src/ForceTorqueCtrl.cpp:306:   instantiated from here
  /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Core/DenseCoeffsBase.h:382: error: 'THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD' is not a member of 'Eigen::internal::static_assertion<false>'
  make[3]: *** [CMakeFiles/cob_forcetorque.dir/common/src/ForceTorqueCtrl.o] Error 1

For the other ones I will push back on them to use the agnostic API and port forward the other one from the internal API.
Comment 12 Benoit Jacob 2011-01-27 02:20:44 UTC
> /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Core/DenseCoeffsBase.h:
> In member function 'typename Eigen::internal::traits<T>::Scalar&
> Eigen::DenseCoeffsBase<Derived, 1>::operator[](typename
> Eigen::internal::traits<T>::Index) [with Derived = Eigen::Matrix<float,
> -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001,
> -0x00000000000000001>]':
>  
> /tmp/install_dir/depends_on_overlay/cob_driver/cob_forcetorque/common/src/ForceTorqueCtrl.cpp:306:
>   instantiated from here
>  
> /tmp/install_dir/stack_overlay/geometry/eigen/include/Eigen/src/Core/DenseCoeffsBase.h:382:
> error:
> 'THE_BRACKET_OPERATOR_IS_ONLY_FOR_VECTORS__USE_THE_PARENTHESIS_OPERATOR_INSTEAD'
> is not a member of 'Eigen::internal::static_assertion<false>'
>   make[3]: *** [CMakeFiles/cob_forcetorque.dir/common/src/ForceTorqueCtrl.o]
> Error 1

OK, this one is easy. Here you have a MatrixXf and are trying to call operator[] on it, like this:

    MatrixXf m;
    ...
    float x = m[i];

We allowed this in Eigen2, but in Eigen3 we restricted operator[] to vectors because it's incredibly bug prone on matrices (when the c++ compiler sees  m[i,j], it evaluates the comma operator first!) but for Eigen2Support it's easy to re-enable it, give me a minute.
Comment 13 Benoit Jacob 2011-01-27 02:24:29 UTC
Done. operator[] on matrices is now allowed in EIGEN2_SUPPORT. Let me know how it compiles now!

Note that the proper Eigen3 port of this is trivial, just replace [] by (). This also works in Eigen2.

The meaning of matrix(index) is: the index-th coefficient in the matrix's native storage order.

Note You need to log in before you can comment on or make changes to this bug.