Get indices where an integer array is non-zero
Array_Type where (Array_Type a)
The where function examines an numeric array a and
returns an integer array giving the indices of a
where the corresponding element of a is non-zero.
Although this function may appear to be simple or even trivial, it
is arguably one of the most important and powerful functions for
manipulating arrays.
Consider the following:
variable X = [0.0:10.0:0.01];
variable A = sin (X);
variable I = where (A < 0.0);
A[I] = cos (X) [I];
Here the variable X has been assigned an array of doubles
whose elements range from 0.0 through 10.0 in
increments of 0.01. The second statement assigns A to
an array whose elements are the sin of the elements of X.
The third statement uses the where function to get the indices of
the elements of A that are less than 0.0. Finally, the
last statement substitutes into A the cos of the
elements of X at the positions of A where the
corresponding sin is less than 0. The end result is
that the elements of A are a mixture of sines and cosines.
- slangrtl
-
_isnull,
_reshape,
_typeof,
acos,
acosh,
array_info,
array_map,
asin,
asinh,
atan,
atanh,
cos,
cosh,
exp,
get_struct_field,
length,
log,
log10,
reshape,
set_struct_field,
sin,
sinh,
sqrt,
tan,
tanh,
transpose,
typeof
|