# Converting a 4 rank matrix to 2 rank matrix after using tensorproduct

Let's say I have a 2x2 matrix (with symbols) called 'A'. Now, if do

B = sympy.tensorproduct(A,A)
print(sympy.shape(B))


I get,

(2,2,2,2)


which is a 4 rank tensor.

However, what I want back is a 2 rank 4x4 matrix. How can I do that?

I tried reading documentations for sympy and found out about reshape. But it didn't work for me. The one difference I could note was that in the examples the matrices were very simple or only had numbers. While the matrix I am trying has some exponentials of time (a variable/symbol).

• Your question does not say what kind of operation you actually want! Jan 16 at 19:01
• My question is right above the long paragraph part. I can see how people can fail to notice it though. I'll put the main part of the question in bold in a separate line. Maybe that will help. Jan 16 at 19:22
• What I was asking is this: There are many 4x4 matrices one could construct. You are asking what function to call, but you are not saying what mathematical operation you are trying to attempt, and so it is unclear which function would be useful. Jan 18 at 0:20

If I understand correctly, you want numpy.kron.