d0nt_math.hpp
Go to the documentation of this file.
1 /**
2 * File : d0math
3 * Author : Gordon Watts (gwatts@fnal.gov) & Onne Peters (opeters@fnal.gov)
4 * Created : 5/24/1999
5 * Last updated : 5/24/1999
6 * Description : This is a workaround for the fact that the math functions in cmath are not
7 * : part of the standard namespace. This file gets included instead of <cmath>
8 * : or <math.h> by using the #pragma include_alias directive.
9 **/
10 
11 #ifndef D0MATH
12 #define D0MATH
13 
14 // This is needed, because of the line
15 // #pragma include_alias(<cmath>, <d0math>)
16 // in nt_settings.hpp. That caused the #include <cmath> here to become <d0math>, and
17 // the header would include itself...Luckily enough transitivity is not supported for
18 // these #pragma's...
19 
20 #pragma include_alias(<cmath_temp>, <cmath>)
21 
22 #include <cmath_temp>
23 #include <complex>
24 
25 namespace std {
26  // abs functions
27  //template< class T >
28  //inline T abs(T number) {
29  // return ::abs(number);
30  //}
31 
32  // Specify this for double, floats and longs, so that fabs/labs gets called instead of
33  // abs.
34  // double a = abs(-0.255) gives 0.
35  //inline double abs(double number) {
36  // return ::fabs(number);
37  //}
38 
39  inline float abs(float number) {
40  return (float)::fabs(number);
41  }
42 
43  inline long abs(long number) {
44  return ::labs(number);
45  }
46 
47  // Seems to be some sort of template specilization problem... this workaround seems to work..
48  //inline double abs (std::complex<double> &c) {
49  // return abs<complex<double> > (c);
50  //};
51 
52  // acos functions
53  template< class T >
54  inline T acos(T number) {
55  return ::acos(number);
56  }
57 
58  // asin functions
59  template< class T >
60  inline T asin(T number) {
61  return ::asin(number);
62  }
63 
64  // atan functions
65  template< class T >
66  inline T atan(T number) {
67  return ::atan(number);
68  }
69 
70  // atan2 functions
71  template< class T >
72  inline T atan2(T number) {
73  return ::atan2(number);
74  }
75 
76  // cos functions
77  template< class T >
78  inline T cos(T number) {
79  return ::cos(number);
80  }
81 
82  // cosh functions
83  template< class T >
84  inline T cosh(T number) {
85  return ::cosh(number);
86  }
87 
88  // exp functions
89  //template< class T >
90  //inline T exp(T number) {
91  // return ::exp(number);
92  //}
93 
94  // fabs functions
95  //template< class T >
96  //inline T fabs(T number) {
97  // return ::fabs(number);
98  //}
99 
100  // fmod functions
101  template< class T1, class T2 >
102  inline T1 fmod(T1 number1, T2 number2) {
103  return ::asin(number1, number2);
104  }
105 
106  // labs function
107  template< class T >
108  inline T labs(T number) {
109  return ::labs(number);
110  }
111 
112  // log functions
113  //template< class T >
114  //inline T log(T number) {
115  // return ::log(number);
116  //}
117 
118  // log10 functions
119  template< class T >
120  inline T log10(T number) {
121  return ::log10(number);
122  }
123 
124  // pow functions
125  //template< class T1, class T2 >
126  //inline T1 pow(T1 number1, T2 number2) {
127  // return ::pow(number1, number2);
128  //}
129 
130  // sin functions
131  template< class T >
132  inline T sin(T number) {
133  return ::sin(number);
134  }
135 
136  // sinh functions
137  template< class T >
138  inline T sinh(T number) {
139  return ::sinh(number);
140  }
141 
142  // tan functions
143  template< class T >
144  inline T tan(T number) {
145  return ::tan(number);
146  }
147 
148  // tanh functions
149  template< class T >
150  inline T tanh(T number) {
151  return ::tanh(number);
152  }
153 
154  // sqrt functions
155  template< class T >
156  inline T sqrt(T number) {
157  return ::sqrt(number);
158  }
159 } // namespace std
160 
161 #endif // D0MATH
T cosh(T number)
Definition: d0nt_math.hpp:84
T1 fmod(T1 number1, T2 number2)
Definition: d0nt_math.hpp:102
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
T sqrt(T number)
Definition: d0nt_math.hpp:156
T acos(T number)
Definition: d0nt_math.hpp:54
float abs(float number)
Definition: d0nt_math.hpp:39
T atan(T number)
Definition: d0nt_math.hpp:66
T tanh(T number)
Definition: d0nt_math.hpp:150
T sin(T number)
Definition: d0nt_math.hpp:132
T log10(T number)
Definition: d0nt_math.hpp:120
T sinh(T number)
Definition: d0nt_math.hpp:138
T cos(T number)
Definition: d0nt_math.hpp:78
double T
Definition: Xdiff_gwt.C:5
T tan(T number)
Definition: d0nt_math.hpp:144
T asin(T number)
Definition: d0nt_math.hpp:60
T atan2(T number)
Definition: d0nt_math.hpp:72
T labs(T number)
Definition: d0nt_math.hpp:108