[Numpy-discussion] vectorization of vectorization

sm lkd thusweare@hotmail....
Thu Aug 19 17:36:08 CDT 2010


With slight modification I got it work (fucnt as before):
 
funct(orders, num.arange(1e6)[:,  num.newaxis], powers).prod(axis = 1)
 
This gives me exactly what I need! Thanks a lot.
 
ps: I don't know how to post my thank you on the discussion list. 
 


Date: Thu, 19 Aug 2010 14:32:42 -0700
From: jsalvati@u.washington.edu
To: numpy-discussion@scipy.org
Subject: Re: [Numpy-discussion] vectorization of vectorization

This seems simple, so perhaps I am missing something, but what about this: 

special.iv(orders[:, newaxis], arange(1e6)[newaxis, : ], powers[:, newaxis]).prod(axis = 2)

This will probably use up a bit slow/memoryintensive, so you probably want to use numexpr to speed it up a bit.


On Thu, Aug 19, 2010 at 2:22 PM, sm lkd <thusweare@hotmail.com> wrote:


Hello,
 
Here's my problem: for each value t of an array (from 0 to 1e6) a smaller array is computed (size between 2-6). To compute the smaller array, I have a function (which can be easily vectorized if necessary) which takes t and an array of powers of t. The return is an array of modified Bessel function values, i.e.:
 
def funct(order, t, power):
   return special.iv(order, t)**power
 
Note that order and power are arrays after this vectorization:
vec_func = sp.vectorization(func)
 
Right this is how it's used:
for i in range(1000000):
   y[i] = vec_func(orders, t, powers).prod()
 
Incredibly slow.
 
Of course, it is desirable to vectorize it it terms of t. I have tried different methods but still cannot make it work. Any suggestions or ointers?
 
Thank you.

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion






_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100819/2a401c06/attachment-0001.html 


More information about the NumPy-Discussion mailing list