Skip to content

Replace static const int rows/cols by integral_constants

Simon Praetorius requested to merge issue/fieldmatrix-rows-cols into master

Summary

This MR is an attempt to fix the issue that FieldMatrix::rows and FieldMatrix::cols are static constexpr int and not constexpr functions as in the base class DenseMatrix and thus also in the other matrix class DynamicMatrix. This makes generic code that accepts both, a DenseMatrix and a FieldMatrix more complicated to use. One is forced to go to the "horribly" named N() and M() methods. Within FieldMatrix we are sometimes forced to even use the mat_rows() and mat_cols() method that is actually just an implementation detail of the DenseMatrix interface class.

The proposed solution is to replace the static constexpr int by a static constexpr std::integral_constant<int,...>. The latter converts implicitly to int and has a call-operator, thus can be used like a function. Thus should thus not make the interface worse, but adds a function syntax to the rows and cols static members of FieldMatrix. The documentation of these functions is actually already provided in the DenseMatrix base class.

Edited by Simon Praetorius

Merge request reports