MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Util.hpp
Go to the documentation of this file.
1 #ifndef UTIL_HPP
2 #define UTIL_HPP
3 
10 #include <Config.hpp>
11 #include <cuda/CudaGlobal.hpp>
12 
13 namespace mgx { namespace util {
14 
15  // Min
16  template <typename T> CU_HOST_DEVICE T min(const T a, const T b)
17  {
18  if(a <= b)
19  return a;
20  return b;
21  }
22 
23  // Max
24  template <typename T> T CU_HOST_DEVICE max(const T a, const T b)
25  {
26  if(a >= b)
27  return a;
28  return b;
29  }
30 
31  // Trim to min/max
32  template <typename T> CU_HOST_DEVICE T trim(const T x, const T minx, const T maxx) {
33  return max(minx, min(maxx, x));
34  }
35 }}
36 #endif