[eigen] Maximum size at compile time

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

Hi Eigen developers,

I have used Eigen for a few years now and I am still amazed by this
library. Thanks a lot for it !

In parts of the code where time is critical, I would like to avoid
dynamic allocation. The matrix size is not know at compile time (and
unbounded). However, at run-time, and outside of these critical regions,
it is possible to know the maximum size of most matrices. Thus, it is
possible to dynamically allocate enough memory in non-critical regions
and use only the necessary part of this allocated memory in critical
regions (thus with no reallocation). I know this can be done with class
Map at the cost of a less readable code. I believe this can also be done
with class Matrix itself, without too much effort. I could not find any
record on the topic. I thus have two questions:

- Is my belief (it would not be too hard to add a run-time maximum size
in class Matrix) correct ?
A (naive ?) approach is to add an option like EnableMaxSizeAtRunTime.
When enabled, a member `max_size` would be added to class `Matrix`.
max_size would always be the allocated size. Then reallocation would be
  * when `Matrix::resize` is called and the requested size is larger
than `max_size`
  * when `Matrix::reserve` (a new method) is called.

- Is this of interest for Eigen ?


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