public static void removeEqualRows ( DenseMatrix64F matrix ) { int rows = matrix . numRows ; if ( rows < 2 ) { return ; } double [ ] d = matrix . data ; int cols = matrix . numCols ; int left = rows - 1 ; int delta = 0 ; for ( int i = 0 ; i < left ; i ++ ) { int j = i ; for ( ; j < left && eq ( d , i , j + 1 , cols ) ; j ++ ) ; if ( i != j ) { int cnt = j - i ; System . arraycopy ( d , cols * j , d , cols * i , cols * ( left - j + 1 ) ) ; left -= cnt ; delta += cnt ; } } if ( eq ( d , 0 , rows - 1 , cols ) ) { delta ++ ; } if ( delta > 0 ) { matrix . reshape ( rows - delta , cols , true ) ; } }
Removes equal subsequent rows and additionally last row if it is equal to first row .