question: public static void swapPivot ( double [ ] [ ] source , int diag , double [ ] [ ] s , double [ ] [ ] t ) { int swapRow = diag ; int swapCol = diag ; double maxValue = Math . abs ( source [ diag ] [ diag ] ) ; int rows = source . length ; int cols = source [ 0 ] . length ; double abs = 0 ; double [ ] r = null ; for ( int row = diag ; row < rows ; row ++ ) { r = source [ row ] ; for ( int col = diag ; col < cols ; col ++ ) { abs = Math . abs ( r [ col ] ) ; if ( abs > maxValue ) { maxValue = abs ; swapRow = row ; swapCol = col ; } } } if ( swapRow != diag ) { swapRows ( source , swapRow , diag ) ; swapRows ( t , swapRow , diag ) ; } if ( swapCol != diag ) { swapCols ( source , swapCol , diag ) ; swapCols ( s , swapCol , diag ) ; } }
target:  Swap the matrices so that the largest value is on the pivot