I have a set of n vectors stored in the 3 x n matrix z
. I find the outer product using np.einsum
. When I timed it using:
%timeit v=np.einsum('i...,j...->ij...',z,z)
I got the result:
The slowest run took 7.23 times longer than the fastest. This could mean that an
intermediate result is being cached
100000 loops, best of 3: 2.9 μs per loop
What is happening here and can it be avoided? The best 3 is 2.9us, but the slowest maybe more typical.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…