Registered Member
|
I'm using Eigen to construct dynamically an optimization problem. To do this I start with empty problem description matrices and iteratively append other matrices using conservativeResize and block operations.
Accordnigly to http://eigen.tuxfamily.org/dox/classEigen_1_1PlainObjectBase.html#ac20f895ce9b73fa7447196855c0d0758 resize always reallocate data with exception of unchanged dimensions. So the proposed method for constructing matrices will reallocate memory each time matrix is appended. Is there a way to do it without reallocation? I.e. allocate enough memory for the initial matrix, so the latter append operations and thus resizing won't lead to reallocation. |
Moderator
|
You can do it manually using either:
1) a preallocated buffer, and a Map object that you remap (see the end of the doc of the Map class to see how to remap: http://eigen.tuxfamily.org/dox-devel/cl ... _1Map.html) 2) a big Matrix, and a Block<> that you dynamically reconstruct (you can use the same placement new to reconstruct the Block object) |
Registered Member
|
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell