public static void swapPivot(DenseDoubleMatrix2D source,long diag,DenseDoubleMatrix2D s,DenseDoubleMatrix2D t){
  long swapRow=diag;
  long swapCol=diag;
  double maxValue=Math.abs(source.getDouble(diag,diag));
  long rows=source.getRowCount();
  long cols=source.getColumnCount();
  double abs=0;
  for (long row=diag; row < rows; row++) {
    for (long col=diag; col < cols; col++) {
      abs=Math.abs(source.getDouble(row,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);
  }
}

public static void swapPivot ( DenseDoubleMatrix2D source , long diag , DenseDoubleMatrix2D s , DenseDoubleMatrix2D t ) { long swapRow = diag ; long swapCol = diag ; double maxValue = Math . abs ( source . getDouble ( diag , diag ) ) ; long rows = source . getRowCount ( ) ; long cols = source . getColumnCount ( ) ; double abs = 0 ; for ( long row = diag ; row < rows ; row ++ ) { for ( long col = diag ; col < cols ; col ++ ) { abs = Math . abs ( source . getDouble ( row , 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 ) ; } }
swap the matrices so that the largest value is on the pivot
