casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functors.h
Go to the documentation of this file.
1 //# Functors.h: Define STL functors for basic math functions.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_FUNCTORS_H
29 #define CASA_FUNCTORS_H
30 
31 #include <casacore/casa/aips.h>
35 #include <functional>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 
40  // Define a function to do a binary transform in place.
41  // It is functionally equivalent to std::transform where the first and result
42  // iterator are the same, but it is faster for non-trivial iterators.
43  template<typename InputIterator1, typename InputIterator2, typename BinaryOperator>
44  inline void transformInPlace (InputIterator1 first1, InputIterator1 last1,
45  InputIterator2 first2, BinaryOperator op)
46  {
47  for (; first1!=last1; ++first1, ++first2) {
48  *first1 = op(*first1, *first2);
49  }
50  }
51 
52  // Define a function to do a unary transform in place.
53  // It is functionally equivalent to std::transform where the first and result
54  // iterator are the same, but it is faster for non-trivial iterators.
55  template<typename InputIterator1, typename UnaryOperator>
56  inline void transformInPlace (InputIterator1 first1, InputIterator1 last1,
57  UnaryOperator op)
58  {
59  for (; first1!=last1; ++first1) {
60  *first1 = op(*first1);
61  }
62  }
63 
64  // Define a function (similar to std::accumulate) to do accumulation of
65  // elements for which the corresponding mask value is true.
66  // The default accumulation is addition.
67  template<typename InputIterator, typename MaskIterator, typename Accum, typename BinaryOperator>
68  inline Accum accumulateTrue (InputIterator first, InputIterator last,
69  MaskIterator mask, Accum acc,
70  BinaryOperator op = std::plus<Accum>())
71  {
72  for (; first!=last; ++first, ++mask) {
73  if (*mask) acc = op(acc, *first);
74  }
75  return acc;
76  }
77 
78  // Define a function (similar to std::accumulate) to do accumulation of
79  // elements for which the corresponding mask value is false.
80  // The default accumulation is addition.
81  template<typename InputIterator, typename MaskIterator, typename Accum, typename BinaryOperator>
82  inline Accum accumulateFalse (InputIterator first, InputIterator last,
83  MaskIterator mask, Accum acc,
84  BinaryOperator op = std::plus<Accum>())
85  {
86  for (; first!=last; ++first, ++mask) {
87  if (!*mask) acc = op(acc, *first);
88  }
89  return acc;
90  }
91 
92  // Define a function to compare all elements of two sequences.
93  // It returns true if all elements compare true.
94  // An example compare operator is <src>std::equal_to</src>.
95  // <group>
96  template<typename InputIterator1, typename InputIterator2, typename CompareOperator>
97  inline bool compareAll (InputIterator1 first1, InputIterator1 last1,
98  InputIterator2 first2, CompareOperator op)
99  {
100  for (; first1!=last1; ++first1, ++first2) {
101  if (!op(*first1, *first2)) return false;
102  }
103  return true;
104  }
105  // For use with a constant left value.
106  // This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
107  // (see ArrayMath.h).
108  template<typename InputIterator1, typename T, typename CompareOperator>
109  inline bool compareAllLeft (InputIterator1 first1, InputIterator1 last1,
110  T left, CompareOperator op)
111  {
112  for (; first1!=last1; ++first1) {
113  if (!op(left, *first1)) return false;
114  }
115  return true;
116  }
117  // For use with a constant right value.
118  // This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
119  // (see ArrayMath.h).
120  template<typename InputIterator1, typename T, typename CompareOperator>
121  inline bool compareAllRight (InputIterator1 first1, InputIterator1 last1,
122  T right, CompareOperator op)
123  {
124  for (; first1!=last1; ++first1) {
125  if (!op(*first1, right)) return false;
126  }
127  return true;
128  }
129  // </group>
130 
131  // Define a function to compare all elements of two sequences.
132  // It returns true if any element compares true.
133  // An example compare operator is <src>std::equal_to</src>.
134  // <group>
135  template<typename InputIterator1, typename InputIterator2, typename CompareOperator>
136  inline bool compareAny (InputIterator1 first1, InputIterator1 last1,
137  InputIterator2 first2, CompareOperator op)
138  {
139  for (; first1!=last1; ++first1, ++first2) {
140  if (op(*first1, *first2)) return true;
141  }
142  return false;
143  }
144  // For use with a constant left value.
145  // This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
146  // (see ArrayMath.h).
147  template<typename InputIterator1, typename T, typename CompareOperator>
148  inline bool compareAnyLeft (InputIterator1 first1, InputIterator1 last1,
149  T left, CompareOperator op)
150  {
151  for (; first1!=last1; ++first1) {
152  if (op(left, *first1)) return true;
153  }
154  return false;
155  }
156  // For use with a constant right value.
157  // This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
158  // (see ArrayMath.h).
159  template<typename InputIterator1, typename T, typename CompareOperator>
160  inline bool compareAnyRight (InputIterator1 first1, InputIterator1 last1,
161  T right, CompareOperator op)
162  {
163  for (; first1!=last1; ++first1) {
164  if (op(*first1, right)) return true;
165  }
166  return false;
167  }
168  // </group>
169 
170 
171 
172  // Functor to add variables of possibly different types.
173  // This is unlike std::plus which requires equal types.
174  template <typename L, typename R=L, typename RES=L>
175  struct Plus : public std::binary_function<L,R,RES>
176  {
177  RES operator() (const L& x, const R& y) const
178  { return RES(x)+y; }
179  };
180 
181  // Functor to subtract variables of possibly different types.
182  // This is unlike std::minus which requires equal types.
183  template <typename L, typename R=L, typename RES=L>
184  struct Minus : public std::binary_function<L,R,RES>
185  {
186  RES operator() (const L& x, const R& y) const
187  { return RES(x)-y; }
188  };
189 
190  // Functor to multiply variables of possibly different types.
191  // This is unlike std::multiplies which requires equal types.
192  template <typename L, typename R=L, typename RES=L>
193  struct Multiplies : public std::binary_function<L,R,RES>
194  {
195  RES operator() (const L& x, const R& y) const
196  { return RES(x)*y; }
197  };
198 
199  // Functor to divide variables of possibly different types.
200  // This is unlike std::divides which requires equal types.
201  template <typename L, typename R=L, typename RES=L>
202  struct Divides : public std::binary_function<L,R,RES>
203  {
204  RES operator() (const L& x, const R& y) const
205  { return RES(x)/y; }
206  };
207 
208  // Functor to take modulo of (integer) variables of possibly different types
209  // in the C way.
210  // This is unlike std::modulo which requires equal types.
211  template <typename L, typename R=L, typename RES=L>
212  struct Modulo : public std::binary_function<L,R,RES>
213  {
214  RES operator() (const L& x, const R& y) const
215  { return RES(x)%y; }
216  };
217 
218  // Functor to take modulo of variables of possibly different types
219  // using the floor modulo (% as used in Python).
220  template <typename L, typename R=L, typename RES=L>
221  struct FloorMod : public std::binary_function<L,R,RES>
222  {
223  RES operator() (const L& x, const R& y) const
224  { return floormod (RES(x), RES(y)); }
225  };
226 
227  // Functor for bitwise and of (integer) values.
228  template <typename T>
229  struct BitAnd : public std::binary_function<T,T,T>
230  {
231  T operator() (const T& x, const T& y) const
232  { return x&y; }
233  };
234 
235  // Functor for bitwise or of (integer) values.
236  template <typename T>
237  struct BitOr : public std::binary_function<T,T,T>
238  {
239  T operator() (const T& x, const T& y) const
240  { return x|y; }
241  };
242 
243  // Functor for bitwise xor of (integer) values.
244  template <typename T>
245  struct BitXor : public std::binary_function<T,T,T>
246  {
247  T operator() (const T& x, const T& y) const
248  { return x^y; }
249  };
250 
251  // Functor for bitwise negate of (integer) values.
252  template <typename T>
253  struct BitNegate : public std::unary_function<T,T>
254  {
255  T operator() (const T& x) const
256  { return ~x; }
257  };
258 
259  // Functor to test for NaN.
260  // It can be used in something like:
261  // <srcblock>
262  // std::transform (array.begin(), array.end(),
263  // result.begin(), IsNaN<T>());
264  // </srcblock>
265  template<typename T>
266  struct IsNaN : public std::unary_function<T,bool>
267  {
268  bool operator() (T value) const
269  { return isNaN (value); }
270  };
271 
272  // Functor to test for infinity.
273  template<typename T>
274  struct IsInf : public std::unary_function<T,bool>
275  {
276  bool operator() (T value) const
277  { return isInf (value); }
278  };
279 
280  // Functor to test for finiteness.
281  template<typename T>
282  struct IsFinite : public std::unary_function<T,bool>
283  {
284  bool operator() (T value) const
285  { return isFinite (value); }
286  };
287 
288  // Functor to test if two values are relatively near each other.
289  // It can be used in something like:
290  // <srcblock>
291  // std::transform (left.begin(), left.cend(), right.begin(),
292  // result.cbegin(), Near<T>(tolerance));
293  // </srcblock>
294  template<typename L, typename R=L>
295  struct Near : public std::binary_function<L,R,bool>
296  {
297  explicit Near (double tolerance=1e-5)
298  : itsTolerance (tolerance)
299  {}
300  bool operator() (L left, R right) const
301  { return near (left, L(right), itsTolerance); }
302  private:
303  double itsTolerance;
304  };
305 
306  // Functor to test for if two values are absolutely near each other.
307  template<typename L, typename R=L>
308  struct NearAbs : public std::binary_function<L,R,bool>
309  {
310  explicit NearAbs (double tolerance=1e-13)
311  : itsTolerance (tolerance)
312  {}
313  bool operator() (L left, R right) const
314  { return nearAbs (left, L(right), itsTolerance); }
315  private:
316  double itsTolerance;
317  };
318 
319 
320  // Functor to apply sin.
321  template<typename T, typename RES=T>
322  struct Sin : public std::unary_function<T,RES>
323  {
324  RES operator() (T value) const
325  { return RES(sin (value)); }
326  };
327 
328  // Functor to apply sinh.
329  template<typename T, typename RES=T>
330  struct Sinh : public std::unary_function<T,RES>
331  {
332  RES operator() (T value) const
333  { return RES(sinh (value)); }
334  };
335 
336  // Functor to apply asin.
337  template<typename T, typename RES=T>
338  struct Asin : public std::unary_function<T,RES>
339  {
340  RES operator() (T value) const
341  { return RES(asin (value)); }
342  };
343 
344  // Functor to apply cos.
345  template<typename T, typename RES=T>
346  struct Cos : public std::unary_function<T,RES>
347  {
348  RES operator() (T value) const
349  { return RES(cos (value)); }
350  };
351 
352  // Functor to apply cosh.
353  template<typename T, typename RES=T>
354  struct Cosh : public std::unary_function<T,RES>
355  {
356  RES operator() (T value) const
357  { return RES(cosh (value)); }
358  };
359 
360  // Functor to apply acos.
361  template<typename T, typename RES=T>
362  struct Acos : public std::unary_function<T,RES>
363  {
364  RES operator() (T value) const
365  { return RES(acos (value)); }
366  };
367 
368  // Functor to apply tan.
369  template<typename T, typename RES=T>
370  struct Tan : public std::unary_function<T,RES>
371  {
372  RES operator() (T value) const
373  { return RES(tan (value)); }
374  };
375 
376  // Functor to apply tanh.
377  template<typename T, typename RES=T>
378  struct Tanh : public std::unary_function<T,RES>
379  {
380  RES operator() (T value) const
381  { return RES(tanh (value)); }
382  };
383 
384  // Functor to apply atan.
385  template<typename T, typename RES=T>
386  struct Atan : public std::unary_function<T,RES>
387  {
388  RES operator() (T value) const
389  { return RES(atan (value)); }
390  };
391 
392  // Functor to apply atan2.
393  template<typename L, typename R=L, typename RES=L>
394  struct Atan2 : public std::binary_function<L,R,RES>
395  {
396  RES operator() (L left, R right) const
397  { return RES(atan2 (left, L(right))); }
398  };
399 
400  // Functor to apply sqr (power of 2).
401  template<typename T, typename RES=T>
402  struct Sqr : public std::unary_function<T,RES>
403  {
404  RES operator() (T value) const
405  { return RES(value*value); }
406  };
407 
408  // Functor to apply a power of 3.
409  template<typename T, typename RES=T>
410  struct Pow3 : public std::unary_function<T,RES>
411  {
412  RES operator() (T value) const
413  { return RES(value*value*value); }
414  };
415 
416  // Functor to apply sqrt.
417  template<typename T, typename RES=T>
418  struct Sqrt : public std::unary_function<T,RES>
419  {
420  RES operator() (T value) const
421  { return RES(sqrt (value)); }
422  };
423 
424  // Functor to apply exp.
425  template<typename T, typename RES=T>
426  struct Exp : public std::unary_function<T,RES>
427  {
428  RES operator() (T value) const
429  { return RES(exp (value)); }
430  };
431 
432  // Functor to apply log.
433  template<typename T, typename RES=T>
434  struct Log : public std::unary_function<T,RES>
435  {
436  RES operator() (T value) const
437  { return RES(log (value)); }
438  };
439 
440  // Functor to apply log10.
441  template<typename T, typename RES=T>
442  struct Log10 : public std::unary_function<T,RES>
443  {
444  RES operator() (T value) const
445  { return RES(log10 (value)); }
446  };
447 
448  // Functor to apply abs.
449  template<typename T, typename RES=T>
450  struct Abs : public std::unary_function<T,RES>
451  {
452  RES operator() (T value) const
453  { return RES(abs (value)); }
454  };
455 
456  // Functor to apply floor.
457  template<typename T, typename RES=T>
458  struct Floor : public std::unary_function<T,RES>
459  {
460  RES operator() (T value) const
461  { return RES(floor (value)); }
462  };
463 
464  // Functor to apply ceil.
465  template<typename T, typename RES=T>
466  struct Ceil : public std::unary_function<T,RES>
467  {
468  RES operator() (T value) const
469  { return RES(ceil (value)); }
470  };
471 
472  // Functor to apply round (e.g. -3.7 gets -4).
473  template<typename T, typename RES=T>
474  struct Round : public std::unary_function<T,RES>
475  {
476  RES operator() (T value) const
477  { return RES(value<0 ? ceil(value-0.5) : floor(value+0.5)); }
478  };
479 
480  // Functor to apply sign (result is -1, 0, or 1).
481  template<typename T, typename RES=T>
482  struct Sign : public std::unary_function<T,RES>
483  {
484  RES operator() (T value) const
485  { return (value<0 ? -1 : (value>0 ? 1:0)); }
486  };
487 
488  // Functor to form a complex number from the left and right value.
489  template<typename L, typename R, typename RES>
490  struct MakeComplex : public std::binary_function<L,R,RES>
491  {
492  RES operator() (L l, R r) const
493  { return RES(l, r); }
494  };
495 
496  // Functor to form a complex number from the real part of the
497  // left value and the right value.
498  template<typename L, typename R, typename RES>
499  struct MakeComplexReal : public std::binary_function<L,R,RES>
500  {
501  RES operator() (L l, R r) const
502  { return RES(real(l), r); }
503  };
504 
505  // Functor to form a complex number from the left value and the
506  // imaginary part of the right value.
507  template<typename L, typename R, typename RES>
508  struct MakeComplexImag : public std::binary_function<L,R,RES>
509  {
510  RES operator() (L l, R r) const
511  { return RES(l, imag(r)); }
512  };
513 
514  // Functor to form a complex number from the real part of the
515  // left value and the imaginary part of the right value.
516  template<typename L, typename R, typename RES>
517  struct MakeComplexRealImag : public std::binary_function<L,R,RES>
518  {
519  RES operator() (L l, R r) const
520  { return RES(real(l), imag(r)); }
521  };
522 
523  // Functor to apply complex function conj.
524  template<typename T, typename RES=T>
525  struct Conj : public std::unary_function<T,RES>
526  {
527  RES operator() (T value) const
528  { return RES(conj (value)); }
529  };
530 
531  // Functor to apply complex function real.
532  template<typename T, typename RES>
533  struct Real : public std::unary_function<T,RES>
534  {
535  RES operator() (T value) const
536  { return RES(real (value)); }
537  };
538 
539  // Functor to apply complex function imag.
540  template<typename T, typename RES>
541  struct Imag : public std::unary_function<T,RES>
542  {
543  RES operator() (T value) const
544  { return RES(imag (value)); }
545  };
546 
547  // Functor to apply complex function arg.
548  template<typename T, typename RES>
549  struct CArg : public std::unary_function<T,RES>
550  {
551  RES operator() (T value) const
552  { return RES(arg (value)); }
553  };
554 
555  // Functor to apply complex function fabs.
556  template<typename T, typename RES>
557  struct CAbs : public std::unary_function<T,RES>
558  {
559  RES operator() (T value) const
560  { return RES(fabs (value)); }
561  };
562 
563  // Functor to apply pow.
564  template<typename T, typename E=T, typename RES=T>
565  struct Pow : public std::binary_function<T,E,RES>
566  {
567  RES operator() (T left, E exponent) const
568  { return RES(pow (left, exponent)); }
569  };
570 
571  // Functor to apply fmod.
572  template<typename L, typename R=L, typename RES=L>
573  struct Fmod : public std::binary_function<L,R,RES>
574  {
575  RES operator() (R left, L right) const
576  { return RES(fmod (left, L(right))); }
577  };
578 
579  // Functor to get minimum of two values.
580  template<typename L, typename R=L, typename RES=L>
581  struct Min : public std::binary_function<L,R,RES>
582  {
583  RES operator() (L left, R right) const
584  { return RES(left<right ? left : right); }
585  };
586 
587  // Functor to get maximum of two values.
588  template<typename L, typename R=L, typename RES=L>
589  struct Max : public std::binary_function<L,R,RES>
590  {
591  RES operator() (L left, R right) const
592  { return RES(left<right ? right : left); }
593  };
594 
595  // Functor to add square of right to left.
596  template<typename T, typename Accum=T>
597  struct SumSqr : public std::binary_function<Accum,T,Accum>
598  {
599  Accum operator() (Accum left, T right) const
600  { return left + Accum(right)*Accum(right); }
601  };
602 
603  // Functor to add squared diff of right and base value to left.
604  // It can be used to calculate the variance.
605  // Note: it is specialized for complex values to handle real and imag separately.
606  template<typename T, typename Accum=T>
607  struct SumSqrDiff : public std::binary_function<Accum,T,Accum>
608  {
609  explicit SumSqrDiff(T base) : itsBase(base) {}
610  Accum operator() (Accum left, T right) const
611  { return left + (right-itsBase)*(right-itsBase); }
612  private:
613  Accum itsBase; // store as Accum, so subtraction results in Accum
614  };
615  // Specialize for complex values.
616  // Variance has to be taken for the absolute value of a complex value. thus
617  // sum(abs((a[i] - mean)**2
618  // where the sqrt used in abs and the **2 cancel each other, thus can be left out.
619  // See also https://en.wikipedia.org/wiki/Complex_random_variable#Variance
620  // Note that although the sum is real, a complex value is used to have equal template types.
621  template<typename T>
622  struct SumSqrDiff<std::complex<T>> : public std::binary_function<std::complex<T>,std::complex<T>,std::complex<T>>
623  {
624  explicit SumSqrDiff(std::complex<T> base) : itsBase(base) {}
625  std::complex<T> operator() (std::complex<T> left, std::complex<T> right) const
626  { return left + ((right.real() - itsBase.real()) * (right.real() - itsBase.real()) +
627  (right.imag() - itsBase.imag()) * (right.imag() - itsBase.imag())); }
628  private:
629  std::complex<T> itsBase;
630  };
631 
632  // Functor to add absolute diff of right and base value to left.
633  // It can be used to calculate the average deviation.
634  template<typename T, typename Accum=T>
635  struct SumAbsDiff : public std::binary_function<Accum,T,Accum>
636  {
637  explicit SumAbsDiff(T base) : itsBase(base) {}
638  Accum operator() (Accum left, T right) const
639  { return left + abs((right-itsBase)); }
640  private:
641  Accum itsBase; // store as Accum, so subtraction results in Accum
642  };
643 
644  // Functor to downcase a std::string. The result is a casacore::String.
645  struct Downcase : public std::unary_function<std::string,String>
646  {
647  String operator() (const std::string& value) const
648  { return downcase(value); }
649  };
650 
651  // Functor to upcase a std::string. The result is a casacore::String.
652  struct Upcase : public std::unary_function<std::string,String>
653  {
654  String operator() (const std::string& value) const
655  { return upcase(value); }
656  };
657 
658  // Functor to capitalize a std::string. The result is a casacore::String.
659  struct Capitalize : public std::unary_function<std::string,String>
660  {
661  String operator() (const std::string& value) const
662  { return capitalize(value); }
663  };
664 
665  // Functor to trim a std::string. The result is a casacore::String.
666  // Leading and trailing whitespace is removed.
667  struct Trim : public std::unary_function<std::string,String>
668  {
669  String operator() (const std::string& value) const
670  { return trim(value); }
671  };
672 
673 
674 } //# NAMESPACE CASACORE - END
675 
676 #endif
LatticeExprNode log10(const LatticeExprNode &expr)
Functor to test for if two values are absolutely near each other.
Definition: Functors.h:308
Functor for bitwise and of (integer) values.
Definition: Functors.h:229
RES operator()(L l, R r) const
Definition: Functors.h:501
Accum accumulateTrue(InputIterator first, InputIterator last, MaskIterator mask, Accum acc, BinaryOperator op=std::plus< Accum >())
Define a function (similar to std::accumulate) to do accumulation of elements for which the correspon...
Definition: Functors.h:68
RES operator()(T value) const
Definition: Functors.h:428
String operator()(const std::string &value) const
Definition: Functors.h:661
RES operator()(T value) const
Definition: Functors.h:348
RES operator()(T value) const
Definition: Functors.h:468
Functor to apply asin.
Definition: Functors.h:338
LatticeExprNode log(const LatticeExprNode &expr)
RES operator()(T value) const
Definition: Functors.h:404
Functor to apply log10.
Definition: Functors.h:442
RES operator()(T value) const
Definition: Functors.h:388
LatticeExprNode arg(const LatticeExprNode &expr)
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1430
Functor to apply round (e.g.
Definition: Functors.h:474
Accum operator()(Accum left, T right) const
Definition: Functors.h:599
Functor to add square of right to left.
Definition: Functors.h:597
Functor to add absolute diff of right and base value to left.
Definition: Functors.h:635
RES operator()(T value) const
Definition: Functors.h:559
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
T operator()(const T &x, const T &y) const
Definition: Functors.h:247
RES operator()(const L &x, const R &y) const
Definition: Functors.h:186
Functor to apply a power of 3.
Definition: Functors.h:410
LatticeExprNode imag(const LatticeExprNode &expr)
String operator()(const std::string &value) const
Definition: Functors.h:669
Functor to form a complex number from the real part of the left value and the imaginary part of the r...
Definition: Functors.h:517
RES operator()(T value) const
Definition: Functors.h:551
Functor to apply sqrt.
Definition: Functors.h:418
Functor for bitwise negate of (integer) values.
Definition: Functors.h:253
Near(double tolerance=1e-5)
Definition: Functors.h:297
RES operator()(T value) const
Definition: Functors.h:436
RES operator()(T value) const
Definition: Functors.h:543
struct Node * first
Definition: malloc.h:330
Accum operator()(Accum left, T right) const
Definition: Functors.h:610
bool compareAllLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:109
Functor to get maximum of two values.
Definition: Functors.h:589
RES operator()(T value) const
Definition: Functors.h:527
Functor to test for NaN.
Definition: Functors.h:266
RES operator()(T value) const
Definition: Functors.h:452
Functor to take modulo of variables of possibly different types using the floor modulo (% as used in ...
Definition: Functors.h:221
Functor to downcase a std::string.
Definition: Functors.h:645
Functor to form a complex number from the left and right value.
Definition: Functors.h:490
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
Functor to test for finiteness.
Definition: Functors.h:282
RES operator()(L left, R right) const
Definition: Functors.h:583
T operator()(const T &x) const
Definition: Functors.h:255
Functor to trim a std::string.
Definition: Functors.h:667
Functor for bitwise or of (integer) values.
Definition: Functors.h:237
Functor to apply atan2.
Definition: Functors.h:394
LatticeExprNode exp(const LatticeExprNode &expr)
Functor to subtract variables of possibly different types.
Definition: Functors.h:184
RES operator()(T value) const
Definition: Functors.h:324
RES operator()(T value) const
Definition: Functors.h:460
RES operator()(T value) const
Definition: Functors.h:356
LatticeExprNode floor(const LatticeExprNode &expr)
Functor to apply fmod.
Definition: Functors.h:573
RES operator()(T value) const
Definition: Functors.h:332
LatticeExprNode cos(const LatticeExprNode &expr)
RES operator()(L l, R r) const
Definition: Functors.h:510
Functor to apply sqr (power of 2).
Definition: Functors.h:402
bool operator()(T value) const
Definition: Functors.h:268
Functor to get minimum of two values.
Definition: Functors.h:581
RES operator()(L l, R r) const
Definition: Functors.h:492
LatticeExprNode conj(const LatticeExprNode &expr)
bool operator()(T value) const
Definition: Functors.h:276
Functor to add variables of possibly different types.
Definition: Functors.h:175
Functor to apply complex function fabs.
Definition: Functors.h:557
Functor to apply sin.
Definition: Functors.h:322
T operator()(const T &x, const T &y) const
Definition: Functors.h:239
RES operator()(T value) const
Definition: Functors.h:420
LatticeExprNode tanh(const LatticeExprNode &expr)
RES operator()(T value) const
Definition: Functors.h:412
void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperator op)
Define a function to do a binary transform in place.
Definition: Functors.h:44
Functor to test if two values are relatively near each other.
Definition: Functors.h:295
TableExprNode isInf(const TableExprNode &node)
Definition: ExprNode.h:1583
Functor to apply sinh.
Definition: Functors.h:330
RES operator()(T value) const
Definition: Functors.h:380
NearAbs(double tolerance=1e-13)
Definition: Functors.h:310
Functor to apply complex function imag.
Definition: Functors.h:541
Functor for bitwise xor of (integer) values.
Definition: Functors.h:245
bool operator()(L left, R right) const
Definition: Functors.h:313
RES operator()(const L &x, const R &y) const
Definition: Functors.h:195
Functor to apply exp.
Definition: Functors.h:426
T operator()(const T &x, const T &y) const
Definition: Functors.h:231
Functor to apply log.
Definition: Functors.h:434
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1541
RES operator()(const L &x, const R &y) const
Definition: Functors.h:177
Functor to test for infinity.
Definition: Functors.h:274
Functor to apply tanh.
Definition: Functors.h:378
Functor to form a complex number from the real part of the left value and the right value...
Definition: Functors.h:499
Functor to apply acos.
Definition: Functors.h:362
LatticeExprNode sqrt(const LatticeExprNode &expr)
LatticeExprNode tan(const LatticeExprNode &expr)
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Definition: ExprNode.h:1587
Functor to apply ceil.
Definition: Functors.h:466
LatticeExprNode atan(const LatticeExprNode &expr)
Functor to capitalize a std::string.
Definition: Functors.h:659
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1425
RES operator()(const L &x, const R &y) const
Definition: Functors.h:223
RES operator()(T value) const
Definition: Functors.h:364
bool compareAnyRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:160
Functor to apply complex function real.
Definition: Functors.h:533
bool compareAny(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:136
Functor to apply complex function conj.
Definition: Functors.h:525
Functor to apply atan.
Definition: Functors.h:386
double itsTolerance
Definition: Functors.h:303
Functor to multiply variables of possibly different types.
Definition: Functors.h:193
bool compareAllRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:121
RES operator()(T value) const
Definition: Functors.h:484
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
String operator()(const std::string &value) const
Definition: Functors.h:654
Functor to apply cos.
Definition: Functors.h:346
bool compareAnyLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:148
Accum accumulateFalse(InputIterator first, InputIterator last, MaskIterator mask, Accum acc, BinaryOperator op=std::plus< Accum >())
Define a function (similar to std::accumulate) to do accumulation of elements for which the correspon...
Definition: Functors.h:82
Functor to apply floor.
Definition: Functors.h:458
String operator()(const std::string &value) const
Definition: Functors.h:647
RES operator()(const L &x, const R &y) const
Definition: Functors.h:214
bool operator()(L left, R right) const
Definition: Functors.h:300
RES operator()(T value) const
Definition: Functors.h:535
RES operator()(T value) const
Definition: Functors.h:444
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
Functor to apply sign (result is -1, 0, or 1).
Definition: Functors.h:482
SumSqrDiff(std::complex< T > base)
Definition: Functors.h:624
double itsTolerance
Definition: Functors.h:316
LatticeExprNode asin(const LatticeExprNode &expr)
const Double e
e and functions thereof:
Functor to divide variables of possibly different types.
Definition: Functors.h:202
Functor to apply abs.
Definition: Functors.h:450
LatticeExprNode sinh(const LatticeExprNode &expr)
Functor to form a complex number from the left value and the imaginary part of the right value...
Definition: Functors.h:508
RES operator()(L l, R r) const
Definition: Functors.h:519
RES operator()(T left, E exponent) const
Definition: Functors.h:567
LatticeExprNode acos(const LatticeExprNode &expr)
RES operator()(T value) const
Definition: Functors.h:340
Functor to apply tan.
Definition: Functors.h:370
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1435
String: the storage and methods of handling collections of characters.
Definition: String.h:223
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1207
Accum operator()(Accum left, T right) const
Definition: Functors.h:638
Functor to take modulo of (integer) variables of possibly different types in the C way...
Definition: Functors.h:212
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:97
Functor to apply cosh.
Definition: Functors.h:354
RES operator()(R left, L right) const
Definition: Functors.h:575
Functor to upcase a std::string.
Definition: Functors.h:652
bool operator()(T value) const
Definition: Functors.h:284
LatticeExprNode ceil(const LatticeExprNode &expr)
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
RES operator()(T value) const
Definition: Functors.h:476
Functor to apply pow.
Definition: Functors.h:565
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode real(const LatticeExprNode &expr)
Functor to add squared diff of right and base value to left.
Definition: Functors.h:607
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
RES operator()(L left, R right) const
Definition: Functors.h:396
RES operator()(T value) const
Definition: Functors.h:372
Functor to apply complex function arg.
Definition: Functors.h:549
RES operator()(L left, R right) const
Definition: Functors.h:591
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
RES operator()(const L &x, const R &y) const
Definition: Functors.h:204