[Numpy-discussion] speeding up operations on small vectors
Tue Oct 11 11:11:01 CDT 2011
On Tue, Oct 11, 2011 at 11:57 AM, Christoph Groth <firstname.lastname@example.org> wrote:
> Pauli Virtanen <email@example.com> writes:
>>> Thank you for your suggestion. It doesn't help me however, because
>>> the algorithm I'm _really_ trying to speed up cannot be vectorized
>>> with numpy in the way you vectorized my toy example.
>>> Any other ideas?
>> Reformulate the problem so that it can be vectorized. Without knowing
>> more about the actual algorithm you are trying to implement, it's not
>> easy to give more detailed help.
> My question was about ways to achieve a speedup without modifying the
> algorithm. I was hoping that there is some numpy-like library for
> python which for small arrays achieves a performance at least on par
> with the implementation using tuples. This should be possible
So it's the dot function being called repeatedly on smallish arrays
that's the bottleneck? I've run into this as well. See this thread
. You might gain some speed if you drop it down into Cython, some
examples in that thread. If you're still up against it, you can try
the C code that Fernando posted for fast matrix multiplication (I
haven't yet), or you might be able to do well to use tokyo from Cython
since Wes' has fixed it up .
I'd be very interested to hear if you achieve a great speed-up with
More information about the NumPy-Discussion