[Numpy-discussion] Applying formula to all in an array which hasvalue from previous

Vishal Rana ranavishal at gmail.com
Mon Mar 29 18:54:00 EDT 2010

```Thanks Nadav!

On Mon, Mar 29, 2010 at 4:07 AM, Nadav Horesh <nadavh at visionsense.com>wrote:

> The general guideline:
>
> Suppose the function definition is:
>
> def func(x,y):
>    # x and y are scalars
>    bla bla bla ...
>    return z # a scalar
>
> So,
>
> import numpy as np
>
> vecfun = np.vectorize(func)
>
> vecfun.ufunc.accumulate(array((0,1,2,3,4,5,6,7,8,9))
>
>
>
>
> -----Original Message-----
> From: numpy-discussion-bounces at scipy.org on behalf of Vishal Rana
> Sent: Sun 28-Mar-10 21:19
> To: Discussion of Numerical Python
> Subject: [Numpy-discussion] Applying formula to all in an array which
> hasvalue from previous
>
> Hi,
>
> For a numpy array:
>
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
> I do some calculation with 0, 1... and get a value = 2.5, now use this
> value
> to do the repeat the same calculation with next element for example...
> 2.5, 2 and get a value = 3.1
> 3.1, 3 and get a value = 4.2
> 4.2, 4 and get a value = 5.1
> ....
> ....     and get a value = 8.5
> 8.5, 9 and get a value = 9.8
>
> So I should be getting a new array like array([0, 2.5, 3.1, 4.2, 5.1, .....
> 8.5,9.8])
>
> Is it where numpy or scipy can help?
>
> Thanks
> Vishal
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100329/01c1919a/attachment.html>
```