ILNumerics - Technical Computing Tools

High Performance Framework for Visualization

and Computing in Industry and Science

 

tgt

Logical Arrays

Logical arrays in ILNumerics are arbitrary sized arrays, whose elements store a single boolean information each. Logicals are created as result of binary comparison operations (<,>,==,!=,>=,...) and unary test functions like any,isnan,isposinf, ...

Some examples of the creation of logical arrays:

The same options exist for handling logicals as for other arrays. Logicals can be used as local variable or returned from functions. However, logicals are mostly useful for the selection of elements and can directly be used on both sides of indexing expressions or as arguments of the Subarray() or SetRange() functions.

An expression A[L], where L is a logical array, is internally interpreted as A[find(L)]. I.e., nonzero elements of L are searched and given to the indexer (or Subarray()/ SetRange()) as column vector of sequential element indices. In order to return all even element values from A:

The scheme generalizes to the n-dimensional case. Logicals can be combined with all other common index specifiers for n-dimensional subarray range definitions. On the left side of assignments, logicals are convenient too:

Learn more: