You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this simple example that doesn't work, I'm not so sure if we are allowed to combine such arguments or not, but then why does it work in a certain order and doesn't on the other.
In [37]: from sympy.physics.quantum import TensorProduct
In [38]: from sympy import Symbol, eye
In [39]: a = Symbol('a',commutative=False)
In [40]: TensorProduct(a,eye(1))
Out[40]: axMatrix([[1]])
/usr/local/lib/python3.5/dist-packages/sympy/physics/quantum/matrixutils.py in matrix_tensor_product(*product)
245 """Compute the matrix tensor product of sympy/numpy/scipy.sparse matrices."""
246 if isinstance(product[0], MatrixBase):
--> 247 return _sympy_tensor_product(*product)
248 elif isinstance(product[0], numpy_ndarray):
249 return _numpy_tensor_product(*product)
/usr/local/lib/python3.5/dist-packages/sympy/physics/quantum/matrixutils.py in _sympy_tensor_product(*matrices)
192 if not all(isinstance(m, MatrixBase) for m in matrices):
193 raise TypeError(
--> 194 'Sequence of Matrices expected, got: %s' % repr(matrices)
195 )
196
TypeError: Sequence of Matrices expected, got: (Matrix([[1]]), a)
In [42]:
The text was updated successfully, but these errors were encountered:
it works if u use from sympy.tensor.functions import TensorProduct
also i'm not sure what you are trying to do but a = Symbol('a',commutative=False)
is interpreted to the best of my knowledge as a number not a matrix so:
x = Symbol('x',commutative=False)
TensorProduct(x,eye(4))
results in:
⎡x 0 0 0⎤
⎢0 x 0 0⎥
⎢0 0 x 0⎥
⎣0 0 0 x⎦
if you want x to be a Matrix as well (like i would suggest snice you are using the tesorproduct) i would recommend to use MatrixSybols
M = MatrixSymbol('M',2,2)
TensorProduct(eye(2), M)
I have this simple example that doesn't work, I'm not so sure if we are allowed to combine such arguments or not, but then why does it work in a certain order and doesn't on the other.
In [37]: from sympy.physics.quantum import TensorProduct
In [38]: from sympy import Symbol, eye
In [39]: a = Symbol('a',commutative=False)
In [40]: TensorProduct(a,eye(1))
Out[40]: axMatrix([[1]])
In [41]: TensorProduct(eye(1),a)
TypeError Traceback (most recent call last)
in ()
----> 1 TensorProduct(eye(1),a)
/usr/local/lib/python3.5/dist-packages/sympy/physics/quantum/tensorproduct.py in new(cls, *args)
120 def new(cls, *args):
121 if isinstance(args[0], (Matrix, numpy_ndarray, scipy_sparse_matrix)):
--> 122 return matrix_tensor_product(*args)
123 c_part, new_args = cls.flatten(sympify(args))
124 c_part = Mul(*c_part)
/usr/local/lib/python3.5/dist-packages/sympy/physics/quantum/matrixutils.py in matrix_tensor_product(*product)
245 """Compute the matrix tensor product of sympy/numpy/scipy.sparse matrices."""
246 if isinstance(product[0], MatrixBase):
--> 247 return _sympy_tensor_product(*product)
248 elif isinstance(product[0], numpy_ndarray):
249 return _numpy_tensor_product(*product)
/usr/local/lib/python3.5/dist-packages/sympy/physics/quantum/matrixutils.py in _sympy_tensor_product(*matrices)
192 if not all(isinstance(m, MatrixBase) for m in matrices):
193 raise TypeError(
--> 194 'Sequence of Matrices expected, got: %s' % repr(matrices)
195 )
196
TypeError: Sequence of Matrices expected, got: (Matrix([[1]]), a)
In [42]:
The text was updated successfully, but these errors were encountered: