code: public static void permute(@Nullable int permRowInv[], DMatrixSparseCSC input, @Nullable int permCol[], DMatrixSparseCSC output) {
          if( permRowInv!= null && input.numRows > permRowInv.length )
              throw new IllegalArgumentException("rowInv permutation vector must have at least as many elements as input has columns");
          if( permCol != null && input.numCols > permCol.length )
              throw new IllegalArgumentException("permCol permutation vector must have at least as many elements as input has rows");
  
          output.reshape(input.numRows,input.numCols,input.nz_length);
          output.indicesSorted = false;
          output.nz_length = input.nz_length;
  
          int N = input.numCols;
  
          // traverse through in order for the output columns
          int outputNZ = 0;
          for (int i = 0; i < N; i++) {
              int inputCol = permCol!=null?permCol[i]:i; // column of input to source from
              int inputNZ = input.col_idx[inputCol];
              int total = input.col_idx[inputCol+1]- inputNZ; // total nz in this column
  
              output.col_idx[i+1] = output.col_idx[i] + total;
  
              for (int j = 0; j < total; j++) {
                  int row = input.nz_rows[inputNZ];
                  output.nz_rows[outputNZ] = permRowInv!=null?permRowInv[row]:row;
                  output.nz_values[outputNZ++] = input.nz_values[inputNZ++];
              }
          }
      }
docs: Applies the forward column and inverse row permutation specified by the two vector to the input matrix
  and save the results in the output matrix. output[permRow[j],permCol[i]] = input[j,i]
  @param permRowInv (Input) Inverse row permutation vector. Null is the same as passing in identity.
  @param input (Input) Matrix which is to be permuted
  @param permCol (Input) Column permutation vector. Null is the same as passing in identity.
  @param output (Output) Matrix which has the permutation stored in it.  Is reshaped.