public Matrix shuffle ( ) { Matrix result = copy ( ) ; // Conduct Fisher-Yates shuffle Random random = new Random ( ) ; for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = 0 ; j < columns ; j ++ ) { int ii = random . nextInt ( rows - i ) + i ; int jj = random . nextInt ( columns - j ) + j ; double a = result . get ( ii , jj ) ; result . set ( ii , jj , result . get ( i , j ) ) ; result . set ( i , j , a ) ; } } return result ; }
Shuffles this matrix .