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

Home » Public Forums » archive » reversing calculation order
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: reversing calculation order [message #4105 is a reply to message #4087] Thu, 04 May 1995 00:00 Go to previous messageGo to previous message
Fergus Gallagher is currently offline  Fergus Gallagher
Messages: 41
Registered: January 1995
Member
rclark@phantasos.lpl.arizona.edu (Richard Clark) wrote:
>
> I need to fill in some values for a vector from a recurrence relation.
>
> V(0:N-1) = func(V(1:*)) ;I wish there was a shorthand for (*-1)
>
> Where V(N) is the only value initially defined (Well actually it is
> calculated from an ascending recurrence relation but the values of
> V(0:N-1) from that step are of no further interest. The results of the
> second recurrence are the ones returned.)
>
> I know that ROTATE can be used to reverse the order of the vector for the
> calculation, and then reverse them again to put it back in the right
> order. But is it possible to eliminate these two reverse operations and do
> the calculation in backwards direction? (no FOR loops, too slow!)
>
> The vector is fairly short but this function will get called a lot.
>


Vector elements can be accessed with other vectors, e.g.,

IDL> x = fltarr(n)
IDL> i = n-1-indgen(n)

IDL> y = cumulative_sum(x(i)) ; made-function that is order dependent
IDL> z = y(i) ; reverse it again

As an additional point, any function enclosed in () becomes a vector, so
that the above could have been abbreviated to

IDL> y = (cumulative_sum(x(i)))(i)

Mind you, ROTATE is pretty fast.......

Fergus

=================================================
| Fergus Gallagher |
| Remote Sensing Applications Development Unit |
| British National Space Centre |
| Monks Wood |
| Huntingdon PE17 2LS / UK |
| |
| F.Gallagher@nerc.ac.uk |
| http://uh.nmt.ac.uk/bnsc/fgg.html |
=================================================
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Envi ROI Spectral/Bandmath
Next Topic: Is there an emacs mode??

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

Current Time: Sat Oct 11 15:08:54 PDT 2025

Total time taken to generate the page: 1.60362 seconds