casacore
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>
32 #include <casacore/casa/BasicMath/Math.h>
33 #include <casacore/casa/BasicSL/Complex.h>
34 #include <casacore/casa/BasicSL/String.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
casacore::Cos::operator()
RES operator()(T value) const
Definition: Functors.h:348
casacore::Atan2
Functor to apply atan2.
Definition: Functors.h:395
casacore::Modulo
Functor to take modulo of (integer) variables of possibly different types in the C way.
Definition: Functors.h:213
casacore::acos
LatticeExprNode acos(const LatticeExprNode &expr)
casacore::Pow::operator()
RES operator()(T left, E exponent) const
Definition: Functors.h:567
casacore::compareAllLeft
bool compareAllLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:109
casacore::transformInPlace
void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperator op)
Define a function to do a binary transform in place.
Definition: Functors.h:44
casacore::Real
Functor to apply complex function real.
Definition: Functors.h:534
casacore::SumAbsDiff
Functor to add absolute diff of right and base value to left.
Definition: Functors.h:636
casacore::CArg::operator()
RES operator()(T value) const
Definition: Functors.h:551
casacore::Imag::operator()
RES operator()(T value) const
Definition: Functors.h:543
casacore::Fmod::operator()
RES operator()(R left, L right) const
Definition: Functors.h:575
casacore::MakeComplex::operator()
RES operator()(L l, R r) const
Definition: Functors.h:492
casacore::Cosh
Functor to apply cosh.
Definition: Functors.h:355
casacore::Minus
Functor to subtract variables of possibly different types.
Definition: Functors.h:185
casacore::Max
Functor to get maximum of two values.
Definition: Functors.h:590
casacore::SumSqr
Functor to add square of right to left.
Definition: Functors.h:598
casacore::BitXor::operator()
T operator()(const T &x, const T &y) const
Definition: Functors.h:247
casacore::MakeComplexImag
Functor to form a complex number from the left value and the imaginary part of the right value.
Definition: Functors.h:509
casacore::IsNaN
Functor to test for NaN.
Definition: Functors.h:267
casacore::Near::operator()
bool operator()(L left, R right) const
Definition: Functors.h:300
casacore::FloorMod
Functor to take modulo of variables of possibly different types using the floor modulo (% as used in ...
Definition: Functors.h:222
casacore::log
LatticeExprNode log(const LatticeExprNode &expr)
casacore::Near::Near
Near(double tolerance=1e-5)
Definition: Functors.h:297
casacore::IsNaN::operator()
bool operator()(T value) const
Definition: Functors.h:268
casacore::Sin::operator()
RES operator()(T value) const
Definition: Functors.h:324
casacore::Sqrt::operator()
RES operator()(T value) const
Definition: Functors.h:420
casacore::compareAnyRight
bool compareAnyRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:160
casacore::real
LatticeExprNode real(const LatticeExprNode &expr)
casacore::isFinite
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Definition: ExprNode.h:1587
casacore::log10
LatticeExprNode log10(const LatticeExprNode &expr)
casacore::compareAny
bool compareAny(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:136
casacore::Sign
Functor to apply sign (result is -1, 0, or 1).
Definition: Functors.h:483
casacore::accumulateTrue
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
casacore::fmod
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
casacore::IsFinite::operator()
bool operator()(T value) const
Definition: Functors.h:284
casacore::CArg
Functor to apply complex function arg.
Definition: Functors.h:550
casacore::abs
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type.
casacore::Sinh::operator()
RES operator()(T value) const
Definition: Functors.h:332
casacore::MakeComplexRealImag::operator()
RES operator()(L l, R r) const
Definition: Functors.h:519
casacore::Sqr
Functor to apply sqr (power of 2).
Definition: Functors.h:403
casacore::Atan2::operator()
RES operator()(L left, R right) const
Definition: Functors.h:396
casacore::BitAnd::operator()
T operator()(const T &x, const T &y) const
Definition: Functors.h:231
casacore::SumAbsDiff::operator()
Accum operator()(Accum left, T right) const
Definition: Functors.h:638
casacore::Asin::operator()
RES operator()(T value) const
Definition: Functors.h:340
casacore::BitXor
Functor for bitwise xor of (integer) values.
Definition: Functors.h:246
casacore::MakeComplexReal
Functor to form a complex number from the real part of the left value and the right value.
Definition: Functors.h:500
casacore::Log::operator()
RES operator()(T value) const
Definition: Functors.h:436
casacore::NearAbs::operator()
bool operator()(L left, R right) const
Definition: Functors.h:313
casacore::BitNegate
Functor for bitwise negate of (integer) values.
Definition: Functors.h:254
casacore::IsFinite
Functor to test for finiteness.
Definition: Functors.h:283
casacore::Asin
Functor to apply asin.
Definition: Functors.h:339
casacore::pow
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
casacore::Capitalize::operator()
String operator()(const std::string &value) const
Definition: Functors.h:661
casacore::Downcase
Functor to downcase a std::string.
Definition: Functors.h:646
casacore::Pow3::operator()
RES operator()(T value) const
Definition: Functors.h:412
casacore::Sin
Functor to apply sin.
Definition: Functors.h:323
casacore::MakeComplex
Functor to form a complex number from the left and right value.
Definition: Functors.h:491
casacore::atan
LatticeExprNode atan(const LatticeExprNode &expr)
casacore::Floor::operator()
RES operator()(T value) const
Definition: Functors.h:460
casacore::Min
Functor to get minimum of two values.
Definition: Functors.h:582
casacore::conj
LatticeExprNode conj(const LatticeExprNode &expr)
casacore::sqrt
LatticeExprNode sqrt(const LatticeExprNode &expr)
casacore::isInf
TableExprNode isInf(const TableExprNode &node)
Definition: ExprNode.h:1583
casacore::tan
LatticeExprNode tan(const LatticeExprNode &expr)
casacore::BitNegate::operator()
T operator()(const T &x) const
Definition: Functors.h:255
casacore::Multiplies::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:195
casacore::Sign::operator()
RES operator()(T value) const
Definition: Functors.h:484
casacore::Ceil::operator()
RES operator()(T value) const
Definition: Functors.h:468
casacore::cos
LatticeExprNode cos(const LatticeExprNode &expr)
casacore::SumSqrDiff< std::complex< T > >::itsBase
std::complex< T > itsBase
Definition: Functors.h:629
casacore::Log
Functor to apply log.
Definition: Functors.h:435
casacore::Modulo::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:214
casacore::Upcase::operator()
String operator()(const std::string &value) const
Definition: Functors.h:654
casacore::value
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
casacore::Floor
Functor to apply floor.
Definition: Functors.h:459
casacore::compareAnyLeft
bool compareAnyLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:148
casacore::upcase
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1425
casacore::cosh
LatticeExprNode cosh(const LatticeExprNode &expr)
casacore::atan2
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
casacore::sin
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
casacore::Exp
Functor to apply exp.
Definition: Functors.h:427
casacore::near
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
casacore::Pow3
Functor to apply a power of 3.
Definition: Functors.h:411
casacore::Tan::operator()
RES operator()(T value) const
Definition: Functors.h:372
casacore::ceil
LatticeExprNode ceil(const LatticeExprNode &expr)
casacore::Fmod
Functor to apply fmod.
Definition: Functors.h:574
casacore::Upcase
Functor to upcase a std::string.
Definition: Functors.h:653
casacore::Sqrt
Functor to apply sqrt.
Definition: Functors.h:419
casacore::Atan::operator()
RES operator()(T value) const
Definition: Functors.h:388
casacore::Round::operator()
RES operator()(T value) const
Definition: Functors.h:476
casacore::compareAll
bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:97
casacore::Sqr::operator()
RES operator()(T value) const
Definition: Functors.h:404
casacore::NearAbs::NearAbs
NearAbs(double tolerance=1e-13)
Definition: Functors.h:310
casacore::asin
LatticeExprNode asin(const LatticeExprNode &expr)
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::Multiplies
Functor to multiply variables of possibly different types.
Definition: Functors.h:194
casacore::Downcase::operator()
String operator()(const std::string &value) const
Definition: Functors.h:647
casacore::SumAbsDiff::itsBase
Accum itsBase
Definition: Functors.h:641
casacore::Min::operator()
RES operator()(L left, R right) const
Definition: Functors.h:583
casacore::CAbs
Functor to apply complex function fabs.
Definition: Functors.h:558
casacore::NearAbs::itsTolerance
double itsTolerance
Definition: Functors.h:316
casacore::Tanh::operator()
RES operator()(T value) const
Definition: Functors.h:380
casacore::imag
LatticeExprNode imag(const LatticeExprNode &expr)
casacore::Tan
Functor to apply tan.
Definition: Functors.h:371
casacore::capitalize
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1435
casacore::Trim
Functor to trim a std::string.
Definition: Functors.h:668
casacore::MakeComplexReal::operator()
RES operator()(L l, R r) const
Definition: Functors.h:501
casacore::Conj::operator()
RES operator()(T value) const
Definition: Functors.h:527
casacore::SumSqrDiff::itsBase
Accum itsBase
Definition: Functors.h:613
casacore::Cos
Functor to apply cos.
Definition: Functors.h:347
casacore::Near::itsTolerance
double itsTolerance
Definition: Functors.h:303
casacore::BitAnd
Functor for bitwise and of (integer) values.
Definition: Functors.h:230
casacore::Near
Functor to test if two values are relatively near each other.
Definition: Functors.h:296
casacore::MakeComplexRealImag
Functor to form a complex number from the real part of the left value and the imaginary part of the r...
Definition: Functors.h:518
casacore::IsInf
Functor to test for infinity.
Definition: Functors.h:275
casacore::IsInf::operator()
bool operator()(T value) const
Definition: Functors.h:276
casacore::Max::operator()
RES operator()(L left, R right) const
Definition: Functors.h:591
casacore::Imag
Functor to apply complex function imag.
Definition: Functors.h:542
casacore::SumSqrDiff
Functor to add squared diff of right and base value to left.
Definition: Functors.h:608
casacore::C::e
const Double e
e and functions thereof:
casacore::Acos::operator()
RES operator()(T value) const
Definition: Functors.h:364
casacore::Trim::operator()
String operator()(const std::string &value) const
Definition: Functors.h:669
casacore::Round
Functor to apply round (e.g.
Definition: Functors.h:475
casacore::isNaN
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
std
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
Definition: Complex.h:352
casacore::compareAllRight
bool compareAllRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:121
casacore::NearAbs
Functor to test for if two values are absolutely near each other.
Definition: Functors.h:309
casacore::downcase
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1430
casacore::mask
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::FloorMod::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:223
casacore::arg
LatticeExprNode arg(const LatticeExprNode &expr)
casacore::Plus::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:177
casacore::Pow
Functor to apply pow.
Definition: Functors.h:566
casacore::Real::operator()
RES operator()(T value) const
Definition: Functors.h:535
casacore::MakeComplexImag::operator()
RES operator()(L l, R r) const
Definition: Functors.h:510
casacore::Abs
Functor to apply abs.
Definition: Functors.h:451
casacore::tanh
LatticeExprNode tanh(const LatticeExprNode &expr)
casacore::Abs::operator()
RES operator()(T value) const
Definition: Functors.h:452
casacore::Acos
Functor to apply acos.
Definition: Functors.h:363
casacore::Divides
Functor to divide variables of possibly different types.
Definition: Functors.h:203
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Ceil
Functor to apply ceil.
Definition: Functors.h:467
casacore::Log10::operator()
RES operator()(T value) const
Definition: Functors.h:444
casacore::floor
LatticeExprNode floor(const LatticeExprNode &expr)
casacore::Plus
Functor to add variables of possibly different types.
Definition: Functors.h:176
casacore::SumSqr::operator()
Accum operator()(Accum left, T right) const
Definition: Functors.h:599
casacore::SumSqrDiff::SumSqrDiff
SumSqrDiff(T base)
Definition: Functors.h:609
casacore::Log10
Functor to apply log10.
Definition: Functors.h:443
casacore::trim
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1541
casacore::accumulateFalse
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
casacore::Divides::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:204
casacore::Conj
Functor to apply complex function conj.
Definition: Functors.h:526
casacore::Minus::operator()
RES operator()(const L &x, const R &y) const
Definition: Functors.h:186
casacore::Sinh
Functor to apply sinh.
Definition: Functors.h:331
casacore::Atan
Functor to apply atan.
Definition: Functors.h:387
casacore::SumAbsDiff::SumAbsDiff
SumAbsDiff(T base)
Definition: Functors.h:637
casacore::SumSqrDiff::operator()
Accum operator()(Accum left, T right) const
Definition: Functors.h:610
first
struct Node * first
Definition: malloc.h:330
casacore::sinh
LatticeExprNode sinh(const LatticeExprNode &expr)
casacore::CAbs::operator()
RES operator()(T value) const
Definition: Functors.h:559
casacore::Capitalize
Functor to capitalize a std::string.
Definition: Functors.h:660
casacore::exp
LatticeExprNode exp(const LatticeExprNode &expr)
casacore::Cosh::operator()
RES operator()(T value) const
Definition: Functors.h:356
casacore::SumSqrDiff< std::complex< T > >::SumSqrDiff
SumSqrDiff(std::complex< T > base)
Definition: Functors.h:624
casacore::Exp::operator()
RES operator()(T value) const
Definition: Functors.h:428
casacore::Tanh
Functor to apply tanh.
Definition: Functors.h:379
casacore::nearAbs
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1207
casacore::BitOr::operator()
T operator()(const T &x, const T &y) const
Definition: Functors.h:239
casacore::BitOr
Functor for bitwise or of (integer) values.
Definition: Functors.h:238