[Numpy-discussion] Questions about C API
Russell E Owen
owen at astro.washington.edu
Fri Apr 9 11:49:44 EDT 2004
At 2:32 PM -0400 2004-04-09, Todd Miller wrote:
>On Fri, 2004-04-09 at 13:25, Russell E Owen wrote:
>> I'm trying to write a median function (surely one is there already,
>> but if so I've not found it). The fastest technique seems to involve
>> rearranging the data in place.
>
>You might want to try out numarray.image.median (or
>numarray.image.combine.median for versions < 0.9).
Thanks. Based on the source, it looks like that prefers a stack of
identical images (instead of a single array, though perhaps one could
make that case work).
John Hunter also kindly pointed out MLab (which it turns out is
buried under linear_algebra in numarray:
numarray.linear_algebra.mlab).
I had been working on a fast median instead of one that sorted the
whole array, but after timing mlab's median I can probably get away
with the simple implementation (and skip the C extension).
>> Also, is there any simple sample code running around for handling
>> arrays of any type (e.g. with C++ templates)?
>
>I think Peter Verveer did some code like this in the nd_image package.
>The general idea is to constrain the arrays with type tAny in the high
>level API and then switch off of a->descr->type_num to select type
>specific code.
Thank you very much for the explanation of the high level interface
and the pointer to this sample code.
-- Russell
More information about the NumPy-Discussion
mailing list