//# MaskArrLogi.h: Element by element logical operations on masked arrays. //# Copyright (C) 1993,1994,1995,1999,2001 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #ifndef CASA_MASKARRLOGI_2_H #define CASA_MASKARRLOGI_2_H #include "Array.h" #include "MaskedArray.h" #include "MaskLogiArr.h" namespace casacore { //# NAMESPACE CASACORE - BEGIN // // Logical operations for MaskedArrays, and between MaskedArrays and Arrays. // // // // //
  • Array //
  • LogicalArray //
  • MaskedArray // // // // MaskArrLogi is short for MaskedArrayLogical, which is too long by the // old AIPS++ file naming conventions. This file contains global functions // which perform element by element logical operations on masked arrays. // // // // These functions perform element by element logical operations on // masked arrays. With two arrays, they must both conform, and the result // is done element by element, for those locations where the mask of the // MaskedArray is true. For two MaskedArrays, the "and" of the masks is used. // // There are two classes of functions. One class returns a MaskedLogicalArray. // In these functions, the value of an element of the MaskedLogicalArray is // the value of the logical operation applied to the corresponding elements // of the input MaskedArrays. 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 masked arrays for the "all" functions // (e.g. allLE()), and returns true if the logical operation returns true for // any elements of the input masked arrays for the "any" functions // (e.g. anyLE()). The functions which return a single bool throw an exception // if the AND of the masks of the input masked arrays has no true elements. // // For instance allLE (a, b) imples 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]). // // NB comparison between two zero-sized arrays is not defined (should it // throw an exception?). // // // // // Vector a(10); // Vector b(10); // LogicalVector l(10); // . . . // l = a(a>0) < b(b>0); // // This example sets those elements of l where ((a>0) && (b>0)) to (a0) && (b>0)) are unchanged. The result of // the comparison is a MaskedLogicalArray. The assignment from this // MaskedLogicalArray to the LogicalArray l only assigns those elements // where the mask is true. // // // // // Vector a(10); // Vector b(10); // bool result; // . . . // result = allLT (a(a>0), b(b>0)); // // This example sets result to true if, for all elements where // ((a>0) && (b>0)), a // // // One wants to be able to mask arrays and perform logical operations on // those masked arrays. Since the masked arrays are only defined where // the masks are true, the result must be a MaskedLogicalArray, or a single // bool. // // // // MaskedArray logical operations -- Logical operations // for MaskedArrays, and between MaskedArrays and Arrays. // // // // // 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 // for which the mask of the MaskedArray is true. For two MaskedArrays, // the "and" of the masks is used. // // //
  • ArrayConformanceError //
  • ArrayError // // // template bool allLE (const MaskedArray &l, const Array &r); template bool allLT (const MaskedArray &l, const Array &r); template bool allGE (const MaskedArray &l, const Array &r); template bool allGT (const MaskedArray &l, const Array &r); template bool allEQ (const MaskedArray &l, const Array &r); template bool allNE (const MaskedArray &l, const Array &r); // // This only makes sense if the array element type is logical valued. // template bool allAND (const MaskedArray &l, const Array &r); template bool allOR (const MaskedArray &l, const Array &r); // template bool allLE (const Array &l, const MaskedArray &r); template bool allLT (const Array &l, const MaskedArray &r); template bool allGE (const Array &l, const MaskedArray &r); template bool allGT (const Array &l, const MaskedArray &r); template bool allEQ (const Array &l, const MaskedArray &r); template bool allNE (const Array &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template bool allAND (const Array &l, const MaskedArray &r); template bool allOR (const Array &l, const MaskedArray &r); // template bool allLE (const MaskedArray &l, const MaskedArray &r); template bool allLT (const MaskedArray &l, const MaskedArray &r); template bool allGE (const MaskedArray &l, const MaskedArray &r); template bool allGT (const MaskedArray &l, const MaskedArray &r); template bool allEQ (const MaskedArray &l, const MaskedArray &r); template bool allNE (const MaskedArray &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template bool allAND (const MaskedArray &l, const MaskedArray &r); template bool allOR (const MaskedArray &l, const MaskedArray &r); // // // // Element by element comparisons between the "l" and "r" arrays. The result // is a MaskedLogicalArray. // // The arrays must conform or an exception is thrown. // // //
  • ArrayConformanceError // // // template MaskedLogicalArray operator <= (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator < (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator >= (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator > (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator == (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator != (const MaskedArray &l, const Array &r); // // This only makes sense if the array element type is logical valued. // template MaskedLogicalArray operator && (const MaskedArray &l, const Array &r); template MaskedLogicalArray operator || (const MaskedArray &l, const Array &r); // template MaskedLogicalArray operator <= (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator < (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator >= (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator > (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator == (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator != (const Array &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template MaskedLogicalArray operator && (const Array &l, const MaskedArray &r); template MaskedLogicalArray operator || (const Array &l, const MaskedArray &r); // template MaskedLogicalArray operator <= (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator < (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator >= (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator > (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator == (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator != (const MaskedArray &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template MaskedLogicalArray operator && (const MaskedArray &l, const MaskedArray &r); template MaskedLogicalArray operator || (const MaskedArray &l, const MaskedArray &r); // // // // Logical negation of a MaskedArray. This only makes sense if the array // element type is logical valued. template MaskedLogicalArray operator ! (const MaskedArray &marray); // // 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 // for which the mask of the MaskedArray is true. // //
  • ArrayError // // // template bool allLE (const MaskedArray &array, const T &val); template bool allLE (const T &val, const MaskedArray &array); template bool allLT (const MaskedArray &array, const T &val); template bool allLT (const T &val, const MaskedArray &array); template bool allGE (const MaskedArray &array, const T &val); template bool allGE (const T &val, const MaskedArray &array); template bool allGT (const MaskedArray &array, const T &val); template bool allGT (const T &val, const MaskedArray &array); template bool allEQ (const MaskedArray &array, const T &val); template bool allEQ (const T &val, const MaskedArray &array); template bool allNE (const MaskedArray &array, const T &val); template bool allNE (const T &val, const MaskedArray &array); // // This only makes sense if the array element type is logical valued. // template bool allAND (const MaskedArray &array, const T &val); template bool allAND (const T &val, const MaskedArray &array); template bool allOR (const MaskedArray &array, const T &val); template bool allOR (const T &val, const MaskedArray &array); // // // // // 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 an MaskedLogicalArray. // // template MaskedLogicalArray operator <= (const MaskedArray &array, const T &val); template MaskedLogicalArray operator <= (const T &val, const MaskedArray &array); template MaskedLogicalArray operator < (const MaskedArray &array, const T &val); template MaskedLogicalArray operator < (const T &val, const MaskedArray &array); template MaskedLogicalArray operator >= (const MaskedArray &array, const T &val); template MaskedLogicalArray operator >= (const T &val, const MaskedArray &array); template MaskedLogicalArray operator > (const MaskedArray &array, const T &val); template MaskedLogicalArray operator > (const T &val, const MaskedArray &array); template MaskedLogicalArray operator == (const MaskedArray &array, const T &val); template MaskedLogicalArray operator == (const T &val, const MaskedArray &array); template MaskedLogicalArray operator != (const MaskedArray &array, const T &val); template MaskedLogicalArray operator != (const T &val, const MaskedArray &array); // // This only makes sense if the array element type is logical valued. // template MaskedLogicalArray operator && (const MaskedArray &array, const T &val); template MaskedLogicalArray operator && (const T &val, const MaskedArray &array); template MaskedLogicalArray operator || (const MaskedArray &array, const T &val); template MaskedLogicalArray operator || (const T &val, const MaskedArray &array); // // // //# With two arrays, they must both conform, and the result is done element //# by element. For instance anyLE (a, b) imples that some element of a is //# less than or equal to every element of b. //# NB comparison between two zero-sized arrays is not defined (should it //# throw an exception?). // // Element by element comparisons between the "l" and "r" arrays. The result // is true only if the comparison is true for some element of the arrays // for which the mask of the MaskedArray is true. For two MaskedArrays, // the "and" of the masks is used. // // //
  • ArrayConformanceError //
  • ArrayError // // // // template bool anyLE (const MaskedArray &l, const Array &r); template bool anyLT (const MaskedArray &l, const Array &r); template bool anyGE (const MaskedArray &l, const Array &r); template bool anyGT (const MaskedArray &l, const Array &r); template bool anyEQ (const MaskedArray &l, const Array &r); template bool anyNE (const MaskedArray &l, const Array &r); // // This only makes sense if the array element type is logical valued. // template bool anyAND (const MaskedArray &l, const Array &r); template bool anyOR (const MaskedArray &l, const Array &r); // template bool anyLE (const Array &l, const MaskedArray &r); template bool anyLT (const Array &l, const MaskedArray &r); template bool anyGE (const Array &l, const MaskedArray &r); template bool anyGT (const Array &l, const MaskedArray &r); template bool anyEQ (const Array &l, const MaskedArray &r); template bool anyNE (const Array &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template bool anyAND (const Array &l, const MaskedArray &r); template bool anyOR (const Array &l, const MaskedArray &r); // template bool anyLE (const MaskedArray &l, const MaskedArray &r); template bool anyLT (const MaskedArray &l, const MaskedArray &r); template bool anyGE (const MaskedArray &l, const MaskedArray &r); template bool anyGT (const MaskedArray &l, const MaskedArray &r); template bool anyEQ (const MaskedArray &l, const MaskedArray &r); template bool anyNE (const MaskedArray &l, const MaskedArray &r); // // This only makes sense if the array element type is logical valued. // template bool anyAND (const MaskedArray &l, const MaskedArray &r); template bool anyOR (const MaskedArray &l, const MaskedArray &r); // // // // 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 some element // for which the mask of the MaskedArray is true. // // //
  • ArrayError // // // // template bool anyLE (const MaskedArray &array, const T &val); template bool anyLE (const T &val, const MaskedArray &array); template bool anyLT (const MaskedArray &array, const T &val); template bool anyLT (const T &val, const MaskedArray &array); template bool anyGE (const MaskedArray &array, const T &val); template bool anyGE (const T &val, const MaskedArray &array); template bool anyGT (const MaskedArray &array, const T &val); template bool anyGT (const T &val, const MaskedArray &array); template bool anyEQ (const MaskedArray &array, const T &val); template bool anyEQ (const T &val, const MaskedArray &array); template bool anyNE (const MaskedArray &array, const T &val); template bool anyNE (const T &val, const MaskedArray &array); // // This only makes sense if the array element type is logical valued. // template bool anyAND (const MaskedArray &array, const T &val); template bool anyAND (const T &val, const MaskedArray &array); template bool anyOR (const MaskedArray &array, const T &val); template bool anyOR (const T &val, const MaskedArray &array); // // // // } //# NAMESPACE CASACORE - END #include "MaskArrLogi.tcc" #endif