|
From: <co...@ph...> - 2006-01-20 17:47:19
|
Fernando Perez <Fer...@co...> writes: > David M. Cooke wrote: > >> I've done a little bit of work along these lines. I have a module I >> call vector3 [*] which has 2- and 3-dimensional immutable vectors, >> using either ints or doubles. It's as fast as I could make it, while >> keeping it all written in Pyrex. I find it very convenient for >> anything vector-related. Konrad Hinsen has something similiar in the >> development version of his ScientificPython package. >> [*] http://arbutus.mcmaster.ca/dmc/software/vector3.html >> Also, I've also done some playing around with a n-dimensional vector >> type (restricted to doubles). My best attempts make it ~4-5x faster >> than numpy (and 2x faster than Numeric) for vectors of dimension 10 >> on simple ops like + and *, 2x faster than numpy for dimension 1000, >> and approaching 1x as you make the vectors larger. Indexing is about >> 3x faster than numpy, and 1.4x faster than Numeric. So that gives I >> think some idea of the maximum speed-up possible. >> I think the speedups mostly come from the utter lack of any >> polymorphism: it handles vectors of doubles only, and only as >> contiguous vectors (no strides). > > This is excellent, thanks for the pointer. I can see uses for vectors > (still 1-d, no strides, etc) with more than 3 elements, and perhaps > fixed-size (no reshaping, no striding) 2-d arrays (matrices), but this > looks like a good starting point. Sandbox material? Well, I'd be pleased to donate vector3 to scipy as a sandbox (although I think it's very useful as a standalone package for others with no need of full scipy. The general vector stuff is still quite rough, and at this point is really only meant as a study on how fast I can make something like that run :-) -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |co...@ph... |