np.dot 3x3 with N 1x3 arrays
Clash Royale CLAN TAG #URR8PPP np.dot 3x3 with N 1x3 arrays I have an ndarray of N 1x3 arrays I'd like to perform dot multiplication with a 3x3 matrix. I can't seem to figure out an efficient way to do this, as all the multi_dot and tensordot, etc methods seem to recursively sum or multiply the results of each operation. I simply want to apply a dot multiply the same way you can apply a scalar. I can do this with a for loop or list comprehension but it is much too slow for my application. N = np.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9], ...]) m = np.asarray([[10, 20, 30], [40, 50, 60], [70, 80, 90]]) I'd like to perform something such as this but without any python loops: np.asarray([np.dot(m, a) for a in N]) so that it simply returns [m * N[0], m * N[1], m * N[2], ...] [m * N[0], m * N[1], m * N[2], ...] What's the most efficient way to do this? And is there a way to do this so that if N is just a single 1x3 matrix, it will just output the same as np.dot(m, N)? ...