[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

subscript array question



     I'm using IDL 5.0 and need to be able to use a subscript
array containing duplicate values like this:

array = intarr(5)
subs  = [0,2,4,4]
array[subs] = array[subs] + 1

and have the resulting values for array be:

	1	0	1	0	2

Because of the way IDL manages memory for expression evaluation
and assignments, what happens for the last two elements of the
addition is that the original value of array[4] is used twice,
rather than what I want, which is to use the current value of
array[4] each time.  I.e. IDL gives the resulting values for
array to be:

	1	0	1	0	1

     So is there a way to do what I want without resorting to
a loop?  In my real-world application, I'm using two different
subscript arrays together to index into and update a two-
dimensional table.  Having duplicate pairs of subscripts from
the two subscript arrays is expected to occur very frequently.


                                  Scott Bennett, Comm. ASMELG, CFIAG
                                  Dept. of Atmospheric Sciences
                                  Oregon State University
                                  Corvallis, Oregon 97331
**********************************************************************
* Internet:       sbennett@oce.orst.edu                              *
*--------------------------------------------------------------------*
* "The jury has a right to judge both the law as well as the fact in *
* controversy."--John Jay, First Chief Justice, U.S. Supreme Court   *
* in Georgia vs. Brailsford, 1794                                    *
**********************************************************************