469,588 Members | 2,824 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

Wrap Numpy with Cython?

Hi! I'm trying to wrap numpy with Cython and I've tried to use this
guide to manage this: http://wiki.cython.org/WrappingNumpy
However when I send an array to mysum() it gives me the right answer
only when dtype of the array is float, otherwise it gives me random
answers. The problem may be that the array is converted to a C double
which is just as long as float for Numpyarrays and therefore it works
only when the dtype is float. How do I make a Numpywrapper that works
with an arbitrary dtype?

I've also tried to convert a tuple or list with only numbers in it to
a C array with Cython but I've failed. Does anyone have an example of
how to do this?

Thanks!
Martin
Jun 27 '08 #1
1 2035
ma****************@gmail.com wrote:
Hi! I'm trying to wrap numpy with Cython and I've tried to use this
guide to manage this: http://wiki.cython.org/WrappingNumpy
However when I send an array to mysum() it gives me the right answer
only when dtype of the array is float, otherwise it gives me random
answers. The problem may be that the array is converted to a C double
which is just as long as float for Numpyarrays and therefore it works
only when the dtype is float. How do I make a Numpywrapper that works
with an arbitrary dtype?
You will need a Cython function for each dtype and dispatch based on the dtype.

You will want to ask further numpy questions on the numpy mailing list:

http://www.scipy.org/Mailing_Lists

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Gary Wessle | last post: by
2 posts views Thread by Chris Smith | last post: by
2 posts views Thread by danfan1981 | last post: by
5 posts views Thread by David Lees | last post: by
reply views Thread by Stefan Behnel | last post: by
4 posts views Thread by Tommy Grav | last post: by
1 post views Thread by Srijit Kumar Bhadra | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.