Question about creating a 3-rank tensor in numpy with python3

196 Views Asked by At

I'm trying to create a 3-rank tensor in numpy, with python3.x.

I need to create this 3-rank tensor A in a very particular way. If I have 3 matrices, let's say that all of them are some $Y$ matrix (which is dimensionally $4x4$), then it must be of the following mathematical form:

$A((in),(jk),(lm))$ from some type of multiplication roughly like: $"Y_{4}(i,j) \otimes Y_{4}(k,l) \otimes Y_{4}(m,n)"$. So, in a sense, I must connect the "input" of a matrix to the "output" of another identical matrix, for three identical matrices.

The final 3-rank tensor $A$ should have dimensions 16x16x16.

Mathematically, I'm not sure if this corresponds to a tensor product or a kronecker product. Obviously this makes a big difference, as in numpy for python, the functions numpy.kron() and numpy.tensordot() have different meanings.

I'd appreciate any help on this problem. I understand that this question may not exactly fit into the mathematics stack exchange, but I didn't know where else to ask, since this question deals with both mathematical and computational aspects.

So, just to clarify, my questions are:

  1. What is the difference between a tensor product and a kronecker product?
  2. How would I then create the above object? Would it require a tensor product or a kronecker product, or some combination of both?