![]() Registered Member ![]()
|
I many cases, I need a dynamically-sized array or matrix so that I can initialize it to a correct size that is dynamically determined. After each object is initialized, though, I often want to freeze its size so that it is not accidentally modified. Does Eigen provide a way to freeze or lock the size of a dynamic array or matrix?
|
![]() Moderator ![]()
|
Check the EIGEN_NO_AUTOMATIC_RESIZING macro: http://eigen.tuxfamily.org/dox/TopicPre ... tives.html
|
![]() Registered Member ![]()
|
Interesting, but I think it is different from what I want in 2 ways. It appears to apply to all arrays, whereas I want to protect only designated arrays against resizing. Also, it appears to protect only against "automatic" resizing, whereas I want to also prohibit explicit resizing of size-locked arrays.
|
![]() Moderator ![]()
|
To this end, you might extend the Array class via the EIGEN_ARRAY_PLUGIN mechanism to re-implement resize(...) and add a size-locking mechanism. I don't see the point in having that in Eigen and that would break ABI compatibility.
See http://eigen.tuxfamily.org/dox/TopicCus ... tml#title0. |
![]() Registered Member ![]()
|
Thanks, that page is pretty interesting. Meanwhile, I tried your suggestion of #define EIGEN_NO_AUTOMATIC_RESIZING. I had trouble with the following.
Eigen::ArrayXXf bigBuffer; //... do everything right, and then Eigen::ArrayXf buf = bigBuffer.row(i).segment( startCol, segSize); With, EIGEN_NO_AUTOMATIC_RESIZING, it seems to be unwilling to construct an ArrayXf from the VectorBlock that comes from segment(). I thought EIGEN_NO_AUTOMATIC_RESIZING only applied to assignments. Am I confused? |
![]() Moderator ![]()
|
Indeed, automatic transposition is also disabled with EIGEN_NO_AUTOMATIC_RESIZING. Note that "bigBuffer.row(i).segment( startCol, segSize)" is a 1 x segSize array, while buf is a "? x 1" array. So you either have to use a row array or to explicitly transpose the right hand side.
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]