I trying to use sympy TensorProduct to evaluate the tensor product of more than 2 matrices.
The example below works
from sympy.physics.quantum import TensorProduct
from sympy import Matrix
m1 = Matrix([[1,2],[3,4]])
m2 = Matrix([[1,0],[0,1]])
m3 = Matrix([[1,1],[1,1]])
prod = TensorProduct(m1, m2, m3)
My question is if it’s possible to do something like:
matrices = [m1, m2, m3]
prod = TensorProduct(matrices)
I tried define matrices as an array and a tuple but doesn’t work. Didn’t find another function to do this.
>Solution :
You just need to unpack matrices, like this:
matrices = [m1, m2, m3]
prod = TensorProduct(*matrices)
prod