1
$\begingroup$

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).

$\endgroup$
3
  • $\begingroup$ Your question does not say what kind of operation you actually want! $\endgroup$ Jan 16 at 19:01
  • $\begingroup$ 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. $\endgroup$ Jan 16 at 19:22
  • $\begingroup$ 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. $\endgroup$ Jan 18 at 0:20

1 Answer 1

2
$\begingroup$

If I understand correctly, you want numpy.kron.

$\endgroup$
1
  • 2
    $\begingroup$ Wow. It never occured to me that numpy would work just fine with symbols. I knew about kron but kept looking in sympy. Thanx a lot $\endgroup$ Jan 16 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.