[Numpy-discussion] speeding up the following expression
Sat Nov 12 06:43:57 CST 2011
On Sat, Nov 12, 2011 at 3:36 AM, Geoffrey Zhu <firstname.lastname@example.org> wrote:
> I am playing with multiple ways to speed up the following expression
> (it is in the inner loop):
> C[1:(M - 1)]=(a * C[2:] + b * C[1:(M-1)] + c * C[:(M-2)])
> where C is an array of about 200-300 elements, M=len(C), a, b, c are scalars.
> I played with numexpr, but it was way slower than directly using
> numpy. It would be nice if I could create a Mx3 matrix without copying
> memory and so I can use dot() to calculate the whole thing.
> Can anyone help with giving some advices to make this faster?
looks like a np.convolve(C, [a,b,c]) to me except for the boundary conditions.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion