26#ifndef CASA_MARRAYLOGICAL_H
27#define CASA_MARRAYLOGICAL_H
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/MArrayMathBase.h>
32#include <casacore/casa/Arrays/ArrayLogical.h>
33#include <casacore/casa/Arrays/ArrayPartMath.h>
34#include <casacore/casa/BasicMath/Functors.h>
94 template<
typename T,
typename RES=
size_t>
100 template<
typename T,
typename RES=
size_t>
106 template<
typename T>
class MAllFunc :
public MArrayFunctorBase<T,Bool> {
111 template<
typename T>
class MAnyFunc :
public MArrayFunctorBase<T,Bool> {
131 left.combineMask(right))); }
134 MArray<Bool> operator< (
const MArray<T>& left,
const MArray<T>& right)
135 {
return (left.isNull() || right.isNull() ? MArray<Bool>() :
137 left.combineMask(right))); }
178 MArray<Bool> operator< (
const MArray<T>& left,
const T& right)
179 {
return MArray<Bool> (left.array() < right, left); }
210 MArray<Bool> operator< (
const T& left,
const MArray<T>& right)
211 {
return MArray<Bool> (left < right.array(), right); }
299 template <
typename T>
305 return compareAllMasked (left.
array().begin(), left.
array().end(),
307 right.
mask().
begin(), std::equal_to<T>());
309 return compareAllMasked (left.
array().begin(), left.
array().end(),
314 return compareAllMasked (left.
array().begin(), left.
array().end(),
320 template <
typename T>
324 compareAllRightMasked (
array.array().begin(),
array.array().end(),
325 value,
array.mask().begin(), std::equal_to<T>())
328 template <
typename T>
336 template <
typename T>
342 return compareAnyMasked (left.
array().begin(), left.
array().end(),
344 right.
mask().
begin(), std::equal_to<T>());
346 return compareAnyMasked (left.
array().begin(), left.
array().end(),
351 return compareAnyMasked (left.
array().begin(), left.
array().end(),
357 template <
typename T>
361 compareAnyRightMasked (
array.array().begin(),
array.array().end(),
362 value,
array.mask().begin(), std::equal_to<T>())
365 template <
typename T>
384 countNEMasked<T>(a.
array().cbegin(), a.
array().cend(),
386 countNEMasked<T>(a.
array().begin(), a.
array().end(),
398 countMasked<T>(a.
array().cbegin(), a.
array().cend(),
400 countMasked<T>(a.
array().begin(), a.
array().end(),
448 partialArrayMath (res, a, collapseAxes,
MAllFunc<T>());
464 partialArrayMath (res, a, collapseAxes,
MAnyFunc<T>());
Logical functor to test if all elements are true.
Logical functor to test if any elements are true.
bool contiguousStorage() const
Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a cop...
iterator begin()
Get the begin iterator object for any array.
contiter cbegin()
Get the begin iterator object for a contiguous array.
Array< Bool > combineMask(const MArrayBase &other) const
Combine this and the other mask.
Bool isNull() const
Is the array null?
const Array< Bool > & mask() const
Get the mask.
Bool hasMask() const
Is there a mask?
Bool operator()(const MArray< T > &arr) const
Bool operator()(const MArray< T > &arr) const
RES operator()(const MArray< T > &arr) const
Define functors to perform a reduction function on an MArray object.
RES operator()(const MArray< T > &arr) const
const Array< T > & array() const
Get access to the array.
Logical functor to count the number of false elements.
Logical functor to count the number of true elements.
Bool isNull() const
Does the node contain no actual node?
this file contains all the compiler specific defines
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
LatticeExprNode operator&&(const LatticeExprNode &left, const LatticeExprNode &right)
Logical binary operators.
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.
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
TableExprNode isInf(const TableExprNode &node)
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
LatticeExprNode ntrue(const LatticeExprNode &expr)
Bool anyEQ(const TableVector< T > &l, const TableVector< T > &r)
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
LatticeExprNode operator!(const LatticeExprNode &expr)
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
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...
LatticeExprNode operator||(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode nfalse(const LatticeExprNode &expr)
size_t nfalse(const MArray< T > &a)
Count the number of unmasked elements that are False.
Bool allEQ(const MArray< T > &array, const T &value)
size_t ntrue(const MArray< T > &a)
Count the number of unmasked elements that are True.
MArray< Bool > nearAbs(const T &left, const MArray< T > &right, Double tol)
MArray< Bool > partialAlls(const MArray< T > &a, const IPosition &collapseAxes)
Get partial all.
MArray< Bool > operator!=(const MArray< T > &left, const MArray< T > &right)
MArray< Bool > operator||(const MArray< T > &left, const MArray< T > &right)
MArray< Bool > near(const T &left, const MArray< T > &right, Double tol)
MArray< Bool > nearAbs(const MArray< T > &left, const MArray< T > &right, Double tol)
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.
Bool allEQ(const T &value, const MArray< T > &array)
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 > slidingAnys(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding any.
MArray< uInt > slidingNTrue(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding ntrues.
MArray< Bool > isNaN(const MArray< T > &arr)
Test which elements are NaN.
MArray< uInt > boxedNFalse(const MArray< T > &a, const IPosition &boxSize)
Get boxed nfalses.
MArray< Bool > slidingAlls(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding all.
Bool anyEQ(const T &value, const MArray< T > &array)
MArray< Bool > boxedAlls(const MArray< T > &a, const IPosition &boxSize)
Get boxed all.
MArray< Bool > near(const MArray< T > &left, const T &right, Double tol)
MArray< Bool > nearAbs(const MArray< T > &left, const T &right, Double tol)
MArray< Bool > operator&&(const MArray< T > &left, const MArray< T > &right)
MArray< Bool > boxedAnys(const MArray< T > &a, const IPosition &boxSize)
Get boxed any.
MArray< uInt > slidingNFalse(const MArray< T > &a, const IPosition &halfBoxSize, Bool fillEdge=True)
Get sliding nfalses.
MArray< size_t > partialNFalse(const MArray< T > &a, const IPosition &collapseAxes)
Get partial nfalses.
Bool anyTrue(const MArray< Bool > &array)
Is any unmasked element true?
MArray< Bool > isInf(const MArray< T > &arr)
Test which elements are infinite.
MArray< Bool > isFinite(const MArray< T > &arr)
Test which elements have a finite value.
MArray< Bool > partialAnys(const MArray< T > &a, const IPosition &collapseAxes)
Get partial any.
MArray< size_t > partialNTrue(const MArray< T > &a, const IPosition &collapseAxes)
Get partial ntrues.
MArray< uInt > boxedNTrue(const MArray< T > &a, const IPosition &boxSize)
Get boxed ntrues.
MArray< Bool > operator!(const MArray< T > &a)
The logical NOT of an MArray object (normally Bool type).
MArray< Bool > near(const MArray< T > &left, const MArray< T > &right, Double tol)
Compare with a given relative or absolute tolerance.
Bool allTrue(const MArray< Bool > &array)
Are all unmasked elements true?
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.
Bool anyEQ(const MArray< T > &array, const T &value)