[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Specification for a new array slicing function
In article <firstname.lastname@example.org>, email@example.com (Stein Vidar
Hagfors Haugan) wrote:
> There are some issues
> that I would like to clear up, though: What exactly does
> the 0:5:2 sequence mean? Does it mean elements 0:5, sampled
> with a stride of 2? Or does it mean 5 elements sampled with
> a stride of 2, starting from 0? Or is it START:STRIDE:COUNT,
> meaning 2 elements, sampled with a stride of 5?
> Just curious.... And I would strongly recommend following
> Fortran conventions, whatever they are....
I have the Numerical Recipies in Fortran 90 book, which has a nice, short
introduction to F90 concepts.
The F90 syntax is a(lower:upper:stride) or as I prefer to think about it
a(from:to:by). It works exactly like a DO (or FOR) loop, which the new
indexing largely replaces. You can have negative strides if upper<lower.
If upper-lower has a different sign than stride, you get a null result.
So in F90
b = a(10:1:-1)
would give a in reverse order. I find thi more appealing that having to
look up the direction parameters in ROTATE.
In IDL this could be
b = a[*:0L:-1]
Still better than F90 because of the * (an the zero-based indexing, of
course :-) ).
Finally, much of F90 was developed to make parallel programming easier. I
would hope that true parallelism is a goal for IDL (rather than just
better ActiveX controls).
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 @