I'm Piotr Trebisz from the GFaI e.V. institute in Berlin. I work as a software developer in the 3D-Data-Processing departement of the institute. We decided to use "Eigen" because we are tired of spending time on writing our own numerical methods and Eigen seems to yield good results in terms of accuracy.
But we also identified a little performance issue: Eigen frees and allocates memory on every matrix resize, on every computation of a matrix decomposition and on every other change of an objects size, and that costs some time. If you only want to solve 1 or just a few equation systems, then it's not a problem. But our programms often have to solve some 100.000 to some 1.000.000 equation systems whose dimensions vary from iteration step to iteration step.
Freeing and allocating bigger matrices, vectors and matrix-decomposition-objects 100.000 to 1.000.000 times has a negative impact on performance. Therefore in our departement and in many other scientific institutions it is regarded as best practice in numerical algorithms to allocate new memory only when the old memory is not big enough. When an object shrinks, the memory is keept and not freed. Our objects have an extra method called "FreeExtra" if one explicitly wants to free unused memory.
With Eigen's map-templates it is possible to manage the memory of matrices and vectors by our own. But it is not possible to do so with all the other objects like JacobiSVD- and HouseholderQR-Decompositions. Therefore we would like to know if you could think about our suggestion and consider such a memory management for future Eigen releases.
In-Place decompositions could partially solve this.
But we need some general decision if we want to allow independent memory allocation from the matrix size, which would also be helpful for matrices growing during run-time.
API-wise this could be done by using special values for the RowsAtCompileTime/ColsAtCompileTime template arguments and provide a reserve() function similar to std::vector
Instead of special Rows/Cols template argument, I'd rather add a new option bit flag enabling the proposed behavior in Matrix<>. This option would then be passed to all members of a given decomposition. I'd accept such a patch.
See https://bitbucket.org/eigen/eigen/pull-request/125/789-memory-allocation-only-when-necessary/diff for a start and current discussions.
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/789.