code: public static DMatrixRMaj pivotMatrix(DMatrixRMaj ret, int pivots[], int numPivots, boolean transposed ) {
  
          if( ret == null ) {
              ret = new DMatrixRMaj(numPivots, numPivots);
          } else {
              if( ret.numCols != numPivots || ret.numRows != numPivots )
                  throw new IllegalArgumentException("Unexpected matrix dimension");
              CommonOps_DDRM.fill(ret, 0);
          }
  
          if( transposed ) {
              for( int i = 0; i < numPivots; i++ ) {
                  ret.set(pivots[i],i,1);
              }
          } else {
              for( int i = 0; i < numPivots; i++ ) {
                  ret.set(i,pivots[i],1);
              }
          }
  
          return ret;
      }
docs: <p>
  Creates a pivot matrix that exchanges the rows in a matrix:
  <br>
  A' = P*A<br>
  </p>
  <p>
  For example, if element 0 in 'pivots' is 2 then the first row in A' will be the 3rd row in A.
  </p>
  
  @param ret If null then a new matrix is declared otherwise the results are written to it.  Is modified.
  @param pivots Specifies the new order of rows in a matrix.
  @param numPivots How many elements in pivots are being used.
  @param transposed If the transpose of the matrix is returned.
  @return A pivot matrix.