(self, rows, cols)
return self._new(rows, cols, smat)
Reshape matrix while retaining original size.

        Examples
        ========

        >>> from sympy.matrices import SparseMatrix
        >>> S = SparseMatrix(4, 2, range(8))
        >>> S.reshape(2, 4)
        Matrix([
        [0, 1, 2, 3],
        [4, 5, 6, 7]])
Reshape matrix while retaining original size.
Reshape matrix while retaining original size .
def reshape(self, rows, cols):
        """Reshape matrix while retaining original size.

        Examples
        ========

        >>> from sympy.matrices import SparseMatrix
        >>> S = SparseMatrix(4, 2, range(8))
        >>> S.reshape(2, 4)
        Matrix([
        [0, 1, 2, 3],
        [4, 5, 6, 7]])

        """
        if len(self) != rows*cols:
            raise ValueError("Invalid reshape parameters %d %d" % (rows, cols))
        smat = {}
        for k, v in self._smat.items():
            i, j = k
            n = i*self.cols + j
            ii, jj = divmod(n, cols)
            smat[(ii, jj)] = self._smat[(i, j)]
        return self._new(rows, cols, smat)
def reshape ( self , rows , cols ) : if len ( self ) != rows * cols : raise ValueError ( "Invalid reshape parameters %d %d" % ( rows , cols ) ) smat = { } for k , v in self . _smat . items ( ) : i , j = k n = i * self . cols + j ii , jj = divmod ( n , cols ) smat [ ( ii , jj ) ] = self . _smat [ ( i , j ) ] return self . _new ( rows , cols , smat )