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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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>
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>
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>
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
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
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
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
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
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
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
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
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
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
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
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>>
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
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
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
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
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
668  {
669  String operator() (const std::string& value) const
670  { return trim(value); }
671  };
672 
673 
674 } //# NAMESPACE CASACORE - END
675 
676 #endif
String: the storage and methods of handling collections of characters.
Definition: String.h:225
struct Node * first
Definition: malloc.h:330
const Double e
e and functions thereof:
int floormod(int x, int y)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
bool compareAnyLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:148
LatticeExprNode exp(const LatticeExprNode &expr)
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
LatticeExprNode asin(const LatticeExprNode &expr)
bool compareAny(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:136
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode acos(const LatticeExprNode &expr)
TableExprNode upcase(const TableExprNode &node)
Definition: ExprNode.h:1468
bool compareAllLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition: Functors.h:109
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Definition: ExprNode.h:1630
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode atan(const LatticeExprNode &expr)
LatticeExprNode tanh(const LatticeExprNode &expr)
LatticeExprNode arg(const LatticeExprNode &expr)
bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, CompareOperator op)
Define a function to compare all elements of two sequences.
Definition: Functors.h:97
LatticeExprNode log10(const LatticeExprNode &expr)
LatticeExprNode conj(const LatticeExprNode &expr)
LatticeExprNode sinh(const LatticeExprNode &expr)
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1250
TableExprNode isInf(const TableExprNode &node)
Definition: ExprNode.h:1626
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type.
LatticeExprNode tan(const LatticeExprNode &expr)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
bool compareAnyRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:160
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
TableExprNode capitalize(const TableExprNode &node)
Definition: ExprNode.h:1478
TableExprNode downcase(const TableExprNode &node)
Definition: ExprNode.h:1473
LatticeExprNode sqrt(const LatticeExprNode &expr)
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode log(const LatticeExprNode &expr)
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
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
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
TableExprNode trim(const TableExprNode &node)
Definition: ExprNode.h:1584
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode floor(const LatticeExprNode &expr)
void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperator op)
Define a function to do a binary transform in place.
Definition: Functors.h:44
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
bool compareAllRight(InputIterator1 first1, InputIterator1 last1, T right, CompareOperator op)
For use with a constant right value.
Definition: Functors.h:121
LatticeExprNode ceil(const LatticeExprNode &expr)
LatticeExprNode real(const LatticeExprNode &expr)
LatticeExprNode imag(const LatticeExprNode &expr)
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
Definition: Complex.h:352
Functor to apply abs.
Definition: Functors.h:451
RES operator()(T value) const
Definition: Functors.h:452
Functor to apply acos.
Definition: Functors.h:363
RES operator()(T value) const
Definition: Functors.h:364
Functor to apply asin.
Definition: Functors.h:339
RES operator()(T value) const
Definition: Functors.h:340
Functor to apply atan2.
Definition: Functors.h:395
RES operator()(L left, R right) const
Definition: Functors.h:396
Functor to apply atan.
Definition: Functors.h:387
RES operator()(T value) const
Definition: Functors.h:388
Functor for bitwise and of (integer) values.
Definition: Functors.h:230
T operator()(const T &x, const T &y) const
Definition: Functors.h:231
Functor for bitwise negate of (integer) values.
Definition: Functors.h:254
T operator()(const T &x) const
Definition: Functors.h:255
Functor for bitwise or of (integer) values.
Definition: Functors.h:238
T operator()(const T &x, const T &y) const
Definition: Functors.h:239
Functor for bitwise xor of (integer) values.
Definition: Functors.h:246
T operator()(const T &x, const T &y) const
Definition: Functors.h:247
Functor to apply complex function fabs.
Definition: Functors.h:558
RES operator()(T value) const
Definition: Functors.h:559
Functor to apply complex function arg.
Definition: Functors.h:550
RES operator()(T value) const
Definition: Functors.h:551
Functor to capitalize a std::string.
Definition: Functors.h:660
String operator()(const std::string &value) const
Definition: Functors.h:661
Functor to apply ceil.
Definition: Functors.h:467
RES operator()(T value) const
Definition: Functors.h:468
Functor to apply complex function conj.
Definition: Functors.h:526
RES operator()(T value) const
Definition: Functors.h:527
Functor to apply cos.
Definition: Functors.h:347
RES operator()(T value) const
Definition: Functors.h:348
Functor to apply cosh.
Definition: Functors.h:355
RES operator()(T value) const
Definition: Functors.h:356
Functor to divide variables of possibly different types.
Definition: Functors.h:203
RES operator()(const L &x, const R &y) const
Definition: Functors.h:204
Functor to downcase a std::string.
Definition: Functors.h:646
String operator()(const std::string &value) const
Definition: Functors.h:647
Functor to apply exp.
Definition: Functors.h:427
RES operator()(T value) const
Definition: Functors.h:428
Functor to take modulo of variables of possibly different types using the floor modulo (% as used in ...
Definition: Functors.h:222
RES operator()(const L &x, const R &y) const
Definition: Functors.h:223
Functor to apply floor.
Definition: Functors.h:459
RES operator()(T value) const
Definition: Functors.h:460
Functor to apply fmod.
Definition: Functors.h:574
RES operator()(R left, L right) const
Definition: Functors.h:575
Functor to apply complex function imag.
Definition: Functors.h:542
RES operator()(T value) const
Definition: Functors.h:543
Functor to test for finiteness.
Definition: Functors.h:283
bool operator()(T value) const
Definition: Functors.h:284
Functor to test for infinity.
Definition: Functors.h:275
bool operator()(T value) const
Definition: Functors.h:276
Functor to test for NaN.
Definition: Functors.h:267
bool operator()(T value) const
Definition: Functors.h:268
Functor to apply log10.
Definition: Functors.h:443
RES operator()(T value) const
Definition: Functors.h:444
Functor to apply log.
Definition: Functors.h:435
RES operator()(T value) const
Definition: Functors.h:436
Functor to form a complex number from the left value and the imaginary part of the right value.
Definition: Functors.h:509
RES operator()(L l, R r) const
Definition: Functors.h:510
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
RES operator()(L l, R r) const
Definition: Functors.h:519
Functor to form a complex number from the real part of the left value and the right value.
Definition: Functors.h:500
RES operator()(L l, R r) const
Definition: Functors.h:501
Functor to form a complex number from the left and right value.
Definition: Functors.h:491
RES operator()(L l, R r) const
Definition: Functors.h:492
Functor to get maximum of two values.
Definition: Functors.h:590
RES operator()(L left, R right) const
Definition: Functors.h:591
Functor to get minimum of two values.
Definition: Functors.h:582
RES operator()(L left, R right) const
Definition: Functors.h:583
Functor to subtract variables of possibly different types.
Definition: Functors.h:185
RES operator()(const L &x, const R &y) const
Definition: Functors.h:186
Functor to take modulo of (integer) variables of possibly different types in the C way.
Definition: Functors.h:213
RES operator()(const L &x, const R &y) const
Definition: Functors.h:214
Functor to multiply variables of possibly different types.
Definition: Functors.h:194
RES operator()(const L &x, const R &y) const
Definition: Functors.h:195
Functor to test for if two values are absolutely near each other.
Definition: Functors.h:309
double itsTolerance
Definition: Functors.h:316
NearAbs(double tolerance=1e-13)
Definition: Functors.h:310
bool operator()(L left, R right) const
Definition: Functors.h:313
Functor to test if two values are relatively near each other.
Definition: Functors.h:296
bool operator()(L left, R right) const
Definition: Functors.h:300
double itsTolerance
Definition: Functors.h:303
Near(double tolerance=1e-5)
Definition: Functors.h:297
Functor to add variables of possibly different types.
Definition: Functors.h:176
RES operator()(const L &x, const R &y) const
Definition: Functors.h:177
Functor to apply a power of 3.
Definition: Functors.h:411
RES operator()(T value) const
Definition: Functors.h:412
Functor to apply pow.
Definition: Functors.h:566
RES operator()(T left, E exponent) const
Definition: Functors.h:567
Functor to apply complex function real.
Definition: Functors.h:534
RES operator()(T value) const
Definition: Functors.h:535
Functor to apply round (e.g.
Definition: Functors.h:475
RES operator()(T value) const
Definition: Functors.h:476
Functor to apply sign (result is -1, 0, or 1).
Definition: Functors.h:483
RES operator()(T value) const
Definition: Functors.h:484
Functor to apply sin.
Definition: Functors.h:323
RES operator()(T value) const
Definition: Functors.h:324
Functor to apply sinh.
Definition: Functors.h:331
RES operator()(T value) const
Definition: Functors.h:332
Functor to apply sqr (power of 2).
Definition: Functors.h:403
RES operator()(T value) const
Definition: Functors.h:404
Functor to apply sqrt.
Definition: Functors.h:419
RES operator()(T value) const
Definition: Functors.h:420
Functor to add absolute diff of right and base value to left.
Definition: Functors.h:636
Accum operator()(Accum left, T right) const
Definition: Functors.h:638
SumSqrDiff(std::complex< T > base)
Definition: Functors.h:624
Functor to add squared diff of right and base value to left.
Definition: Functors.h:608
Accum operator()(Accum left, T right) const
Definition: Functors.h:610
Functor to add square of right to left.
Definition: Functors.h:598
Accum operator()(Accum left, T right) const
Definition: Functors.h:599
Functor to apply tan.
Definition: Functors.h:371
RES operator()(T value) const
Definition: Functors.h:372
Functor to apply tanh.
Definition: Functors.h:379
RES operator()(T value) const
Definition: Functors.h:380
Functor to trim a std::string.
Definition: Functors.h:668
String operator()(const std::string &value) const
Definition: Functors.h:669
Functor to upcase a std::string.
Definition: Functors.h:653
String operator()(const std::string &value) const
Definition: Functors.h:654