[Numpy-discussion] optimising single value functions for array calculations

Nadav Horesh nadavh at visionsense.com
Mon Dec 1 05:37:25 EST 2008


I does not solve the slowness problem. I think I read on the list about an experimental code for fast vectorization.

  Nadav.


-----הודעה מקורית-----
מאת: numpy-discussion-bounces at scipy.org בשם Emmanuelle Gouillart
נשלח: ב 01-דצמבר-08 12:28
אל: Discussion of Numerical Python
נושא: Re: [Numpy-discussion] optimising single value functions for array calculations
 
Hello Timmie,

numpy.vectorize(myfunc) should do what you want.

Cheers,

Emmanuelle

> Hello,
> I am developing a module which bases its calculations
> on another specialised module.
> My module uses numpy arrays a lot.
> The problem is that the other module I am building
> upon, does not work with (whole) arrays but with
> single values.
> Therefore, I am currently forces to loop over the
> array:
>
> ###
> a = numpy.arange(100)
> b = numpy.arange(100,200)
> for i in range(0,a.size):
>     a[i] = myfunc(a[i])* b[i]
>
> ###
>
> The results come out well. But the problem is that this
> way of calculation is very ineffiecent and takes time.
>
> May anyone give me a hint on how I can improve my
> code without having to modify the package I am
> building upon. I do not want to change it a lot because
> I would always have to run behind the chnages in the
> other package.
>
> To summarise:
> How to I make a calculation function array-aware?
>
> Thanks in advance,
> Timmie
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>


_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 3856 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20081201/a613b63d/attachment.bin>


More information about the NumPy-Discussion mailing list