Пример #1
0
 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
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 def __pow__(self, other):
     return MatrixBase.__pow__(self, other)
Пример #5
0
 def __truediv__(self, other):
     return MatrixBase.__truediv__(self, _force_mutable(other))
Пример #6
0
 def __rmul__(self, other):
     return MatrixBase.__rmul__(self, _force_mutable(other))
Пример #7
0
 def __pow__(self, other):
     return MatrixBase.__pow__(self, other)
Пример #8
0
 def __truediv__(self, other):
     return MatrixBase.__truediv__(self, _force_mutable(other))
Пример #9
0
 def __rmul__(self, other):
     return MatrixBase.__rmul__(self, _force_mutable(other))
Пример #10
0
def numpy_to_sympy(m, **options):
    """Convert a numpy matrix to a SymPy matrix."""
    return MatrixBase(m)
Пример #11
0
def scipy_sparse_to_sympy(m, **options):
    """Convert a scipy.sparse matrix to a SymPy matrix."""
    return MatrixBase(m.todense())