OpenMPCD
MathematicalFunctions.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Declares common mathematical functions.
4  */
5 
6 #ifndef OPENMPCD_UTILITY_MATHEMATICALFUNCTIONS_HPP
7 #define OPENMPCD_UTILITY_MATHEMATICALFUNCTIONS_HPP
8 
10 
11 namespace OpenMPCD
12 {
13 namespace Utility
14 {
15 
16 /**
17  * Defines common mathematical functions.
18  */
19 namespace MathematicalFunctions
20 {
21 
22 /**
23  * Returns the arc cosine of the argument.
24  *
25  * @tparam T The data type to use.
26  *
27  * @param[in] x The argument \f$ x \f$, which must be in the range
28  * \f$ \left[1, 1\right] \f$.
29  *
30  * @return Returns \f$ \arccos \left( x \right) \f$.
31  */
32 template<typename T>
34 T acos(const T x);
35 
36 /**
37  * Returns the cosine of the argument.
38  *
39  * @tparam T The data type to use.
40  *
41  * @param[in] x The argument \f$ x \f$.
42  *
43  * @return Returns \f$ \cos \left( x \right) \f$.
44  */
45 template<typename T>
47 T cos(const T x);
48 
49 /**
50  * Returns the cosine of the product of the argument and \f$ \pi \f$.
51  *
52  * @tparam T The data type to use.
53  *
54  * @param[in] x The argument \f$ x \f$.
55  *
56  * @return Returns \f$ \cos \left( \pi x \right) \f$.
57  */
58 template<typename T>
60 T cospi(const T x);
61 
62 /**
63  * Returns the sine of the argument.
64  *
65  * @tparam T The data type to use.
66  *
67  * @param[in] x The argument \f$ x \f$.
68  *
69  * @return Returns \f$ \sin \left( x \right) \f$.
70  */
71 template<typename T>
73 T sin(const T x);
74 
75 /**
76  * Returns the sine of the product of the argument and \f$ \pi \f$.
77  *
78  * @tparam T The data type to use.
79  *
80  * @param[in] x The argument \f$ x \f$.
81  *
82  * @return Returns \f$ \sin \left( \pi x \right) \f$.
83  */
84 template<typename T>
86 T sinpi(const T x);
87 
88 
89 /**
90  * Computes both the sine and the cosine of the argument.
91  *
92  * @throw OpenMPCD::NULLPointerException
93  * If `OPENMPCD_DEBUG` is defined, throws if `s == nullptr` or
94  * `c == nullptr`.
95  *
96  * @tparam T The data type to use.
97  *
98  * @param[in] x
99  * The argument \f$ x \f$.
100  * @param[out] s
101  * Where to store the sine of the argument,
102  * \f$ \sin \left( x \right) \f$. Must not be `nullptr`.
103  * @param[out] c
104  * Where to store the cosine of the argument,
105  * \f$ \cos \left( x \right) \f$. Must not be `nullptr`.
106  */
107 template<typename T>
109 void sincos(const T x, T* const s, T* const c);
110 
111 /**
112  * Computes both the sine and the cosine of the product of the argument and
113  * \f$ \pi \f$.
114  *
115  * @throw OpenMPCD::NULLPointerException
116  * If `OPENMPCD_DEBUG` is defined, throws if `s == nullptr` or
117  * `c == nullptr`.
118  *
119  * @tparam T The data type to use.
120  *
121  * @param[in] x
122  * The argument \f$ x \f$.
123  * @param[out] s
124  * Where to store the sine of the product of the argument and
125  * \f$ \pi \f$, \f$ \sin \left( x \pi \right) \f$.
126  * Must not be `nullptr`.
127  * @param[out] c
128  * Where to store the cosine of the product of the argument and
129  * \f$ \pi \f$, \f$ \cos \left( x \pi \right) \f$.
130  * Must not be `nullptr`.
131  */
132 template<typename T>
134 void sincospi(const T x, T* const s, T* const c);
135 
136 
137 /**
138  * Returns the sqaure root of the argument.
139  *
140  * @tparam T The data type to use.
141  *
142  * @param[in] x The argument \f$ x \f$.
143  *
144  * @return Returns \f$ \sqrt{ x } \f$.
145  */
146 template<typename T>
148 T sqrt(const T x);
149 
150 } //namespace MathematicalFunctions
151 } //namespace Utility
152 } //namespace OpenMPCD
153 
155 
156 #endif //OPENMPCD_UTILITY_MATHEMATICALFUNCTIONS_HPP
OpenMPCD::Utility::MathematicalFunctions::cos
OPENMPCD_CUDA_HOST_AND_DEVICE T cos(const T x)
Returns the cosine of the argument.
OpenMPCD::Utility::MathematicalFunctions::cospi
OPENMPCD_CUDA_HOST_AND_DEVICE T cospi(const T x)
Returns the cosine of the product of the argument and .
OpenMPCD::Utility::MathematicalFunctions::sincos
OPENMPCD_CUDA_HOST_AND_DEVICE void sincos(const T x, T *const s, T *const c)
Computes both the sine and the cosine of the argument.
OPENMPCD_CUDA_HOST_AND_DEVICE
#define OPENMPCD_CUDA_HOST_AND_DEVICE
Denotes a function to be callable both from the Host and from a CUDA Device.
Definition: Macros.hpp:15
MathematicalFunctions.hpp
OpenMPCD::Utility::MathematicalFunctions::sincospi
OPENMPCD_CUDA_HOST_AND_DEVICE void sincospi(const T x, T *const s, T *const c)
Computes both the sine and the cosine of the product of the argument and .
Macros.hpp
OpenMPCD::Utility::MathematicalFunctions::sqrt
OPENMPCD_CUDA_HOST_AND_DEVICE T sqrt(const T x)
Returns the sqaure root of the argument.
OpenMPCD::Utility::MathematicalFunctions::sinpi
OPENMPCD_CUDA_HOST_AND_DEVICE T sinpi(const T x)
Returns the sine of the product of the argument and .
OpenMPCD::Utility::MathematicalFunctions::acos
OPENMPCD_CUDA_HOST_AND_DEVICE T acos(const T x)
Returns the arc cosine of the argument.
OpenMPCD::Utility::MathematicalFunctions::sin
OPENMPCD_CUDA_HOST_AND_DEVICE T sin(const T x)
Returns the sine of the argument.