SPH
MathBasic.h
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include "objects/Object.h"
9 
11 
13 
14 template <typename T>
15 INLINE constexpr T min(const T& f1, const T& f2) {
16  return (f1 < f2) ? f1 : f2;
17 }
18 
19 template <typename T>
20 INLINE constexpr T max(const T& f1, const T& f2) {
21  return (f1 > f2) ? f1 : f2;
22 }
23 
24 template <typename T, typename... TArgs>
25 INLINE constexpr T min(const T& f1, const T& f2, const TArgs&... rest) {
26  return min(min(f1, f2), rest...);
27 }
28 
29 template <typename T, typename... TArgs>
30 INLINE constexpr T max(const T& f1, const T& f2, const TArgs&... rest) {
31  return max(max(f1, f2), rest...);
32 }
33 
34 template <typename T>
35 INLINE constexpr T clamp(const T& f, const T& f1, const T& f2) {
36  return max(f1, min(f, f2));
37 }
38 
39 template <typename T>
40 INLINE constexpr bool isOdd(const T& f) {
41  return f & 1;
42 }
43 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
constexpr INLINE T max(const T &f1, const T &f2)
Definition: MathBasic.h:20
constexpr INLINE bool isOdd(const T &f)
Definition: MathBasic.h:40
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
Definition: MathBasic.h:35
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
Definition: MathBasic.h:15
Common macros and basic objects.
#define INLINE
Macros for conditional compilation based on selected compiler.
Definition: Object.h:31
#define NAMESPACE_SPH_END
Definition: Object.h:12