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