Registered Member
|
Is it possible somehow to copy a block of an array
to another array at the specific location? Let's say, I have extracted a block of size 2x2 from one array and want to insert it into another array of size 4x4 but only at the beginning of this array that element (0,0), (0,1), (1,0) and (1,1) would be replaced by the block elements. |
Moderator
|
Yes, block expression are read-write, so, in your case:
B.block(0,0,2,2) = A.block(i,j,2,2); or: B.topLeftCorner(2,2) = A.block(,i,j,2,2); or even: B.topLeftCorner<2,2>() = A.block<2,2>(i,j); The later version takes advantage that the block is 2x2 at compile-time. |
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft