Functors.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_FUNCTORS_HPP
12 #define CUBBYFLOW_FUNCTORS_HPP
13 
14 #include <limits>
15 
16 namespace CubbyFlow
17 {
19 template <typename T>
20 struct NoOp
21 {
22  constexpr T operator()(const T& a) const;
23 };
24 
26 template <typename T, typename U>
27 struct TypeCast
28 {
29  constexpr U operator()(const T& a) const;
30 };
31 
33 template <typename T>
34 struct DoCeil
35 {
36  constexpr T operator()(const T& a) const;
37 };
38 
40 template <typename T>
41 struct DoFloor
42 {
43  constexpr T operator()(const T& a) const;
44 };
45 
47 template <typename T>
48 struct RMinus
49 {
50  constexpr T operator()(const T& a, const T& b) const;
51 };
52 
54 template <typename T>
55 struct RDivides
56 {
57  constexpr T operator()(const T& a, const T& b) const;
58 };
59 
61 template <typename T>
62 struct DoMin
63 {
64  constexpr T operator()(const T& a, const T& b) const;
65 };
66 
68 template <typename T>
69 struct DoMax
70 {
71  constexpr T operator()(const T& a, const T& b) const;
72 };
73 
75 template <typename T>
76 struct DoAbsMin
77 {
78  constexpr T operator()(const T& a, const T& b) const;
79 };
80 
82 template <typename T>
83 struct DoAbsMax
84 {
85  constexpr T operator()(const T& a, const T& b) const;
86 };
87 
89 template <typename T>
90 struct SimilarTo
91 {
92  constexpr SimilarTo(
93  double _tolerance = std::numeric_limits<double>::epsilon())
94  : tolerance(_tolerance)
95  {
96  // Do nothing
97  }
98 
99  constexpr bool operator()(const T& a, const T& b) const;
100 
101  double tolerance;
102 };
103 
105 template <typename T>
106 struct DoClamp
107 {
108  constexpr T operator()(const T& a, const T& low, const T& high) const;
109 };
110 } // namespace CubbyFlow
111 
113 
114 #endif
Performs std::ceil.
Definition: Functors.hpp:34
Takes absolute minimum value.
Definition: Functors.hpp:76
Takes minimum value.
Definition: Functors.hpp:62
Takes absolute maximum value.
Definition: Functors.hpp:83
constexpr SimilarTo(double _tolerance=std::numeric_limits< double >::epsilon())
Definition: Functors.hpp:92
Reverse divides operator.
Definition: Functors.hpp:55
Performs std::floor.
Definition: Functors.hpp:41
constexpr T operator()(const T &a) const
Definition: Functors-Impl.hpp:21
Definition: pybind11Utils.hpp:20
No-op operator.
Definition: Functors.hpp:20
Takes maximum value.
Definition: Functors.hpp:69
True if similar.
Definition: Functors.hpp:90
Reverse minus operator.
Definition: Functors.hpp:48
Clamps the input value with low/high.
Definition: Functors.hpp:106
Type casting operator.
Definition: Functors.hpp:27
double tolerance
Definition: Functors.hpp:101