def _new(cls, *args, **kwargs): rows, cols, flat_list = MatrixBase._handle_creation_inputs(*args, **kwargs) self = object.__new__(cls) self.rows = rows self.cols = cols self._mat = list(flat_list) # create a shallow copy return self
def _new(cls, *args, **kwargs): if len(args) == 1 and isinstance(args[0], ImmutableMatrix): return args[0] rows, cols, flat_list = MatrixBase._handle_creation_inputs( *args, **kwargs) rows = Integer(rows) cols = Integer(cols) mat = Tuple(*flat_list) return Basic.__new__(cls, rows, cols, mat)
def __pow__(self, other): return MatrixBase.__pow__(self, other)
def __truediv__(self, other): return MatrixBase.__truediv__(self, _force_mutable(other))
def __rmul__(self, other): return MatrixBase.__rmul__(self, _force_mutable(other))
def numpy_to_sympy(m, **options): """Convert a numpy matrix to a SymPy matrix.""" return MatrixBase(m)
def scipy_sparse_to_sympy(m, **options): """Convert a scipy.sparse matrix to a SymPy matrix.""" return MatrixBase(m.todense())