How to cycle through matrix blocks?

Posted by luiss on Stack Overflow See other posts from Stack Overflow or by luiss
Published on 2009-10-08T08:08:23Z Indexed on 2010/03/16 1:09 UTC
Read the original article Hit count: 335

Filed under:
|
|

I have some matrix which I want to cycle through blocks, the matrix could be of many different sizes, but I can know the size, is there a way to fast cycle through blocks? i.e: to fast output the indexes of the blocks, suppose a matrix of 4*4 I should have:

Block1: (0,0),(0,1)(1,0)(1,1)
Block2: (0,2),(0,3)(1,2)(1,3)
Block3: (2,0),(2,1)(3,0)(3,1)
Block4: (2,2),(2,3)(3,2)(3,3)
Where the indexes are (row,col).

For blocks I mean a submatrix of size sqrt(matrixSize)* sqrt(matrixSize) where matrix is a matrix of matrixSize*matrixSize. For example a matrix of 4*4 has 4 blocks of 2*2, a 9*9 has 9 blocks of 3*3...

I'm workdeing in C, but I think that the pseudocode is useful also, I only need the loop on the indexes... Thanks

© Stack Overflow or respective owner

Related posts about block

Related posts about matrix