Go to the documentation of this file.
28 #ifndef CASA_MARRAYLOGICAL_H
29 #define CASA_MARRAYLOGICAL_H
32 #include <casacore/casa/aips.h>
33 #include <casacore/tables/TaQL/MArrayMathBase.h>
34 #include <casacore/casa/Arrays/ArrayLogical.h>
35 #include <casacore/casa/Arrays/ArrayPartMath.h>
36 #include <casacore/casa/BasicMath/Functors.h>
96 template<
typename T,
typename RES=
size_t>
102 template<
typename T,
typename RES=
size_t>
108 template<
typename T>
class MAllFunc :
public MArrayFunctorBase<T,Bool> {
113 template<
typename T>
class MAnyFunc :
public MArrayFunctorBase<T,Bool> {
125 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
127 left.combineMask(right))); }
131 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
133 left.combineMask(right))); }
136 MArray<Bool>
operator< (
const MArray<T>& left,
const MArray<T>& right)
137 {
return (left.isNull() || right.isNull() ? MArray<Bool>() :
138 MArray<Bool> (left.array() < right.array(),
139 left.combineMask(right))); }
143 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
145 left.combineMask(right))); }
149 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
151 left.combineMask(right))); }
155 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
157 left.combineMask(right))); }
161 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
163 left.combineMask(right))); }
167 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
169 left.combineMask(right))); }
180 MArray<Bool>
operator< (
const MArray<T>& left,
const T& right)
181 {
return MArray<Bool> (left.array() < right, left); }
212 MArray<Bool>
operator< (
const T& left,
const MArray<T>& right)
213 {
return MArray<Bool> (left < right.array(), right); }
249 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
251 left.combineMask(right))); }
256 {
return (left.isNull() || right.isNull() ?
MArray<Bool>() :
258 left.combineMask(right))); }
301 template <
typename T>
303 {
if (left.isNull() || right.isNull()) {
305 }
else if (left.hasMask()) {
306 if (right.hasMask()) {
307 return compareAllMasked (left.
array().begin(), left.
array().end(),
308 right.
array.begin(), left.mask().begin(),
309 right.mask().begin(), std::equal_to<T>());
311 return compareAllMasked (left.
array().begin(), left.
array().end(),
312 right.
array.begin(), left.mask().begin(),
315 }
else if (right.hasMask()) {
316 return compareAllMasked (left.
array().begin(), left.
array().end(),
317 right.
array.begin(), right.mask().begin(),
322 template <
typename T>
326 compareAllRightMasked (
array.array().begin(),
array.array().end(),
327 value,
array.mask().begin(), std::equal_to<T>())
330 template <
typename T>
338 template <
typename T>
340 {
if (left.isNull() || right.isNull()) {
342 }
else if (left.hasMask()) {
343 if (right.hasMask()) {
344 return compareAnyMasked (left.
array().begin(), left.
array().end(),
345 right.
array.begin(), left.mask().begin(),
346 right.mask().begin(), std::equal_to<T>());
348 return compareAnyMasked (left.
array().begin(), left.
array().end(),
349 right.
array.begin(), left.mask().begin(),
352 }
else if (right.hasMask()) {
353 return compareAnyMasked (left.
array().begin(), left.
array().end(),
354 right.
array.begin(), right.mask().begin(),
359 template <
typename T>
363 compareAnyRightMasked (
array.array().begin(),
array.array().end(),
364 value,
array.mask().begin(), std::equal_to<T>())
367 template <
typename T>
385 return a.
array().contiguousStorage() && a.mask().contiguousStorage() ?
386 countNEMasked<T>(a.
array().cbegin(), a.
array().cend(),
387 a.mask().cbegin(), T()) :
388 countNEMasked<T>(a.
array().begin(), a.
array().end(),
389 a.mask().begin(), T());
399 return a.
array().contiguousStorage() && a.mask().contiguousStorage() ?
400 countMasked<T>(a.
array().cbegin(), a.
array().cend(),
401 a.mask().cbegin(), T()) :
402 countMasked<T>(a.
array().begin(), a.
array().end(),
403 a.mask().begin(), T());
416 }
else if (! a.hasMask()) {
430 }
else if (! a.hasMask()) {
444 }
else if (! a.hasMask()) {
450 partialArrayMath (res, a, collapseAxes,
MAllFunc<T>());
460 }
else if (! a.hasMask()) {
466 partialArrayMath (res, a, collapseAxes,
MAnyFunc<T>());
477 }
else if (! a.hasMask()) {
494 }
else if (! a.hasMask()) {
511 }
else if (! a.hasMask()) {
527 }
else if (! a.hasMask()) {
544 }
else if (! a.hasMask()) {
560 }
else if (! a.hasMask()) {
576 }
else if (! a.hasMask()) {
592 }
else if (! a.hasMask()) {
MArray< Bool > partialAnys(const MArray< T > &a, const IPosition &collapseAxes)
Get partial any.
MaskedArray< T > boxedArrayMath(const MaskedArray< T > &array, const IPosition &boxSize, const FuncType &funcObj)
Apply the given ArrayMath reduction function objects to each box in the array.
MArray< uInt > partialNTrue(const MArray< T > &a, const IPosition &collapseAxes)
Get partial ntrues.
MArray< Bool > operator!=(const MArray< T > &left, const MArray< T > &right)
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
MArray< Bool > operator>=(const MArray< T > &left, const MArray< T > &right)
Bool anyEQ(const TableVector< T > &l, const TableVector< T > &r)
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Bool anyTrue(const MArray< Bool > &array)
Is any unmasked element true?
LatticeExprNode nfalse(const LatticeExprNode &expr)
RES operator()(const MArray< T > &arr) const
MArray< uInt > slidingNFalse(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding nfalses.
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
MArray< Bool > isInf(const MArray< T > &arr)
Test which elements are infinite.
MArray< uInt > boxedNTrue(const MArray< T > &a, const IPosition &boxSize)
Get boxed ntrues.
Bool allEQ(const MArray< T > &left, const MArray< T > &right)
Are all unmasked elements equal? The result is True if there are no unmasked elements.
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
MArray< Bool > operator<=(const MArray< T > &left, const MArray< T > &right)
RES operator()(const MArray< T > &arr) const
TableExprNode isInf(const TableExprNode &node)
MArray< uInt > partialNFalse(const MArray< T > &a, const IPosition &collapseAxes)
Get partial nfalses.
MArray< uInt > slidingNTrue(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding ntrues.
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
MArray< Bool > operator&&(const MArray< T > &left, const MArray< T > &right)
MArray< Bool > near(const MArray< T > &left, const MArray< T > &right, Double tol)
Compare with a given relative or absolute tolerance.
MArray< Bool > nearAbs(const MArray< T > &left, const T &right, Double tol)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
MArray< Bool > slidingAlls(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding all.
Bool operator()(const MArray< T > &arr) const
MArray< Bool > nearAbs(const MArray< T > &left, const MArray< T > &right, Double tol)
LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
MArray< Bool > operator||(const MArray< T > &left, const MArray< T > &right)
LatticeExprNode operator||(const LatticeExprNode &left, const LatticeExprNode &right)
MArray< Bool > boxedAnys(const MArray< T > &a, const IPosition &boxSize)
Get boxed any.
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
Bool anyEQ(const MArray< T > &left, const MArray< T > &right)
Is any unmasked element equal? The result is False if there are no unmasked elements.
MArray< Bool > isFinite(const MArray< T > &arr)
Test which elements have a finite value.
size_t nfalse(const MArray< T > &a)
Count the number of unmasked elements that are False.
MArray< uInt > boxedNFalse(const MArray< T > &a, const IPosition &boxSize)
Get boxed nfalses.
Bool anyEQ(const T &value, const MArray< T > &array)
Bool allEQ(const MArray< T > &array, const T &value)
LatticeExprNode operator!(const LatticeExprNode &expr)
this file contains all the compiler specific defines
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
const Array< T > & array() const
Get access to the array.
LatticeExprNode ntrue(const LatticeExprNode &expr)
MArray< Bool > operator==(const MArray< T > &left, const MArray< T > &right)
Define comparison functions between 2 MArray objects and between MArray object and scalar.
MArray< Bool > operator<(const MArray< T > &left, const MArray< T > &right)
MArray< Bool > isNaN(const MArray< T > &arr)
Test which elements are NaN.
MArray< Bool > nearAbs(const T &left, const MArray< T > &right, Double tol)
Bool allTrue(const MArray< Bool > &array)
Are all unmasked elements true?
Bool allEQ(const T &value, const MArray< T > &array)
MArray< Bool > boxedAlls(const MArray< T > &a, const IPosition &boxSize)
Get boxed all.
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
MArray< Bool > operator!(const MArray< T > &a)
The logical NOT of an MArray object (normally Bool type).
MArray< Bool > slidingAnys(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding any.
Bool isNull() const
Does the node contain no actual node?
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
MArray< Bool > near(const T &left, const MArray< T > &right, Double tol)
bool Bool
Define the standard types used by Casacore.
Bool operator()(const MArray< T > &arr) const
size_t ntrue(const MArray< T > &a)
Count the number of unmasked elements that are True.
MArray< Bool > near(const MArray< T > &left, const T &right, Double tol)
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
MArray< Bool > partialAlls(const MArray< T > &a, const IPosition &collapseAxes)
Get partial all.
Define functors to perform a reduction function on an MArray object.
Bool anyEQ(const MArray< T > &array, const T &value)
MArray< Bool > operator>(const MArray< T > &left, const MArray< T > &right)
Array< T > slidingArrayMath(const MaskedArray< T > &array, const IPosition &halfBoxSize, const FuncType &funcObj, Bool fillEdge=True)
Apply for each element in the array the given ArrayMath reduction function object to the box around t...
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)