This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Freezing the size of an Array or Matrix

Tags: None
(comma "," separated)
xaffeine
Registered Member
Posts
24
Karma
0
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?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Check the EIGEN_NO_AUTOMATIC_RESIZING macro: http://eigen.tuxfamily.org/dox/TopicPre ... tives.html
xaffeine
Registered Member
Posts
24
Karma
0
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.
xaffeine
Registered Member
Posts
24
Karma
0
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?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]