I need to multiply the elements of a, let's say, 2x2 matrix, x, with a matrix, y, whose elements are 2x2 matrices. When I use the conventional numpy multiplication it takes the entire matrix, x, and multiples it with each matrix in y. I have been searching the numpy doc. for something that will replicate this:
>>> x = np.array([[1, 0], [0, 1]])
>>> x
array([[1, 0],
[0, 1]])
>>> y = np.ones((2, 2, 2, 2))
>>> y
array([[[[ 1., 1.],
[ 1., 1.]],
[[ 1., 1.],
[ 1., 1.]]],
[[[ 1., 1.],
[ 1., 1.]],
[[ 1., 1.],
[ 1., 1.]]]])
>>> multiply(x,y)
[[[[1, 1],
[1, 1]],
[[0, 0],
[0, 0]]],
[[[0, 0],
[0, 0]],
[[1, 1],
[1, 1]]]]
np.tensordot(x, y, axes=[[0, 1], [0, 1]]), but your question is unclear... what is the expected result?1: just1, or maybe1*1, or maybe1*1 + 0*1, etc..