[Numpy-discussion] ufunc for sum of squared difference
Jerome.Kieffer at esrf.fr
Mon Nov 14 03:38:09 EST 2016
On Fri, 11 Nov 2016 11:25:58 -0500
Matthew Harrigan <harrigan.matthew at gmail.com> wrote:
> I started a ufunc to compute the sum of square differences here
> It is about 4x faster and uses half the memory compared to
Using *blas* you win already a factor two (maybe more depending on you blas implementation):
% python -m timeit -s "import numpy as np;x=np.linspace(0,1,int(1e7))" "np.sum(np.square(x-2.))"
10 loops, best of 3: 135 msec per loop
% python -m timeit -s "import numpy as np;x=np.linspace(0,1,int(1e7))" "y=x-2.;np.dot(y,y)"
10 loops, best of 3: 70.2 msec per loop
More information about the NumPy-Discussion