comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: reversing calculation order
items: Re: reversing calculation order

reversing calculation order
type: item
description: 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. Richard Clark rclark@lpl.arizona.edu -- Still working on the other 999 lines.
creator: rclark
date: 1995-04-24T07:00:00-00:00

Re: reversing calculation order
type: item
description: 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 | =================================================
creator: Fergus Gallagher
date: 1995-05-04T07:00:00-00:00

Re: reversing calculation order
type: item
description: Is there an IDLized way to compute the cummulative sum of an array. func=findgen(N) cumm_sum=fltarr(N) for i=0,N-1 do cumm_sum(i)=total(func(0:i)) How can I eliminate the for loop in the above code. thanks ratty -- Ratnakar Amaravadi Software/Hardware Engineer Department of Radiology I.U. School of Medicine (317)274-1843 (w) amaravad@indiana.edu (317)274-4074 (fax) ratty@foyt.indyrad.iupui.edu
creator: amaravad
date: 1995-05-05T07:00:00-00:00