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

# Re: Variable stride in array indices

• Subject: Re: Variable stride in array indices
• From: bowman(at)null.edu (Kenneth P. Bowman)
• Date: Tue, 18 May 1999 09:54:07 -0500
• Newsgroups: comp.lang.idl-pvwave
• Organization: Texas A&M University
• References: <bowman-0705990718310001@tl6-218-141.tca.net> <3732EFA0.1F6C49C0@ssec.wisc.edu>
• Xref: news.doit.wisc.edu comp.lang.idl-pvwave:14796

```In article <3732EFA0.1F6C49C0@ssec.wisc.edu>, Liam Gumley
<Liam.Gumley@ssec.wisc.edu> wrote:

> Or I can select the columns and rows at the same time:
>
> IDL> print,(a[x,*])[*,x]
>        0       2       4       6       8
>       20      22      24      26      28
>       40      42      44      46      48
>       60      62      64      66      68
>       80      82      84      86      88

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

works fine *extracting* data, but

IDL> (a[*,2*LINDGEN(3)])[2*LINDGEN(3),*] = -1
% Temporary variables are still checked out - cleaning up...
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

fails.

So it is possible to extract values (gather) but not to insert values
(scatter) with a variable stride using this method.

I repeat my call for a simple stride syntax in IDL

a[0:5:2,0:5:2] = -1

Ken

--
Dr. Kenneth P. Bowman, Professor                409-862-4060
Department of Meteorology                       409-862-4466 fax
Texas A&M University                            bowmanATcsrp.tamu.edu
College Station, TX   77843-3150                Replace AT with @

```