[SciPy-User] fast small matrix multiplication with cython?
Charles R Harris
Tue Dec 7 08:54:39 CST 2010
On Mon, Dec 6, 2010 at 11:56 PM, Fernando Perez <email@example.com>wrote:
> Hi Skipper,
> On Mon, Dec 6, 2010 at 2:34 PM, Skipper Seabold <firstname.lastname@example.org>
> > I'm wondering if anyone might have a look at my cython code that does
> > matrix multiplication and see where I can speed it up or offer some
> > pointers/reading. I'm new to Cython and my knowledge of C is pretty
> > basic based on trial and (mostly) error, so I am sure the code is
> > still very naive.
> a few years ago I had a similar problem, and I ended up getting a very
> significant speedup by hand-coding a very unsafe, but very fast pure C
> extension just to compute these inner products. This was basically a
> replacement for dot() that would only work with double precision
> inputs of compatible dimensions and would happily segfault with
> anything else, but it ran very fast. The inner loop is implemented
> completely naively, but it still beats calls to BLAS (even linked with
> ATLAS) for small matrix dimensions (my case was also up to ~ 15x15).
> I'm attaching the code in case you find it useful, please keep in mind
> I haven't compiled it in years, so it may have bit-rotted a little.
Blas adds quite a bit of overhead for multiplying small matrices, but so
does calling from python. For implementing Kalman filters it might be better
to write a whole Kalman class so that operations can be combined at the c
Skipper, what kind of Kalman filter are you trying to implement?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User