Home »
Public Forums »
archive »
Re: adding up consecutive elements
| Re: adding up consecutive elements [message #3366] |
Thu, 19 January 1995 17:52 |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <3fk5ps$emd@itssrv1.ucsf.edu>, aki@scifi.ucsf.edu (Andreas Kiefer) writes:
> I need to add consecutive elements of an array. total() doesn't do it because it gives me the sum of the hole array or at least the sum over the different rows/columns if the dimension keyword is used.
> I could use a loop like
>
> for i=0,n_elements(array)-1 do sum(i)=sum(i-1)+array(i)
>
> But this is really slow for large arrays.
>
I have asked RSI for a this function in the past.
A simple derivative function in IDL is just
IDL> d = array - shift(array, 1)
What we are asking for is the inverse of this, i.e. a simple integral or running
total.
____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
|
|
|
|
Current Time: Thu Dec 04 21:58:00 PST 2025
Total time taken to generate the page: 0.16110 seconds