Loading...
Searching...
No Matches
Functors-Impl.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_IMPL_HPP
12#define CUBBYFLOW_FUNCTORS_IMPL_HPP
13
15
16#include <cmath>
17
18namespace CubbyFlow
19{
20template <typename T>
21constexpr T NoOp<T>::operator()(const T& a) const
22{
23 return a;
24}
25
26template <typename T, typename U>
27constexpr U TypeCast<T, U>::operator()(const T& a) const
28{
29 return static_cast<U>(a);
30}
31
32template <typename T>
33constexpr T DoCeil<T>::operator()(const T& a) const
34{
35 return std::ceil(a);
36}
37
38template <typename T>
39constexpr T DoFloor<T>::operator()(const T& a) const
40{
41 return std::floor(a);
42}
43
44template <typename T>
45constexpr T RMinus<T>::operator()(const T& a, const T& b) const
46{
47 return b - a;
48}
49
50template <typename T>
51constexpr T RDivides<T>::operator()(const T& a, const T& b) const
52{
53 return b / a;
54}
55
56template <typename T>
57constexpr T DoMin<T>::operator()(const T& a, const T& b) const
58{
59 return std::min(a, b);
60}
61
62template <typename T>
63constexpr T DoMax<T>::operator()(const T& a, const T& b) const
64{
65 return std::max(a, b);
66}
67
68template <typename T>
69constexpr T DoAbsMin<T>::operator()(const T& a, const T& b) const
70{
71 return AbsMin(a, b);
72}
73
74template <typename T>
75constexpr T DoAbsMax<T>::operator()(const T& a, const T& b) const
76{
77 return AbsMax(a, b);
78}
79
80template <typename T>
81constexpr bool SimilarTo<T>::operator()(const T& a, const T& b) const
82{
83 return std::fabs(a - b) <= tolerance;
84}
85
86template <typename T>
87constexpr T DoClamp<T>::operator()(const T& a, const T& low,
88 const T& high) const
89{
90 return Clamp(a, low, high);
91}
92} // namespace CubbyFlow
93
94#endif
ValueType AbsMin() const
Definition MatrixExpression-Impl.hpp:141
ValueType AbsMax() const
Definition MatrixExpression-Impl.hpp:162
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
std::enable_if_t< std::is_arithmetic< T >::value, T > Clamp(T val, T low, T high)
Returns the clamped value.
Definition MathUtils-Impl.hpp:166
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:75
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:69
constexpr T operator()(const T &a) const
Definition Functors-Impl.hpp:33
constexpr T operator()(const T &a, const T &low, const T &high) const
Definition Functors-Impl.hpp:87
constexpr T operator()(const T &a) const
Definition Functors-Impl.hpp:39
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:63
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:57
constexpr T operator()(const T &a) const
Definition Functors-Impl.hpp:21
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:51
constexpr T operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:45
constexpr bool operator()(const T &a, const T &b) const
Definition Functors-Impl.hpp:81
constexpr U operator()(const T &a) const
Definition Functors-Impl.hpp:27