public static void zero ( DMatrixSparseCSC A , int row0 , int row1 , int col0 , int col1 ) { for ( int col = col1 - 1 ; col >= col0 ; col -- ) { int numRemoved = 0 ; int idx0 = A . col_idx [ col ] , idx1 = A . col_idx [ col + 1 ] ; for ( int i = idx0 ; i < idx1 ; i ++ ) { int row = A . nz_rows [ i ] ; // if sorted a faster technique could be used if ( row >= row0 && row < row1 ) { numRemoved ++ ; } else if ( numRemoved > 0 ) { A . nz_rows [ i - numRemoved ] = row ; A . nz_values [ i - numRemoved ] = A . nz_values [ i ] ; } } if ( numRemoved > 0 ) { // this could be done more intelligently. Each time a column is adjusted all the columns are adjusted // after it. Maybe accumulate the changes in each column and do it in one pass? Need an array to store // those results though for ( int i = idx1 ; i < A . nz_length ; i ++ ) { A . nz_rows [ i - numRemoved ] = A . nz_rows [ i ] ; A . nz_values [ i - numRemoved ] = A . nz_values [ i ] ; } A . nz_length -= numRemoved ; for ( int i = col + 1 ; i <= A . numCols ; i ++ ) { A . col_idx [ i ] -= numRemoved ; } } } }
Zeros an inner rectangle inside the matrix .