ArrayLogical.h

Classes

Global Functions -- Logical operations for Arrays. (full description)

Logical operations for Arrays. (source)

Interface

Bool allLE (const Array<T> &l, const Array<T> &r)
Bool allLT (const Array<T> &l, const Array<T> &r)
Bool allGE (const Array<T> &l, const Array<T> &r)
Bool allGT (const Array<T> &l, const Array<T> &r)
Bool allEQ (const Array<T> &l, const Array<T> &r)
Bool allNE (const Array<T> &l, const Array<T> &r)
Bool allNear (const Array<T> &l, const Array<T> &r, Double tol)
Bool allNearAbs (const Array<T> &l, const Array<T> &r, Double tol)
Bool allAND (const Array<T> &l, const Array<T> &r)
Bool allOR (const Array<T> &l, const Array<T> &r)
LogicalArray operator <= (const Array<T> &l, const Array<T> &r)
LogicalArray operator < (const Array<T> &l, const Array<T> &r)
LogicalArray operator >= (const Array<T> &l, const Array<T> &r)
LogicalArray operator > (const Array<T> &l, const Array<T> &r)
LogicalArray operator == (const Array<T> &l, const Array<T> &r)
LogicalArray operator != (const Array<T> &l, const Array<T> &r)
VECLOG_LA_OP_AA ( <=, Vector )VECLOG_LA_OP_AA ( <, Vector )VECLOG_LA_OP_AA ( >=, Vector )VECLOG_LA_OP_AA ( >, Vector )VECLOG_LA_OP_AA ( ==, Vector )VECLOG_LA_OP_AA ( !=, Vector )VECLOG_LA_OP_AA ( &&, Vector )VECLOG_LA_OP_AA ( ||, Vector )
VECLOG_LA_OP_AA ( <=, Matrix )VECLOG_LA_OP_AA ( <, Matrix )VECLOG_LA_OP_AA ( >=, Matrix )VECLOG_LA_OP_AA ( >, Matrix )VECLOG_LA_OP_AA ( ==, Matrix )VECLOG_LA_OP_AA ( !=, Matrix )VECLOG_LA_OP_AA ( &&, Matrix )VECLOG_LA_OP_AA ( ||, Matrix )
VECLOG_LA_OP_AA ( <=, Cube )VECLOG_LA_OP_AA ( <, Cube )VECLOG_LA_OP_AA ( >=, Cube )VECLOG_LA_OP_AA ( >, Cube )VECLOG_LA_OP_AA ( ==, Cube )VECLOG_LA_OP_AA ( !=, Cube )VECLOG_LA_OP_AA ( &&, Cube )VECLOG_LA_OP_AA ( ||, Cube )
LogicalArray near(const Array<T> &l, const Array<T> &r, Double tol)
LogicalArray nearAbs(const Array<T> &l, const Array<T> &r, Double tol)
LogicalArray operator && (const Array<T> &l, const Array<T> &r)
LogicalArray operator || (const Array<T> &l, const Array<T> &r)
LogicalArray operator ! (const Array<T> &l)
Bool allLE (const Array<T> &array, const T &val)
Bool allLE (const T &val, const Array<T> &array)
Bool allLT (const Array<T> &array, const T &val)
Bool allLT (const T &val, const Array<T> &array)
Bool allGE (const Array<T> &array, const T &val)
Bool allGE (const T &val, const Array<T> &array)
Bool allGT (const Array<T> &array, const T &val)
Bool allGT (const T &val, const Array<T> &array)
Bool allEQ (const Array<T> &array, const T &val)
Bool allEQ (const T &val, const Array<T> &array)
Bool allNE (const Array<T> &array, const T &val)
Bool allNE (const T &val, const Array<T> &array)
Bool allNear (const Array<T> &array, const T &val, Double tol)
Bool allNear (const T &val, const Array<T> &array, Double tol)
Bool allNearAbs (const Array<T> &array, const T &val, Double tol)
Bool allNearAbs (const T &val, const Array<T> &array, Double tol)
Bool allAND (const Array<T> &array, const T &val)
Bool allAND (const T &val, const Array<T> &array)
Bool allOR (const Array<T> &array, const T &val)
Bool allOR (const T &val, const Array<T> &array)
LogicalArray operator <= (const Array<T> &array, const T &val)
LogicalArray operator <= (const T &val, const T<T> &array)
LogicalArray operator < (const Array<T> &array, const T &val)
LogicalArray operator < (const T &val, const T<T> &array)
LogicalArray operator >= (const Array<T> &array, const T &val)
LogicalArray operator >= (const T &val, const T<T> &array)
LogicalArray operator > (const Array<T> &array, const T &val)
LogicalArray operator > (const T &val, const T<T> &array)
LogicalArray operator == (const Array<T> &array, const T &val)
LogicalArray operator == (const T &val, const T<T> &array)
LogicalArray operator != (const Array<T> &array, const T &val)
LogicalArray operator != (const T &val, const T<T> &array)
LogicalArray near (const Array<T> &array, const T &val, Double tol)
LogicalArray near (const T &val, const T<T> &array, Double tol)
LogicalArray nearAbs (const Array<T> &array, const T &val, Double tol)
LogicalArray nearAbs (const T &val, const T<T> &array, Double tol)
LogicalArray operator && (const Array<T> &array, const T &val)
LogicalArray operator && (const T &val, const T<T> &array)
LogicalArray operator || (const Array<T> &array, const T &val)
LogicalArray operator || (const T &val, const T<T> &array)
Bool anyLE (const Array<T> &l, const Array<T> &r)
Bool anyLT (const Array<T> &l, const Array<T> &r)
Bool anyGE (const Array<T> &l, const Array<T> &r)
Bool anyGT (const Array<T> &l, const Array<T> &r)
Bool anyEQ (const Array<T> &l, const Array<T> &r)
Bool anyNE (const Array<T> &l, const Array<T> &r)
Bool anyNear (const Array<T> &l, const Array<T> &r, Double tol)
Bool anyNearAbs (const Array<T> &l, const Array<T> &r, Double tol)
Bool anyAND (const Array<T> &l, const Array<T> &r)
Bool anyOR (const Array<T> &l, const Array<T> &r)
Bool anyLE (const Array<T> &array, const T &val)
Bool anyLE (const T &val, const Array<T> &array)
Bool anyLT (const Array<T> &array, const T &val)
Bool anyLT (const T &val, const Array<T> &array)
Bool anyGE (const Array<T> &array, const T &val)
Bool anyGE (const T &val, const Array<T> &array)
Bool anyGT (const Array<T> &array, const T &val)
Bool anyGT (const T &val, const Array<T> &array)
Bool anyEQ (const Array<T> &array, const T &val)
Bool anyEQ (const T &val, const Array<T> &array)
Bool anyNE (const Array<T> &array, const T &val)
Bool anyNE (const T &val, const Array<T> &array)
Bool anyNear (const Array<T> &array, const T &val, Double tol)
Bool anyNear (const T &val, const Array<T> &array, Double tol)
Bool anyNearAbs (const Array<T> &array, const T &val, Double tol)
Bool anyNearAbs (const T &val, const Array<T> &array, Double tol)
Bool anyAND (const Array<T> &array, const T &val)
Bool anyAND (const T &val, const Array<T> &array)
Bool anyOR (const Array<T> &array, const T &val)
Bool anyOR (const T &val, const Array<T> &array)
uInt ntrue (const Array<T> &array)
uInt nfalse (const Array<T> &array)
Array<uInt> partialNTrue (const Array<T>& array, const IPosition& collapseAxes)
Array<uInt> partialNFalse (const Array<T>& array, const IPosition& collapseAxes)

Description

Review Status

Programs:
Tests:

Prerequisite

Etymology

This file contains global functions which perform element by element logical operations on arrays.

Synopsis

These functions perform element by element logical operations on arrays. The two arrays must conform, except for allEQ which returns False if the arrays do not conform.

There are two classes of functions. One class returns a LogicalArray. In these functions, the value of an element of the LogicalArray is the value of the logical operation applied to the corresponding elements of the input Arrays. The other class of functions returns a single Bool. The return value is True if the logical operation returns True for all elements of the input arrays for the "all" functions (e.g. allLE()), and returns True if the logical operation returns True for any elements of the input arrays for the "any" functions (e.g. anyLE()).

For instance allLE (a, b) implies that every element of a is less than or equal to every element of b. Note that with this definition allLE (a, b) and allGE (a, b) can both be false (e.g. a = [1,0] b = [0,1]).

Caution Comparison between two zero-sized arrays is not defined (should it throw an exception?).

Example

   Vector<Int> a(10);
   Vector<Int> b(10);
   LogicalVector l(10);
      . . .
   l = a < b;
This example sets the elements of l (a

Example

   Vector<Int> a(10);
   Vector<Int> b(10);
   Bool result;
      . . .
   result = allLT (a, b);
This example sets result to True if, for all elements, a

Motivation

One wants to be able to perform logical operations on arrays.

To Do

Member Description

Bool allLE (const Array<T> &l, const Array<T> &r)
Bool allLT (const Array<T> &l, const Array<T> &r)
Bool allGE (const Array<T> &l, const Array<T> &r)
Bool allGT (const Array<T> &l, const Array<T> &r)
Bool allEQ (const Array<T> &l, const Array<T> &r)
Bool allNE (const Array<T> &l, const Array<T> &r)
Bool allNear (const Array<T> &l, const Array<T> &r, Double tol)
Bool allNearAbs (const Array<T> &l, const Array<T> &r, Double tol)

Element by element comparisons between the "l" and "r" arrays. The result is true only if the comparison is true for every element of the arrays.

The operator forms of array logical operations which return a single Bool have been replaced by these "all" functions. The operator forms of array logical operations now return a LogicalArray.

The arrays must conform except for allEQ, which will return False if the arrays have different shapes.

Thrown Exceptions

Bool allAND (const Array<T> &l, const Array<T> &r)
Bool allOR (const Array<T> &l, const Array<T> &r)

This only makes sense if the array element type is logical valued.

LogicalArray operator <= (const Array<T> &l, const Array<T> &r)
LogicalArray operator < (const Array<T> &l, const Array<T> &r)
LogicalArray operator >= (const Array<T> &l, const Array<T> &r)
LogicalArray operator > (const Array<T> &l, const Array<T> &r)
LogicalArray operator == (const Array<T> &l, const Array<T> &r)
LogicalArray operator != (const Array<T> &l, const Array<T> &r)
VECLOG_LA_OP_AA ( <=, Vector )VECLOG_LA_OP_AA ( <, Vector )VECLOG_LA_OP_AA ( >=, Vector )VECLOG_LA_OP_AA ( >, Vector )VECLOG_LA_OP_AA ( ==, Vector )VECLOG_LA_OP_AA ( !=, Vector )VECLOG_LA_OP_AA ( &&, Vector )VECLOG_LA_OP_AA ( ||, Vector )
VECLOG_LA_OP_AA ( <=, Matrix )VECLOG_LA_OP_AA ( <, Matrix )VECLOG_LA_OP_AA ( >=, Matrix )VECLOG_LA_OP_AA ( >, Matrix )VECLOG_LA_OP_AA ( ==, Matrix )VECLOG_LA_OP_AA ( !=, Matrix )VECLOG_LA_OP_AA ( &&, Matrix )VECLOG_LA_OP_AA ( ||, Matrix )
VECLOG_LA_OP_AA ( <=, Cube )VECLOG_LA_OP_AA ( <, Cube )VECLOG_LA_OP_AA ( >=, Cube )VECLOG_LA_OP_AA ( >, Cube )VECLOG_LA_OP_AA ( ==, Cube )VECLOG_LA_OP_AA ( !=, Cube )VECLOG_LA_OP_AA ( &&, Cube )VECLOG_LA_OP_AA ( ||, Cube )
LogicalArray near(const Array<T> &l, const Array<T> &r, Double tol)
LogicalArray nearAbs(const Array<T> &l, const Array<T> &r, Double tol)

Element by element comparisons between the "l" and "r" arrays. The result is a LogicalArray. The arrays must conform or an exception is thrown.

The Vector, Matrix and Cube version are present to bypass the problems due to the existence of automatic comparison inline templates in standard algorithm library, producing a single Bool value.

LogicalArray operator && (const Array<T> &l, const Array<T> &r)
LogicalArray operator || (const Array<T> &l, const Array<T> &r)

This only makes sense if the array element type is logical valued.

LogicalArray operator ! (const Array<T> &l)

Logical negation of an array. This only makes sense if the array element type is logical valued.

Bool allLE (const Array<T> &array, const T &val)
Bool allLE (const T &val, const Array<T> &array)
Bool allLT (const Array<T> &array, const T &val)
Bool allLT (const T &val, const Array<T> &array)
Bool allGE (const Array<T> &array, const T &val)
Bool allGE (const T &val, const Array<T> &array)
Bool allGT (const Array<T> &array, const T &val)
Bool allGT (const T &val, const Array<T> &array)
Bool allEQ (const Array<T> &array, const T &val)
Bool allEQ (const T &val, const Array<T> &array)
Bool allNE (const Array<T> &array, const T &val)
Bool allNE (const T &val, const Array<T> &array)
Bool allNear (const Array<T> &array, const T &val, Double tol)
Bool allNear (const T &val, const Array<T> &array, Double tol)
Bool allNearAbs (const Array<T> &array, const T &val, Double tol)
Bool allNearAbs (const T &val, const Array<T> &array, Double tol)

Element by element comparisons between an array and a scalar, which behaves as if it were a conformant array filled with the value "val." The result is true only if the comparison is true for every element of the array.

Bool allAND (const Array<T> &array, const T &val)
Bool allAND (const T &val, const Array<T> &array)
Bool allOR (const Array<T> &array, const T &val)
Bool allOR (const T &val, const Array<T> &array)

This only makes sense if the array element type is logical valued.

LogicalArray operator <= (const Array<T> &array, const T &val)
LogicalArray operator <= (const T &val, const T<T> &array)
LogicalArray operator < (const Array<T> &array, const T &val)
LogicalArray operator < (const T &val, const T<T> &array)
LogicalArray operator >= (const Array<T> &array, const T &val)
LogicalArray operator >= (const T &val, const T<T> &array)
LogicalArray operator > (const Array<T> &array, const T &val)
LogicalArray operator > (const T &val, const T<T> &array)
LogicalArray operator == (const Array<T> &array, const T &val)
LogicalArray operator == (const T &val, const T<T> &array)
LogicalArray operator != (const Array<T> &array, const T &val)
LogicalArray operator != (const T &val, const T<T> &array)
LogicalArray near (const Array<T> &array, const T &val, Double tol)
LogicalArray near (const T &val, const T<T> &array, Double tol)
LogicalArray nearAbs (const Array<T> &array, const T &val, Double tol)
LogicalArray nearAbs (const T &val, const T<T> &array, Double tol)

Element by element comparisons between an array and a scalar, which behaves as if it were a conformant array filled with the value "val." The result is a LogicalArray.

Thrown Exceptions

LogicalArray operator && (const Array<T> &array, const T &val)
LogicalArray operator && (const T &val, const T<T> &array)
LogicalArray operator || (const Array<T> &array, const T &val)
LogicalArray operator || (const T &val, const T<T> &array)

This only makes sense if the array element type is logical valued.

Bool anyLE (const Array<T> &l, const Array<T> &r)
Bool anyLT (const Array<T> &l, const Array<T> &r)
Bool anyGE (const Array<T> &l, const Array<T> &r)
Bool anyGT (const Array<T> &l, const Array<T> &r)
Bool anyEQ (const Array<T> &l, const Array<T> &r)
Bool anyNE (const Array<T> &l, const Array<T> &r)
Bool anyNear (const Array<T> &l, const Array<T> &r, Double tol)
Bool anyNearAbs (const Array<T> &l, const Array<T> &r, Double tol)

Element by element comparisons between the "l" and "r" arrays. The result is true if the comparison is true for some element of the arrays.

Thrown Exceptions

Bool anyAND (const Array<T> &l, const Array<T> &r)
Bool anyOR (const Array<T> &l, const Array<T> &r)

This only makes sense if the array element type is logical valued.

Bool anyLE (const Array<T> &array, const T &val)
Bool anyLE (const T &val, const Array<T> &array)
Bool anyLT (const Array<T> &array, const T &val)
Bool anyLT (const T &val, const Array<T> &array)
Bool anyGE (const Array<T> &array, const T &val)
Bool anyGE (const T &val, const Array<T> &array)
Bool anyGT (const Array<T> &array, const T &val)
Bool anyGT (const T &val, const Array<T> &array)
Bool anyEQ (const Array<T> &array, const T &val)
Bool anyEQ (const T &val, const Array<T> &array)
Bool anyNE (const Array<T> &array, const T &val)
Bool anyNE (const T &val, const Array<T> &array)
Bool anyNear (const Array<T> &array, const T &val, Double tol)
Bool anyNear (const T &val, const Array<T> &array, Double tol)
Bool anyNearAbs (const Array<T> &array, const T &val, Double tol)
Bool anyNearAbs (const T &val, const Array<T> &array, Double tol)

Determine the number of true or false elements. Note that is meant for Bool arrays, but can also be used for e.g. Int arrays.

Element by element comparisons between an array and a scalar, which behaves as if it were a conformant array filled with the value "val." The result is true if the comparison is true for some element of the array. At some point operators will be available that return masks where the comparison is true.

Bool anyAND (const Array<T> &array, const T &val)
Bool anyAND (const T &val, const Array<T> &array)
Bool anyOR (const Array<T> &array, const T &val)
Bool anyOR (const T &val, const Array<T> &array)

Determine the number of true or false elements. Note that is meant for Bool arrays, but can also be used for e.g. Int arrays.

This only makes sense if the array element type is logical valued.

uInt ntrue (const Array<T> &array)
uInt nfalse (const Array<T> &array)

Determine the number of true or false elements. Note that is meant for Bool arrays, but can also be used for e.g. Int arrays.

Determine it for the full array.

Array<uInt> partialNTrue (const Array<T>& array, const IPosition& collapseAxes)
Array<uInt> partialNFalse (const Array<T>& array, const IPosition& collapseAxes)

Determine the number of true or false elements. Note that is meant for Bool arrays, but can also be used for e.g. Int arrays.