28 #ifndef CASA_MARRAYMATHBASE_H
29 #define CASA_MARRAYMATHBASE_H
37 template<
typename T>
class MArray;
72 template<
typename T,
typename ARRAYITER,
typename MASKITER,
typename OPER>
77 for (; abegin!=aend; ++abegin, ++mbegin) {
78 if (!*mbegin) { accum = *abegin; ++abegin; ++mbegin;
break; }
80 for (; abegin!=aend; ++abegin, ++mbegin) {
81 if (!*mbegin) accum = oper(accum, *abegin);
88 template<
typename T,
typename ARRAYITER,
typename MASKITER,
typename OPER>
92 for (; abegin!=aend; ++abegin, ++mbegin) {
93 if (!*mbegin) accum = oper(accum, *abegin);
101 template<
typename T,
typename ARRAYITER,
typename MASKITER>
102 size_t countMasked (ARRAYITER abegin, ARRAYITER aend, MASKITER mbegin,
106 for (; abegin!=aend; ++abegin, ++mbegin) {
107 if (!*mbegin && *abegin == value) ++n;
114 template<
typename T,
typename ARRAYITER,
typename MASKITER>
119 for (; abegin!=aend; ++abegin, ++mbegin) {
120 if (!*mbegin && *abegin != value) ++n;
130 template<
typename InputIterator1,
typename InputIterator2,
131 typename MaskIterator,
typename CompareOperator>
133 InputIterator2 first2,
134 MaskIterator mask1, MaskIterator mask2,
137 for (; first1!=last1; ++first1, ++first2, ++mask1, ++mask2) {
138 if (!*mask1 && !*mask2) {
139 if (!op(*first1, *first2))
return False;
144 template<
typename InputIterator1,
typename InputIterator2,
145 typename MaskIterator,
typename CompareOperator>
147 InputIterator2 first2,
151 for (; first1!=last1; ++first1, ++first2, ++mask1) {
153 if (!op(*first1, *first2))
return False;
161 template<
typename InputIterator1,
typename T,
162 typename MaskIterator,
typename CompareOperator>
164 T left, MaskIterator mask1,
167 for (; first1!=last1; ++first1, ++mask1) {
169 if (!op(left, *first1))
return False;
177 template<
typename InputIterator1,
typename T,
178 typename MaskIterator,
typename CompareOperator>
180 T right, MaskIterator mask1,
183 for (; first1!=last1; ++first1, ++mask1) {
185 if (!op(*first1, right))
return False;
197 template<
typename InputIterator1,
typename InputIterator2,
198 typename MaskIterator,
typename CompareOperator>
200 InputIterator2 first2,
201 MaskIterator mask1, MaskIterator mask2,
204 for (; first1!=last1; ++first1, ++first2, ++mask1, ++mask2) {
205 if (!*mask1 && !*mask2) {
206 if (op(*first1, *first2))
return true;
211 template<
typename InputIterator1,
typename InputIterator2,
212 typename MaskIterator,
typename CompareOperator>
214 InputIterator2 first2,
218 for (; first1!=last1; ++first1, ++first2, ++mask1) {
220 if (op(*first1, *first2))
return true;
228 template<
typename InputIterator1,
typename T,
229 typename MaskIterator,
typename CompareOperator>
231 T left, MaskIterator mask1,
234 for (; first1!=last1; ++first1, ++mask1) {
236 if (op(left, *first1))
return true;
244 template<
typename InputIterator1,
typename T,
245 typename MaskIterator,
typename CompareOperator>
247 T right, MaskIterator mask1,
250 for (; first1!=last1; ++first1, ++mask1) {
252 if (op(*first1, right))
return true;
266 virtual RES operator() (
const MArray<T>&)
const = 0;
Class to handle an Array with an optional mask.
bool compareAllMasked(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, MaskIterator mask1, CompareOperator op)
T accumulateMasked(ARRAYITER abegin, ARRAYITER aend, MASKITER mbegin, OPER oper)
Define STL-like accumulate function operating on arrays with masks.
bool compareAllMasked(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, MaskIterator mask1, MaskIterator mask2, CompareOperator op)
Define a function to compare the unmasked elements of two sequences.
bool compareAnyMasked(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, MaskIterator mask1, MaskIterator mask2, CompareOperator op)
Define a function to compare the unmasked elements of two sequences.
bool compareAnyLeftMasked(InputIterator1 first1, InputIterator1 last1, T left, MaskIterator mask1, CompareOperator op)
For use with a constant left value.
bool compareAllRightMasked(InputIterator1 first1, InputIterator1 last1, T right, MaskIterator mask1, CompareOperator op)
For use with a constant right value.
bool compareAllLeftMasked(InputIterator1 first1, InputIterator1 last1, T left, MaskIterator mask1, CompareOperator op)
For use with a constant left value.
T accumulateMasked(ARRAYITER abegin, ARRAYITER aend, MASKITER mbegin, T accum, OPER oper)
The second function uses an externally initialized accumulator (e.g.
bool compareAnyMasked(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, MaskIterator mask1, CompareOperator op)
Define the base class for functors to perform a reduction function on an MArray object.
virtual ~MArrayFunctorBase()
size_t countNEMasked(ARRAYITER abegin, ARRAYITER aend, MASKITER mbegin, const T &value)
Count the number of unmasked values not matching the given value.
size_t countMasked(ARRAYITER abegin, ARRAYITER aend, MASKITER mbegin, const T &value)
Count the number of unmasked values matching the given value.
bool compareAnyRightMasked(InputIterator1 first1, InputIterator1 last1, T right, MaskIterator mask1, CompareOperator op)
For use with a constant right value.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.