[Numpy-discussion] Correlate with small arrays

Peter Creasey p.e.creasey.00@googlemail....
Wed Mar 19 12:57:39 CDT 2008


I'm trying to do a PDE style calculation with numpy arrays

y = a * x[:-2] + b * x[1:-1] + c * x[2:]

with a,b,c constants. I realise I could use correlate for this, i.e

y = numpy.correlate(x, array((a, b, c)))

however the performance doesn't seem as good (I suspect correlate is
optimised for both arguments being long arrays). Is the first thing I
wrote probably the best? Or is there a better numpy function for this


More information about the Numpy-discussion mailing list