MorphoGraphX
Util.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef UTIL_HPP
12 #define UTIL_HPP
13 
20 #include <Config.hpp>
21 #include <cuda/CudaGlobal.hpp>
22 
23 namespace mgx { namespace util {
24 
25  // Min
26  template <typename T> CU_HOST_DEVICE T min(const T a, const T b)
27  {
28  if(a <= b)
29  return a;
30  return b;
31  }
32 
33  // Max
34  template <typename T> T CU_HOST_DEVICE max(const T a, const T b)
35  {
36  if(a >= b)
37  return a;
38  return b;
39  }
40 
41  // Trim to min/max
42  template <typename T> CU_HOST_DEVICE T trim(const T x, const T minx, const T maxx) {
43  return max(minx, min(maxx, x));
44  }
45 }}
46 #endif
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26