Registered Member
|
I have a doubt about the behavior of resize and conservativeResize when the maximum number of rows and cols is fixed at compile time, say Matrix<float, Dynamic, Dynamic, 0, 3, 4>.
I guess that resize(x,y) and conservativeResize(x,y), with x<4 and y<5, only change the number of rows and cols while the 12 floats are unchanged whenever the size is increased or decreased. In particular, is it safe to decrease the size, say (2,3) starting from (3,4) thus bring it back to (3,4) and assume that the values are unchanged? |
Moderator
|
No it's not safe, because if you do so the last column and row will be destroyed. When you resize from 3x4 to 2x3, then the coefficient have to be copied such that they are sequentially stored in memory. Same when you resize from 2x3 to 3x4. For your purpose you should use Block expression:
Block<Matrix<float, Dynamic, Dynamic, 0, 3, 4> > mat23l(mat, 0, 0, 2,3); |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]