This thread successfully answers how to use numpy to calculate the tensor product of two matrices in Python. However, I want the output to be in a proper matrix format so that further calculations can be performed on it without my manually editing it.
For instance,
I=matrix([[1,0],[0,1]])
print np.tensordot(I, I, axes=0)
Gives the output:
[[[[1 0]
[0 1]]
[[0 0]
[0 0]]]
[[[0 0]
[0 0]]
[[1 0]
[0 1]]]]
I want it in the form:
[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
so that I can perform further operations on it within the program itself.
How do I do this?