public static void block ( DMatrix1Row A , DMatrix1Row A_tran , final int blockLength ) { for ( int i = 0 ; i < A . numRows ; i += blockLength ) { int blockHeight = Math . min ( blockLength , A . numRows - i ) ; int indexSrc = i * A . numCols ; int indexDst = i ; for ( int j = 0 ; j < A . numCols ; j += blockLength ) { int blockWidth = Math . min ( blockLength , A . numCols - j ) ; // int indexSrc = i*A.numCols + j; // int indexDst = j*A_tran.numCols + i; int indexSrcEnd = indexSrc + blockWidth ; // for( int l = 0; l < blockWidth; l++ , indexSrc++ ) { for ( ; indexSrc < indexSrcEnd ; indexSrc ++ ) { int rowSrc = indexSrc ; int rowDst = indexDst ; int end = rowDst + blockHeight ; // for( int k = 0; k < blockHeight; k++ , rowSrc += A.numCols ) { for ( ; rowDst < end ; rowSrc += A . numCols ) { // faster to write in sequence than to read in sequence A_tran . data [ rowDst ++ ] = A . data [ rowSrc ] ; } indexDst += A_tran . numCols ; } } } }
Performs a transpose across block sub - matrices . Reduces the number of cache misses on larger matrices .