I have two matrix:
A = [a11 a12 a21 a22] B = [b11 b12 b21 b22]
And I want to multiply all its columns (without loops) in orde
b = np.tile(B, 2) # two copies of B, side by side a = np.tile(A, 2) a = np.hstack((a[:,::2], a[:,1::2])) # change 1,2,1,2 to 1,1,2,2 a * b # done
I expect there is a better way to do the third step, but the above works and is relatively efficient.