This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Matrix size comparison in EIGEN_STATIC_ASSERT gives warning?

Tags: None
(comma "," separated)
User avatar
emilf
Registered Member
Posts
29
Karma
0
OS
Hi all,

I have tested to use EIGEN_STATIC_ASSERT to check matrices at compile time, and I get the expected behavior, but a warning as well that I do not expect to get.

If I have the code:
Code: Select all
  template <typename MeasurementFunctor,
            typename HType>
  void update(const Eigen::MatrixBase<HType> *H)
  {

    EIGEN_STATIC_ASSERT(HType::ColsAtCompileTime ==
                        MeasurementFunctor::InputType::RowsAtCompileTime,
                        "HType has wrong size");

  /* ... */

I get the warning:
Code: Select all
warning: comparison between ‘enum Eigen::Matrix<float, 1, 2>::<anonymous>’ and ‘enum Eigen::Matrix<float, 2, 1>::<anonymous>’ [-Wenum-compare]
     EIGEN_STATIC_ASSERT(HType::ColsAtCompileTime ==
                         ~~~~~~~~~~~~~~~~~~~~~~~~~^~
                         MeasurementFunctor::InputType::RowsAtCompileTime,

This stems from the enums being of different type so a simple cast should fix it.
But this feel wrong, as comparing the size of matrices should be ok.
Am I missing some practice when comparing the size of matrices at compile time?

Thanks for your time!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Convert them to int:
Code: Select all
EIGEN_STATIC_ASSERT(int(HType::ColsAtCompileTime) ==
                        int(MeasurementFunctor::InputType::RowsAtCompileTime),
                        "HType has wrong size");
User avatar
emilf
Registered Member
Posts
29
Karma
0
OS
Thank you ggael! So a cast is needed, not me using Eigen wrongly so far. :)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]