[eigen] operator== (and probably others) for 0-sized Eigen-types

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


Hello,

while playing with Eigen in the context of rather generic template code, I stumbled upon
the following issue when comparing two fixed, zero-sized Vectors for equality:

In file included from /Users/maven/Development/dlr/dx/negev/thirdparty/eigen-3.2.0/Eigen/Dense:1:
In file included from /Users/maven/Development/dlr/dx/negev/thirdparty/eigen-3.2.0/Eigen/Core:344:
/Users/maven/Development/dlr/dx/negev/thirdparty/eigen-3.2.0/Eigen/src/Core/BooleanRedux.h:21:11: error: expression is not an integral constant expression
    col = (UnrollCount-1) / Derived::RowsAtCompileTime,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/maven/Development/dlr/dx/negev/thirdparty/eigen-3.2.0/Eigen/src/Core/BooleanRedux.h:88:22: note: in instantiation of template class 'Eigen::internal::all_unroller<Eigen::CwiseBinaryOp<std::__1::equal_to<double>, const Eigen::Matrix<double, 0, 1, 0, 0, 1>, const Eigen::Matrix<double, 0, 1, 0, 0, 1> >, 0>' requested here
    return internal::all_unroller<Derived, unroll ? int(SizeAtCompileTime) : Dynamic>::run(derived());
                     ^
/Users/maven/Development/dlr/dx/negev/thirdparty/eigen-3.2.0/Eigen/src/Core/MatrixBase.h:294:32: note: in instantiation of member function 'Eigen::DenseBase<Eigen::CwiseBinaryOp<std::__1::equal_to<double>, const Eigen::Matrix<double, 0, 1, 0, 0, 1>, const Eigen::Matrix<double, 0, 1, 0, 0, 1> > >::all' requested here
    { return cwiseEqual(other).all(); }
                               ^
/Users/maven/Development/dlr/dx/negev/thirdparty/gtest-gmock-1.7.0/gtest/gtest.h:18861:16: note: in instantiation of function template specialization 'Eigen::MatrixBase<Eigen::Matrix<double, 0, 1, 0, 0, 1> >::operator==<Eigen::Matrix<double, 0, 1, 0, 0, 1> >' requested here
  if (expected == actual) {
               ^
/Users/maven/Development/dlr/dx/negev/thirdparty/gtest-gmock-1.7.0/gtest/gtest.h:18897:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<DX::FixedArray1D<double, 0>, DX::FixedArray1D<double, 0> >' requested here
    return CmpHelperEQ(expected_expression, actual_expression, expected,
           ^
.../test/DiscreteEquation/NamedSetTest.cpp:133:3: note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<DX::FixedArray1D<double, 0>, DX::FixedArray1D<double, 0> >' requested here
  EXPECT_EQ(arr, ns.Select(typename NS::FormatT()).CopyIntoArray());

(i.e. Eigen::Matrix<double, 1, 0>() == Eigen::Matrix<double, 1, 0>())

Before trying an Eigen::Matrix, I'd simply used std::array, and that works fine even
in the degenerate case with 0 entries.

Is this desired behaviour? Without thinking about it too much (as the compare is done by value)
it maybe should return true in this case...?


Best regards

Daniel Vollmer

--------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
German Aerospace Center
Institute of Aerodynamics and Flow Technology | Lilienthalplatz 7 | 38108 Braunschweig | Germany



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