[Numpy-discussion] Optimized sum of squares
Sun Oct 18 13:16:34 CDT 2009
Skipper Seabold skrev:
> I'm curious about this as I use ss, which is just np.sum(a*a, axis),
> in statsmodels and didn't much think about it.
> Do the number of loops matter in the timings and is dot always faster
> even without the blas dot?
The thing is that a*a returns a temporary array with the same shape as
a, and then that is passed to np.sum. The BLAS dot product don't need to
allocate and deallocate temporary arrays.
More information about the NumPy-Discussion