code: public static void extract( DMatrixRMaj src,
                                  int rows[] , int rowsSize ,
                                  int cols[] , int colsSize , DMatrixRMaj dst ) {
          if( rowsSize != dst.numRows || colsSize != dst.numCols )
              throw new MatrixDimensionException("Unexpected number of rows and/or columns in dst matrix");
  
          int indexDst = 0;
          for (int i = 0; i < rowsSize; i++) {
              int indexSrcRow = src.numCols*rows[i];
              for (int j = 0; j < colsSize; j++) {
                  dst.data[indexDst++] = src.data[indexSrcRow + cols[j]];
              }
          }
      }
docs: Extracts out a matrix from source given a sub matrix with arbitrary rows and columns specified in
  two array lists
  
  @param src Source matrix. Not modified.
  @param rows array of row indexes
  @param rowsSize maximum element in row array
  @param cols array of column indexes
  @param colsSize maximum element in column array
  @param dst output matrix.  Must be correct shape.