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

Home » Public Forums » archive » Re: cumulative function?
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 function? [message #12248 is a reply to message #12236] Fri, 24 July 1998 00:00 Go to previous message
wonko is currently offline  wonko
Messages: 22
Registered: March 1997
Junior Member
dschmidt@lanl.gov (David M. Schmidt) wrote:

> Anyone know of a fast (e.g. built-in) way to construct a cumulative
> vector from a given input vector?
>
> The slow way is:
>
> Given A(100)
> C=fltarr(100)
> C(0)=A(0)
> For i=1,99 do C(i)=C(i-1)+A(i)

You could use an index array:

index = indgen( 99 ) + 1
C(0) = A(0)
C(index) = C(index-1) + A(index)

Or the shift function:

C(99) = 0
C = shift( C, 1 ) + A ; or was it -1 ?

Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
[Message index]
 
Read Message
Read Message
Previous Topic: Object Class in Picturesque Albuquerque
Next Topic: Re: Translating IDL Co ordinates

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

Current Time: Fri Oct 10 14:13:36 PDT 2025

Total time taken to generate the page: 0.80021 seconds