Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tensor product of multiple matrices

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading