comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Cumulative total
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Cumulative total [message #12840 is a reply to message #12828] Fri, 18 September 1998 00:00 Go to previous message
eddie haskell is currently offline  eddie haskell
Messages: 29
Registered: September 1998
Junior Member
> Can anyone suggest a more efficient way to compute the running cumulative
> total of a 1-D array than using FOR loops?

here is the way i do it:

IDL> A = findgen(10)
IDL> N = n_elements(A)
IDL> result = A # (lindgen(N,N) ge transpose(lindgen(N,N)))
IDL> print,result
0.00000
1.00000
3.00000
6.00000
10.0000
15.0000
21.0000
28.0000
36.0000
45.0000

cheers,
eddie

__^__
__^__
( ___ )----------------------------------------------------------- -( ___
)
| / | A. G. Edward Haskell | \
|
| / | Center for Coastal Physical Oceanography | \
|
| / | Old Dominion University, Norfolk VA 23529 | \
|
| / | Voice 757.683.4816 Fax 757.683.5550 | \
|
|___| e-mail haskell*ccpo.odu.edu
|___|
(_____)----------------------------------------------------- -------(_____)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Help with pick menu widget code
Next Topic: Re: Search routines

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 12:32:59 PDT 2025

Total time taken to generate the page: 1.51922 seconds