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

Re: Variable stride in array indices



----------
In article <bowman-1805990954070001@bowman.tamu.edu>, bowman@null.edu
(Kenneth P. Bowman) wrote:

> I had a chance to look at my code to see if Liam's suggestion would work,
> and I realized that it won't, because I need to use the variable stride on
> the *left* side of the equal sign, i.e.
>
> IDL> a = LINDGEN(6,6)
> IDL> print, a
>            0           1           2           3           4           5
>            6           7           8           9          10          11
>           12          13          14          15          16          17
>           18          19          20          21          22          23
>           24          25          26          27          28          29
>           30          31          32          33          34          35
> IDL> print, (a[*,2*LINDGEN(3)])[2*LINDGEN(3),*]
>            0           2           4
>           12          14          16
>           24          26          28


What you need to do it then sent the results here as the index for the
array.  ie:

IDL> a[(a[*,2*LINDGEN(3)])[2*LINDGEN(3),*]] = -1

When you do this, the values from above are set to -1
IDL> print,a
          -1           1          -1           3          -1           5
           6           7           8           9          10          11
          -1          13          -1          15          -1          17
          18          19          20          21          22          23
          -1          25          -1          27          -1          29
          30          31          32          33          34          35



David Borland
Software Engineer
Electrical Geodesics, Inc.