'Reshape the matrix. Total number of elements must remain the same.
Examples
>>> from sympy import Matrix
>>> m = Matrix(2, 3, lambda i, j: 1)
>>> m
Matrix([
[1, 1, 1],
[1, 1, 1]])
>>> m.reshape(1, 6)
Matrix([[1, 1, 1, 1, 1, 1]])
>>> m.reshape(3, 2)
Matrix([
[1, 1],
[1, 1],
[1, 1]])'

def reshape(self, rows, cols):

    if ((self.rows * self.cols) != (rows * cols)):
        raise ValueError(('Invalid    reshape    parameters    %d    %d' % (rows, cols)))
    return self._new(rows, cols, (lambda i, j: self[((i * cols) + j)]))
