This forum will soon be archived and you won't be able to interact with it anymore. Please use KDE Discuss instead.

## static assert for single column/row matrices

matthieu.ft
Registered Member
Posts
2
Karma
0

### static assert for single column/row matrices

Thu Mar 26, 2015 5:07 pm
in Core/PlainObjectBase.h, line 654, there is:
Code: Select all
`      EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor)                        && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, (Options&RowMajor)==0)                        && //i skip the other cases so that we focus on the important things                        ,        INVALID_MATRIX_TEMPLATE_PARAMETERS)`

These two EIGEN_IMPLIES make it impossible to use a single column matrix with RowMajor indexation or a single row matrix with ColMajor indexation. Why so?
I know that Matrix(float, 1 , 3, RowMajor) is equivalent to Matrix(float, 1, 3, ColMajor), so I can work with the first one. But why make the second one forbidden?
Is it a mistake or is it for optimization purpose?

Best,
Matthieu

Edit1:
Actually it is really annoying me. I have a templated algorithm, and in this algorithm I use jacobian matrices which sizes are defined by the template parameters. One template parameter is the size N_m of the measure and the other template parameter is the number N_p of parameters that the measure is depending on. The EIGEN_STATIC_ASSERT I'm talking about prevents me to implement one of these two cases: one dimensional measures, or measures that depend on only one parameter. The solution/hack would be to specialize my algorithm for the cases that do not work... but I think it is no good solution.
My proposition is to simply remove these two lines from the assert from eigen code !

Edit2
Looking a bit further, I found that this had already been reported as a bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=416. It seems there is no official solution so far.
In my case I will be using traits, with the number of rows, cols and also the expected layout. This trait will deal with the special cases for me:
Code: Select all
`template<UInt32 NROWS, UInt32 NCOLS,UInt32 MEMORYLAYOUT>class EigenLayout{public:    static const UInt32 ORDER = MEMORYLAYOUT ;};template<UInt32 NCOLS,UInt32 MEMORYLAYOUT>class EigenLayout<1,NCOLS,MEMORYLAYOUT>{public:    static const UInt32 ORDER = Eigen::RowMajor ;};template<UInt32 NROWS,UInt32 MEMORYLAYOUT>class EigenLayout<NROWS,1,MEMORYLAYOUT>{public:    static const UInt32 ORDER = Eigen::ColMajor ;};`

Cheers!
ggael
Moderator
Posts
3447
Karma
19
OS

### Re: static assert for single column/row matrices

Sat Mar 28, 2015 10:21 am
I've cross referenced your post from the bug entry. Feel free to add you in CC of the bug entry if you want to follow/participate the respective discussions.

## Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]