question: public static MatrixBlock reshape ( MatrixBlock in , MatrixBlock out , int rows , int cols , boolean rowwise ) throws DMLRuntimeException { int rlen = in . rlen ; int clen = in . clen ; if ( ( ( long ) rlen ) * clen != ( ( long ) rows ) * cols ) throw new DMLRuntimeException ( "Reshape matrix requires consistent numbers of input/output cells (" + rlen + ":" + clen + ", " + rows + ":" + cols + ")." ) ; if ( rlen == rows && clen == cols ) { out . copy ( in ) ; return out ; } out . sparse = MatrixBlock . evalSparseFormatInMemory ( rows , cols , in . nonZeros ) ; out . rlen = rows ; out . clen = cols ; out . nonZeros = in . nonZeros ; if ( ! in . sparse && ! out . sparse ) reshapeDense ( in , out , rows , cols , rowwise ) ; else if ( in . sparse && out . sparse ) reshapeSparse ( in , out , rows , cols , rowwise ) ; else if ( in . sparse ) reshapeSparseToDense ( in , out , rows , cols , rowwise ) ; else reshapeDenseToSparse ( in , out , rows , cols , rowwise ) ; return out ; }
target:  CP reshape operation (single input, single output matrix) 