casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef CASA_FUNCTORS_H
27#define CASA_FUNCTORS_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicMath/Math.h>
31#include <casacore/casa/BasicSL/Complex.h>
32#include <casacore/casa/BasicSL/String.h>
33#include <functional>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// Define a function to do a binary transform in place.
38// It is functionally equivalent to std::transform where the first and result
39// iterator are the same, but it is faster for non-trivial iterators.
40template <typename InputIterator1, typename InputIterator2, typename BinaryOperator>
41inline void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
42 BinaryOperator op) {
43 for (; first1 != last1; ++first1, ++first2) {
44 *first1 = op(*first1, *first2);
45 }
46}
47
48// Define a function to do a unary transform in place.
49// It is functionally equivalent to std::transform where the first and result
50// iterator are the same, but it is faster for non-trivial iterators.
51template <typename InputIterator1, typename UnaryOperator>
52inline void transformInPlace(InputIterator1 first1, InputIterator1 last1, UnaryOperator op) {
53 for (; first1 != last1; ++first1) {
54 *first1 = op(*first1);
55 }
56}
57
58// Define a function (similar to std::accumulate) to do accumulation of
59// elements for which the corresponding mask value is true.
60// The default accumulation is addition.
61template <typename InputIterator, typename MaskIterator, typename Accum, typename BinaryOperator>
62inline Accum accumulateTrue(InputIterator first, InputIterator last, MaskIterator mask, Accum acc,
63 BinaryOperator op = std::plus<Accum>()) {
64 for (; first != last; ++first, ++mask) {
65 if (*mask) acc = op(acc, *first);
66 }
67 return acc;
68}
69
70// Define a function (similar to std::accumulate) to do accumulation of
71// elements for which the corresponding mask value is false.
72// The default accumulation is addition.
73template <typename InputIterator, typename MaskIterator, typename Accum, typename BinaryOperator>
74inline Accum accumulateFalse(InputIterator first, InputIterator last, MaskIterator mask, Accum acc,
75 BinaryOperator op = std::plus<Accum>()) {
76 for (; first != last; ++first, ++mask) {
77 if (!*mask) acc = op(acc, *first);
78 }
79 return acc;
80}
81
82// Define a function to compare all elements of two sequences.
83// It returns true if all elements compare true.
84// An example compare operator is <src>std::equal_to</src>.
85// <group>
86template <typename InputIterator1, typename InputIterator2, typename CompareOperator>
87inline bool compareAll(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
88 CompareOperator op) {
89 for (; first1 != last1; ++first1, ++first2) {
90 if (!op(*first1, *first2)) return false;
91 }
92 return true;
93}
94// For use with a constant left value.
95// This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
96// (see ArrayMath.h).
97template <typename InputIterator1, typename T, typename CompareOperator>
98inline bool compareAllLeft(InputIterator1 first1, InputIterator1 last1, T left,
99 CompareOperator op) {
100 for (; first1 != last1; ++first1) {
101 if (!op(left, *first1)) return false;
102 }
103 return true;
104}
105// For use with a constant right value.
106// This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
107// (see ArrayMath.h).
108template <typename InputIterator1, typename T, typename CompareOperator>
109inline bool compareAllRight(InputIterator1 first1, InputIterator1 last1, T right,
110 CompareOperator op) {
111 for (; first1 != last1; ++first1) {
112 if (!op(*first1, right)) return false;
113 }
114 return true;
115}
116// </group>
117
118// Define a function to compare all elements of two sequences.
119// It returns true if any element compares true.
120// An example compare operator is <src>std::equal_to</src>.
121// <group>
122template <typename InputIterator1, typename InputIterator2, typename CompareOperator>
123inline bool compareAny(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
124 CompareOperator op) {
125 for (; first1 != last1; ++first1, ++first2) {
126 if (op(*first1, *first2)) return true;
127 }
128 return false;
129}
130// For use with a constant left value.
131// This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
132// (see ArrayMath.h).
133template <typename InputIterator1, typename T, typename CompareOperator>
134inline bool compareAnyLeft(InputIterator1 first1, InputIterator1 last1, T left,
135 CompareOperator op) {
136 for (; first1 != last1; ++first1) {
137 if (op(left, *first1)) return true;
138 }
139 return false;
140}
141// For use with a constant right value.
142// This avoids use of bind1st or bind2nd which can fail for gcc-4.3.
143// (see ArrayMath.h).
144template <typename InputIterator1, typename T, typename CompareOperator>
145inline bool compareAnyRight(InputIterator1 first1, InputIterator1 last1, T right,
146 CompareOperator op) {
147 for (; first1 != last1; ++first1) {
148 if (op(*first1, right)) return true;
149 }
150 return false;
151}
152// </group>
153
154// Functor to add variables of possibly different types.
155// This is unlike std::plus which requires equal types.
156template <typename L, typename R = L, typename RES = L>
157struct Plus {
158 RES operator()(const L& x, const R& y) const { return RES(x) + y; }
159};
160
161// Functor to subtract variables of possibly different types.
162// This is unlike std::minus which requires equal types.
163template <typename L, typename R = L, typename RES = L>
164struct Minus {
165 RES operator()(const L& x, const R& y) const { return RES(x) - y; }
166};
167
168// Functor to multiply variables of possibly different types.
169// This is unlike std::multiplies which requires equal types.
170template <typename L, typename R = L, typename RES = L>
172 RES operator()(const L& x, const R& y) const { return RES(x) * y; }
173};
174
175// Functor to divide variables of possibly different types.
176// This is unlike std::divides which requires equal types.
177template <typename L, typename R = L, typename RES = L>
178struct Divides {
179 RES operator()(const L& x, const R& y) const { return RES(x) / y; }
180};
181
182// Functor to take modulo of (integer) variables of possibly different types
183// in the C way.
184// This is unlike std::modulo which requires equal types.
185template <typename L, typename R = L, typename RES = L>
186struct Modulo {
187 RES operator()(const L& x, const R& y) const { return RES(x) % y; }
188};
189
190// Functor to take modulo of variables of possibly different types
191// using the floor modulo (% as used in Python).
192template <typename L, typename R = L, typename RES = L>
193struct FloorMod {
194 RES operator()(const L& x, const R& y) const { return floormod(RES(x), RES(y)); }
195};
196
197// Functor for bitwise and of (integer) values.
198template <typename T>
199struct BitAnd {
200 T operator()(const T& x, const T& y) const { return x & y; }
201};
202
203// Functor for bitwise or of (integer) values.
204template <typename T>
205struct BitOr {
206 T operator()(const T& x, const T& y) const { return x | y; }
207};
208
209// Functor for bitwise xor of (integer) values.
210template <typename T>
211struct BitXor {
212 T operator()(const T& x, const T& y) const { return x ^ y; }
213};
214
215// Functor for bitwise negate of (integer) values.
216template <typename T>
217struct BitNegate {
218 T operator()(const T& x) const { return ~x; }
219};
220
221// Functor to test for NaN.
222// It can be used in something like:
223// <srcblock>
224// std::transform (array.begin(), array.end(),
225// result.begin(), IsNaN<T>());
226// </srcblock>
227template <typename T>
228struct IsNaN {
229 bool operator()(T value) const { return isNaN(value); }
230};
231
232// Functor to test for infinity.
233template <typename T>
234struct IsInf {
235 bool operator()(T value) const { return isInf(value); }
236};
237
238// Functor to test for finiteness.
239template <typename T>
240struct IsFinite {
241 bool operator()(T value) const { return isFinite(value); }
242};
243
244// Functor to test if two values are relatively near each other.
245// It can be used in something like:
246// <srcblock>
247// std::transform (left.begin(), left.cend(), right.begin(),
248// result.cbegin(), Near<T>(tolerance));
249// </srcblock>
250template <typename L, typename R = L>
251struct Near {
252 explicit Near(double tolerance = 1e-5) : itsTolerance(tolerance) {}
253 bool operator()(L left, R right) const { return near(left, L(right), itsTolerance); }
254
255 private:
257};
258
259// Functor to test for if two values are absolutely near each other.
260template <typename L, typename R = L>
261struct NearAbs {
262 explicit NearAbs(double tolerance = 1e-13) : itsTolerance(tolerance) {}
263 bool operator()(L left, R right) const { return nearAbs(left, L(right), itsTolerance); }
264
265 private:
267};
268
269// Functor to apply sin.
270template <typename T, typename RES = T>
271struct Sin {
272 RES operator()(T value) const { return RES(sin(value)); }
273};
274
275// Functor to apply sinh.
276template <typename T, typename RES = T>
277struct Sinh {
278 RES operator()(T value) const { return RES(sinh(value)); }
279};
280
281// Functor to apply asin.
282template <typename T, typename RES = T>
283struct Asin {
284 RES operator()(T value) const { return RES(asin(value)); }
285};
286
287// Functor to apply cos.
288template <typename T, typename RES = T>
289struct Cos {
290 RES operator()(T value) const { return RES(cos(value)); }
291};
292
293// Functor to apply cosh.
294template <typename T, typename RES = T>
295struct Cosh {
296 RES operator()(T value) const { return RES(cosh(value)); }
297};
298
299// Functor to apply acos.
300template <typename T, typename RES = T>
301struct Acos {
302 RES operator()(T value) const { return RES(acos(value)); }
303};
304
305// Functor to apply tan.
306template <typename T, typename RES = T>
307struct Tan {
308 RES operator()(T value) const { return RES(tan(value)); }
309};
310
311// Functor to apply tanh.
312template <typename T, typename RES = T>
313struct Tanh {
314 RES operator()(T value) const { return RES(tanh(value)); }
315};
316
317// Functor to apply atan.
318template <typename T, typename RES = T>
319struct Atan {
320 RES operator()(T value) const { return RES(atan(value)); }
321};
322
323// Functor to apply atan2.
324template <typename L, typename R = L, typename RES = L>
325struct Atan2 {
326 RES operator()(L left, R right) const { return RES(atan2(left, L(right))); }
327};
328
329// Functor to apply sqr (power of 2).
330template <typename T, typename RES = T>
331struct Sqr {
332 RES operator()(T value) const { return RES(value * value); }
333};
334
335// Functor to apply a power of 3.
336template <typename T, typename RES = T>
337struct Pow3 {
338 RES operator()(T value) const { return RES(value * value * value); }
339};
340
341// Functor to apply sqrt.
342template <typename T, typename RES = T>
343struct Sqrt {
344 RES operator()(T value) const { return RES(sqrt(value)); }
345};
346
347// Functor to apply exp.
348template <typename T, typename RES = T>
349struct Exp {
350 RES operator()(T value) const { return RES(exp(value)); }
351};
352
353// Functor to apply log.
354template <typename T, typename RES = T>
355struct Log {
356 RES operator()(T value) const { return RES(log(value)); }
357};
358
359// Functor to apply log10.
360template <typename T, typename RES = T>
361struct Log10 {
362 RES operator()(T value) const { return RES(log10(value)); }
363};
364
365// Functor to apply abs.
366template <typename T, typename RES = T>
367struct Abs {
368 RES operator()(T value) const { return RES(abs(value)); }
369};
370
371// Functor to apply floor.
372template <typename T, typename RES = T>
373struct Floor {
374 RES operator()(T value) const { return RES(floor(value)); }
375};
376
377// Functor to apply ceil.
378template <typename T, typename RES = T>
379struct Ceil {
380 RES operator()(T value) const { return RES(ceil(value)); }
381};
382
383// Functor to apply round (e.g. -3.7 gets -4).
384template <typename T, typename RES = T>
385struct Round {
386 RES operator()(T value) const { return RES(value < 0 ? ceil(value - 0.5) : floor(value + 0.5)); }
387};
388
389// Functor to apply sign (result is -1, 0, or 1).
390template <typename T, typename RES = T>
391struct Sign {
392 RES operator()(T value) const { return (value < 0 ? -1 : (value > 0 ? 1 : 0)); }
393};
394
395// Functor to form a complex number from the left and right value.
396template <typename L, typename R, typename RES>
398 RES operator()(L l, R r) const { return RES(l, r); }
399};
400
401// Functor to form a complex number from the real part of the
402// left value and the right value.
403template <typename L, typename R, typename RES>
405 RES operator()(L l, R r) const { return RES(real(l), r); }
406};
407
408// Functor to form a complex number from the left value and the
409// imaginary part of the right value.
410template <typename L, typename R, typename RES>
412 RES operator()(L l, R r) const { return RES(l, imag(r)); }
413};
414
415// Functor to form a complex number from the real part of the
416// left value and the imaginary part of the right value.
417template <typename L, typename R, typename RES>
419 RES operator()(L l, R r) const { return RES(real(l), imag(r)); }
420};
421
422// Functor to apply complex function conj.
423template <typename T, typename RES = T>
424struct Conj {
425 RES operator()(T value) const { return RES(conj(value)); }
426};
427
428// Functor to apply complex function real.
429template <typename T, typename RES>
430struct Real {
431 RES operator()(T value) const { return RES(real(value)); }
432};
433
434// Functor to apply complex function imag.
435template <typename T, typename RES>
436struct Imag {
437 RES operator()(T value) const { return RES(imag(value)); }
438};
439
440// Functor to apply complex function arg.
441template <typename T, typename RES>
442struct CArg {
443 RES operator()(T value) const { return RES(arg(value)); }
444};
445
446// Functor to apply complex function fabs.
447template <typename T, typename RES>
448struct CAbs {
449 RES operator()(T value) const { return RES(fabs(value)); }
450};
451
452// Functor to apply pow.
453template <typename T, typename E = T, typename RES = T>
454struct Pow {
455 RES operator()(T left, E exponent) const { return RES(pow(left, exponent)); }
456};
457
458// Functor to apply fmod.
459template <typename L, typename R = L, typename RES = L>
460struct Fmod {
461 RES operator()(R left, L right) const { return RES(fmod(left, L(right))); }
462};
463
464// Functor to get minimum of two values.
465template <typename L, typename R = L, typename RES = L>
466struct Min {
467 RES operator()(L left, R right) const { return RES(left < right ? left : right); }
468};
469
470// Functor to get maximum of two values.
471template <typename L, typename R = L, typename RES = L>
472struct Max {
473 RES operator()(L left, R right) const { return RES(left < right ? right : left); }
474};
475
476// Functor to add square of right to left.
477template <typename T, typename Accum = T>
478struct SumSqr {
479 Accum operator()(Accum left, T right) const { return left + Accum(right) * Accum(right); }
480};
481
482// Functor to add squared diff of right and base value to left.
483// It can be used to calculate the variance.
484// Note: it is specialized for complex values to handle real and imag separately.
485template <typename T, typename Accum = T>
487 explicit SumSqrDiff(T base) : itsBase(base) {}
488 Accum operator()(Accum left, T right) const {
489 return left + (right - itsBase) * (right - itsBase);
490 }
491
492 private:
493 Accum itsBase; // store as Accum, so subtraction results in Accum
494};
495// Specialize for complex values.
496// Variance has to be taken for the absolute value of a complex value. thus
497// sum(abs((a[i] - mean)**2
498// where the sqrt used in abs and the **2 cancel each other, thus can be left out.
499// See also https://en.wikipedia.org/wiki/Complex_random_variable#Variance
500// Note that although the sum is real, a complex value is used to have equal template types.
501template <typename T>
502struct SumSqrDiff<std::complex<T>> {
503 explicit SumSqrDiff(std::complex<T> base) : itsBase(base) {}
504 std::complex<T> operator()(std::complex<T> left, std::complex<T> right) const {
505 return left + ((right.real() - itsBase.real()) * (right.real() - itsBase.real()) +
506 (right.imag() - itsBase.imag()) * (right.imag() - itsBase.imag()));
507 }
508
509 private:
510 std::complex<T> itsBase;
511};
512
513// Functor to add absolute diff of right and base value to left.
514// It can be used to calculate the average deviation.
515template <typename T, typename Accum = T>
517 explicit SumAbsDiff(T base) : itsBase(base) {}
518 Accum operator()(Accum left, T right) const { return left + abs((right - itsBase)); }
519
520 private:
521 Accum itsBase; // store as Accum, so subtraction results in Accum
522};
523
524// Functor to downcase a std::string. The result is a casacore::String.
525struct Downcase {
526 String operator()(const std::string& value) const { return downcase(value); }
527};
528
529// Functor to upcase a std::string. The result is a casacore::String.
530struct Upcase {
531 String operator()(const std::string& value) const { return upcase(value); }
532};
533
534// Functor to capitalize a std::string. The result is a casacore::String.
536 String operator()(const std::string& value) const { return capitalize(value); }
537};
538
539// Functor to trim a std::string. The result is a casacore::String.
540// Leading and trailing whitespace is removed.
541struct Trim {
542 String operator()(const std::string& value) const { return trim(value); }
543};
544
545} // namespace casacore
546
547#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
struct Node * first
Definition malloc.h:325
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool compareAnyLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition Functors.h:134
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:123
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode acos(const LatticeExprNode &expr)
bool compareAllLeft(InputIterator1 first1, InputIterator1 last1, T left, CompareOperator op)
For use with a constant left value.
Definition Functors.h:98
TableExprNode isFinite(const TableExprNode &node)
Function to test if a scalar or array is finite.
Definition ExprNode.h:1400
String downcase(const std::string &str)
Global function which returns a transformation to lowercase of String.
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:87
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:1148
TableExprNode isInf(const TableExprNode &node)
Definition ExprNode.h:1397
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:145
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode sqrt(const LatticeExprNode &expr)
String upcase(const std::string &str)
Global function which returns a transformation to uppercase of String.
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
String capitalize(const std::string &str)
Global function which returns a transformation to capitalization of String.
LatticeExprNode log(const LatticeExprNode &expr)
String trim(const std::string &str)
Global function which removes leading and trailing whitespace.
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:74
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:62
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode floor(const LatticeExprNode &expr)
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperator op)
Define a function to do a binary transform in place.
Definition Functors.h:41
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:109
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:344
Functor to apply abs.
Definition Functors.h:367
RES operator()(T value) const
Definition Functors.h:368
Functor to apply acos.
Definition Functors.h:301
RES operator()(T value) const
Definition Functors.h:302
Functor to apply asin.
Definition Functors.h:283
RES operator()(T value) const
Definition Functors.h:284
Functor to apply atan2.
Definition Functors.h:325
RES operator()(L left, R right) const
Definition Functors.h:326
Functor to apply atan.
Definition Functors.h:319
RES operator()(T value) const
Definition Functors.h:320
Functor for bitwise and of (integer) values.
Definition Functors.h:199
T operator()(const T &x, const T &y) const
Definition Functors.h:200
Functor for bitwise negate of (integer) values.
Definition Functors.h:217
T operator()(const T &x) const
Definition Functors.h:218
Functor for bitwise or of (integer) values.
Definition Functors.h:205
T operator()(const T &x, const T &y) const
Definition Functors.h:206
Functor for bitwise xor of (integer) values.
Definition Functors.h:211
T operator()(const T &x, const T &y) const
Definition Functors.h:212
Functor to apply complex function fabs.
Definition Functors.h:448
RES operator()(T value) const
Definition Functors.h:449
Functor to apply complex function arg.
Definition Functors.h:442
RES operator()(T value) const
Definition Functors.h:443
Functor to capitalize a std::string.
Definition Functors.h:535
String operator()(const std::string &value) const
Definition Functors.h:536
Functor to apply ceil.
Definition Functors.h:379
RES operator()(T value) const
Definition Functors.h:380
Functor to apply complex function conj.
Definition Functors.h:424
RES operator()(T value) const
Definition Functors.h:425
Functor to apply cos.
Definition Functors.h:289
RES operator()(T value) const
Definition Functors.h:290
Functor to apply cosh.
Definition Functors.h:295
RES operator()(T value) const
Definition Functors.h:296
Functor to divide variables of possibly different types.
Definition Functors.h:178
RES operator()(const L &x, const R &y) const
Definition Functors.h:179
Functor to downcase a std::string.
Definition Functors.h:525
String operator()(const std::string &value) const
Definition Functors.h:526
Functor to apply exp.
Definition Functors.h:349
RES operator()(T value) const
Definition Functors.h:350
Functor to take modulo of variables of possibly different types using the floor modulo (% as used in ...
Definition Functors.h:193
RES operator()(const L &x, const R &y) const
Definition Functors.h:194
Functor to apply floor.
Definition Functors.h:373
RES operator()(T value) const
Definition Functors.h:374
Functor to apply fmod.
Definition Functors.h:460
RES operator()(R left, L right) const
Definition Functors.h:461
Functor to apply complex function imag.
Definition Functors.h:436
RES operator()(T value) const
Definition Functors.h:437
Functor to test for finiteness.
Definition Functors.h:240
bool operator()(T value) const
Definition Functors.h:241
Functor to test for infinity.
Definition Functors.h:234
bool operator()(T value) const
Definition Functors.h:235
Functor to test for NaN.
Definition Functors.h:228
bool operator()(T value) const
Definition Functors.h:229
Functor to apply log10.
Definition Functors.h:361
RES operator()(T value) const
Definition Functors.h:362
Functor to apply log.
Definition Functors.h:355
RES operator()(T value) const
Definition Functors.h:356
Functor to form a complex number from the left value and the imaginary part of the right value.
Definition Functors.h:411
RES operator()(L l, R r) const
Definition Functors.h:412
Functor to form a complex number from the real part of the left value and the imaginary part of the r...
Definition Functors.h:418
RES operator()(L l, R r) const
Definition Functors.h:419
Functor to form a complex number from the real part of the left value and the right value.
Definition Functors.h:404
RES operator()(L l, R r) const
Definition Functors.h:405
Functor to form a complex number from the left and right value.
Definition Functors.h:397
RES operator()(L l, R r) const
Definition Functors.h:398
Functor to get maximum of two values.
Definition Functors.h:472
RES operator()(L left, R right) const
Definition Functors.h:473
Functor to get minimum of two values.
Definition Functors.h:466
RES operator()(L left, R right) const
Definition Functors.h:467
Functor to subtract variables of possibly different types.
Definition Functors.h:164
RES operator()(const L &x, const R &y) const
Definition Functors.h:165
Functor to take modulo of (integer) variables of possibly different types in the C way.
Definition Functors.h:186
RES operator()(const L &x, const R &y) const
Definition Functors.h:187
Functor to multiply variables of possibly different types.
Definition Functors.h:171
RES operator()(const L &x, const R &y) const
Definition Functors.h:172
double itsTolerance
Definition Functors.h:266
NearAbs(double tolerance=1e-13)
Definition Functors.h:262
bool operator()(L left, R right) const
Definition Functors.h:263
bool operator()(L left, R right) const
Definition Functors.h:253
double itsTolerance
Definition Functors.h:256
Near(double tolerance=1e-5)
Definition Functors.h:252
Functor to add variables of possibly different types.
Definition Functors.h:157
RES operator()(const L &x, const R &y) const
Definition Functors.h:158
Functor to apply a power of 3.
Definition Functors.h:337
RES operator()(T value) const
Definition Functors.h:338
Functor to apply pow.
Definition Functors.h:454
RES operator()(T left, E exponent) const
Definition Functors.h:455
Functor to apply complex function real.
Definition Functors.h:430
RES operator()(T value) const
Definition Functors.h:431
Functor to apply round (e.g.
Definition Functors.h:385
RES operator()(T value) const
Definition Functors.h:386
Functor to apply sign (result is -1, 0, or 1).
Definition Functors.h:391
RES operator()(T value) const
Definition Functors.h:392
Functor to apply sin.
Definition Functors.h:271
RES operator()(T value) const
Definition Functors.h:272
Functor to apply sinh.
Definition Functors.h:277
RES operator()(T value) const
Definition Functors.h:278
Functor to apply sqr (power of 2).
Definition Functors.h:331
RES operator()(T value) const
Definition Functors.h:332
Functor to apply sqrt.
Definition Functors.h:343
RES operator()(T value) const
Definition Functors.h:344
Accum operator()(Accum left, T right) const
Definition Functors.h:518
std::complex< T > operator()(std::complex< T > left, std::complex< T > right) const
Definition Functors.h:504
SumSqrDiff(std::complex< T > base)
Definition Functors.h:503
Accum operator()(Accum left, T right) const
Definition Functors.h:488
Functor to add square of right to left.
Definition Functors.h:478
Accum operator()(Accum left, T right) const
Definition Functors.h:479
Functor to apply tan.
Definition Functors.h:307
RES operator()(T value) const
Definition Functors.h:308
Functor to apply tanh.
Definition Functors.h:313
RES operator()(T value) const
Definition Functors.h:314
Functor to trim a std::string.
Definition Functors.h:541
String operator()(const std::string &value) const
Definition Functors.h:542
Functor to upcase a std::string.
Definition Functors.h:530
String operator()(const std::string &value) const
Definition Functors.h:531