multiple numpy dot products without a loop
问题 Is it possible to compute several dot products without a loop? say you have the following: a = randn(100, 3, 3) b = randn(100, 3, 3) I want to get an array z of shape (100, 3, 3) such that for all i z[i, ...] == dot(a[i, ...], b[i, ...]) in other words, which verifies: for va, vb, vz in izip(a, b, z): assert (vq == dot(va, vb)).all() The straightforward solution would be: z = array([dot(va, vb) for va, vb in zip(a, b)]) which uses an implicit loop (list comprehension + array). Is there a more