antioch-0.4.0
cmath_shims.h
Go to the documentation of this file.
1 
2 //-----------------------------------------------------------------------bl-
3 //--------------------------------------------------------------------------
4 //
5 // Antioch - A Gas Dynamics Thermochemistry Library
6 //
7 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
8 // Sylvain Plessis, Roy H. Stonger
9 //
10 // Copyright (C) 2013 The PECOS Development Team
11 //
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the Version 2.1 GNU Lesser General
14 // Public License as published by the Free Software Foundation.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
24 // Boston, MA 02110-1301 USA
25 //
26 //-----------------------------------------------------------------------el-
27 
28 #ifndef ANTIOCH_CMATH_H
29 #define ANTIOCH_CMATH_H
30 
31 // Antioch headers
33 
34 // C++ headers
35 #include <algorithm> // max, min
36 #include <cmath> // everything else
37 
38 // Create shim methods Antioch::ant_exp() for exp(), etcetera.
39 
40 namespace Antioch
41 {
42  // Bring std:: methods solely into the shim methods.
43  // There has to be a better way to trick an auto function into doing
44  // Koenig lookup on its return type...
45 
46 #ifdef ANTIOCH_HAVE_CXX11
47 #define ANTIOCH_UNARY_SHIM(funcname) \
48 namespace Ugly_CXX11_Workaround \
49 { \
50  using std::funcname; \
51  template <typename T> \
52  inline \
53  auto \
54  ant_##funcname (const T& in) \
55  -> decltype (funcname(in)) \
56  { return funcname(in); } \
57 } \
58 using Ugly_CXX11_Workaround::ant_##funcname;
59 
60 #define ANTIOCH_BINARY_SHIM(funcname) \
61 namespace Ugly_CXX11_Workaround \
62 { \
63  using std::funcname; \
64  template <typename T1, typename T2> \
65  inline \
66  auto \
67  ant_##funcname (const T1& in1, const T2& in2) \
68  -> decltype (funcname(in1, in2)) \
69  { return funcname(in1, in2); } \
70 } \
71 using Ugly_CXX11_Workaround::ant_##funcname;
72 
73 #else // ANTIOCH_HAVE_CXX11
74 
75 #define ANTIOCH_UNARY_SHIM(funcname) \
76  template <typename T> \
77  inline \
78  T \
79  ant_##funcname (const T& in) \
80  { \
81  using std::funcname; \
82  return funcname(in); \
83  }
84 
85 #define ANTIOCH_BINARY_SHIM(funcname) \
86  template <typename T1, typename T2> \
87  inline \
88  T1 \
89  ant_##funcname (const T1& in1, const T2& in2) \
90  { \
91  using std::funcname; \
92  return funcname(in1, in2); \
93  }
94 
95 #endif // ANTIOCH_HAVE_CXX11
96 
99 ANTIOCH_UNARY_SHIM(log10)
103 ANTIOCH_UNARY_SHIM(asin)
104 ANTIOCH_UNARY_SHIM(acos)
105 ANTIOCH_UNARY_SHIM(atan)
106 ANTIOCH_UNARY_SHIM(sinh)
107 ANTIOCH_UNARY_SHIM(cosh)
108 ANTIOCH_UNARY_SHIM(tanh)
109 ANTIOCH_UNARY_SHIM(sqrt)
111 ANTIOCH_UNARY_SHIM(fabs)
112 ANTIOCH_UNARY_SHIM(ceil)
113 ANTIOCH_UNARY_SHIM(floor)
114 
116 ANTIOCH_BINARY_SHIM(atan2)
120 
121 } // end namespace Antioch
122 
123 #endif //ANTIOCH_CMATH_H
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
Definition: eigen_utils.h:88
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type min(const T &in)
Definition: eigen_utils.h:98
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
#define ANTIOCH_BINARY_SHIM(funcname)
Definition: cmath_shims.h:85
The parameters are reduced parameters.
#define ANTIOCH_UNARY_SHIM(funcname)
Definition: cmath_shims.h:75

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8