I've been trying to figure out the algorithm behind NumPy's matrix multiplication for complex numbers:
import numpy as np A = np.array([[17.+0.j, -3.+0.j], [-7.+0.j, 1.+0.j]]) B = np.array([[ 60.+0.j, -4.+0.j], [-12.+0.j, 0.+0.j]]) print(A * B) It outputs:
[[1020.+0.j 12.-0.j] [ 84.-0.j 0.+0.j]] The result from a standard matrix multiplication is very different, as you can see by the numbers below, so I'm left wondering what it is exactly that NumPy does:
[[1056.+0.j -68.+0.j] [-432.+0.j 28.+0.j]] I've been trying to reproduce their multiplication algorithm using just for loops but I still haven't found the answer. Any tips?
*is element-wise multiplication, you're probably looking fornumpy.matmul().np.multiply()behind our backs.np.multipy(). Also, please don't remove the tags again.np.multiply(). That’s true, although I believe it’s always the case when it comes to ndarrays. That lead to some confusion with the oldnump.matrixclass, see stackoverflow.com/questions/3890621/… for example.