Skip to content

Make DenseStorage cols() static EIGEN_CONSTEXPR for columns / rows of fixed size?

I was looking at the code for fixed column sizes for matrices in DenseStorage.h and noticed that cols() returns back the input template value _Cols

EIGEN_DEVICE_FUNC Index cols(void) const {return _Cols;}

Can this be made as

static EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR cols(void) {return _Cols;}

I think that could be nice since then for things like when you have to iterate over arbitrary matrices like

for (Eigen::Index j = 0; j < x.cols(); ++j) {
  for (Eigen::Index i = 0; i < x.rows(); ++i) {
     // yada yada
  }
}

The compiler would know that the outer loop just goes over 0