[Numpy-discussion] Correlate with small arrays

Peter Creasey p.e.creasey.00 at googlemail.com
Wed Mar 19 13:57:39 EDT 2008


Hi,

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
case?

Regards,
Peter



More information about the NumPy-Discussion mailing list