math.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __math_hpp__
22 #define __math_hpp__
23 
24 #include <cmath>
25 
26 #ifdef __CUDACC__
27 #include "math.h"
28 #endif
29 
30 #include "builtinTypes.hpp"
31 
32 //* * * * * * * * * * * List of functinos * * * * * * * * //
33 // abs, mod, exp, log, log10, pow, sqrt, cbrt
34 // sin, cos, tan, asin, acos, atan, atan2
35 // sinh, cosh, tanh, asinh, acosh, atanh
36 // min, max
37 //* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace pFlow
40 {
41 
42 
44 {
45 #ifdef __CUDACC__
46  return ::fabs(x);
47 #else
48  return std::fabs(x);
49 #endif
50 }
51 
52 
54 {
55 #ifdef __CUDACC__
56  return ::abs(x);
57 #else
58  return std::abs(x);
59 #endif
60 }
61 
63 {
64 #ifdef __CUDACC__
65  return ::abs(x);
66 #else
67  return std::abs(x);
68 #endif
69 }
70 
71 
73 {
74 #ifdef __CUDACC__
75  return ::fmod(x, y);
76 #else
77  return std::fmod(x, y);
78 #endif
79 }
80 
82 {
83  return x%y;
84 }
85 
87 {
88  return x%y;
89 }
90 
92 {
93  return x%y;
94 }
95 
97 {
98  return x%y;
99 }
100 
102 {
103 #ifdef __CUDACC__
104  return ::remainder(x,y);
105 #else
106  return std::remainder(x,y);
107 #endif
108 }
109 
111 {
112 #ifdef __CUDACC__
113  return ::exp(x);
114 #else
115  return std::exp(x);
116 #endif
117 }
118 
120 {
121 #ifdef __CUDACC__
122  return ::log(x);
123 #else
124  return std::log(x);
125 #endif
126 }
127 
129 {
130 #ifdef __CUDACC__
131  return ::log10(x);
132 #else
133  return std::log10(x);
134 #endif
135 }
136 
138 {
139 #ifdef __CUDACC__
140  return ::pow(x, y);
141 #else
142  return std::pow(x, y);
143 #endif
144 
145 }
146 
147 
149 {
150 #ifdef __CUDACC__
151  return ::sqrt(x);
152 #else
153  return std::sqrt(x);
154 #endif
155 }
156 
157 
159 {
160 #ifdef __CUDACC__
161  return ::cbrt (x);
162 #else
163  return std::cbrt (x);
164 #endif
165 }
166 
167 
169 {
170 #ifdef __CUDACC__
171  return ::sin(x);
172 #else
173  return std::sin(x);
174 #endif
175 }
176 
177 
179 {
180 #ifdef __CUDACC__
181  return ::cos(x);
182 #else
183  return std::cos(x);
184 #endif
185 }
186 
187 
189 {
190 #ifdef __CUDACC__
191  return ::tan(x);
192 #else
193  return std::tan(x);
194 #endif
195 }
196 
198 {
199 #ifdef __CUDACC__
200  return ::asin(x);
201 #else
202  return std::asin(x);
203 #endif
204 
205 }
206 
207 
209 {
210 #ifdef __CUDACC__
211  return ::acos(x);
212 #else
213  return std::acos(x);
214 #endif
215 }
216 
217 
219 {
220 #ifdef __CUDACC__
221  return ::atan(x);
222 #else
223  return std::atan(x);
224 #endif
225 
226 }
227 
228 
230 {
231 #ifdef __CUDACC__
232  return ::atan2(y, x);
233 #else
234  return std::atan2(y, x);
235 #endif
236 }
237 
238 
240 {
241 #ifdef __CUDACC__
242  return ::sinh(x);
243 #else
244  return std::sinh(x);
245 #endif
246 }
247 
248 
250 {
251 #ifdef __CUDACC__
252  return ::cosh(x);
253 #else
254  return std::cosh(x);
255 #endif
256 }
257 
258 
260 {
261 #ifdef __CUDACC__
262  return ::tanh(x);
263 #else
264  return std::tanh(x);
265 #endif
266 }
267 
269 {
270 #ifdef __CUDACC__
271  return ::asinh(x);
272 #else
273  return std::asinh(x);
274 #endif
275 }
276 
278 {
279 #ifdef __CUDACC__
280  return ::acosh(x);
281 #else
282  return std::acosh(x);
283 #endif
284 }
285 
287 {
288 #ifdef __CUDACC__
289  return ::atanh(x);
290 #else
291  return std::atanh(x);
292 #endif
293 }
294 
296 {
297 #ifdef __CUDACC__
298  return ::fmin(x,y);
299 #else
300  return std::fmin(x,y);
301 #endif
302 }
303 
305 {
306 #ifdef __CUDACC__
307  return ::min(x, y);
308 #else
309  return std::min(x, y);
310 #endif
311 }
312 
314 {
315 #ifdef __CUDACC__
316  return ::min(x, y);
317 #else
318  return std::min(x, y);
319 #endif
320 }
321 
323 {
324 #ifdef __CUDACC__
325  return ::min(x, y);
326 #else
327  return std::min(x, y);
328 #endif
329 
330 }
331 
333 {
334 #ifdef __CUDACC__
335  return ::min(x, y);
336 #else
337  return std::min(x, y);
338 #endif
339 }
340 
342 {
343 #ifdef __CUDACC__
344  return ::min(x, y);
345 #else
346  return std::min(x, y);
347 #endif
348 }
349 
351 {
352 #ifdef __CUDACC__
353  return ::fmax(x,y);
354 #else
355  return std::fmax(x,y);
356 #endif
357 }
358 
360 {
361 #ifdef __CUDACC__
362  return ::max(x, y);
363 #else
364  return std::max(x, y);
365 #endif
366 }
367 
369 {
370 #ifdef __CUDACC__
371  return ::max(x, y);
372 #else
373  return std::max(x, y);
374 #endif
375 }
376 
378 {
379 #ifdef __CUDACC__
380  return ::max(x, y);
381 #else
382  return std::max(x, y);
383 #endif
384 }
385 
386 
388 {
389 #ifdef __CUDACC__
390  return ::max(x, y);
391 #else
392  return std::max(x, y);
393 #endif
394 }
395 
397 {
398 #ifdef __CUDACC__
399  return ::max(x, y);
400 #else
401  return std::max(x, y);
402 #endif
403 
404 }
405 
406 } // pFlow
407 
408 
409 
410 #endif // __math_hpp__
pFlow::atan
INLINE_FUNCTION_HD real atan(real x)
Definition: math.hpp:218
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::atan2
INLINE_FUNCTION_HD real atan2(real y, real x)
Definition: math.hpp:229
pFlow::abs
INLINE_FUNCTION_HD int32 abs(int32 x)
Definition: math.hpp:62
pFlow::atanh
INLINE_FUNCTION_HD real atanh(real x)
Definition: math.hpp:286
pFlow::cos
INLINE_FUNCTION_HD real cos(real x)
Definition: math.hpp:178
pFlow::max
INLINE_FUNCTION_HD uint32 max(uint16 x, uint16 y)
Definition: math.hpp:396
pFlow::sin
INLINE_FUNCTION_HD real sin(real x)
Definition: math.hpp:168
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::cosh
INLINE_FUNCTION_HD real cosh(real x)
Definition: math.hpp:249
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::asin
INLINE_FUNCTION_HD real asin(real x)
Definition: math.hpp:197
pFlow::log10
INLINE_FUNCTION_HD real log10(real x)
Definition: math.hpp:128
pFlow::log
INLINE_FUNCTION_HD real log(real x)
Definition: math.hpp:119
pFlow::tan
INLINE_FUNCTION_HD real tan(real x)
Definition: math.hpp:188
pFlow
Definition: demComponent.hpp:28
pFlow::pow
INLINE_FUNCTION_HD real pow(real x, real y)
Definition: math.hpp:137
pFlow::remainder
INLINE_FUNCTION_HD real remainder(real x, real y)
Definition: math.hpp:101
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
pFlow::sinh
INLINE_FUNCTION_HD real sinh(real x)
Definition: math.hpp:239
pFlow::min
INLINE_FUNCTION_HD uint32 min(uint16 x, uint16 y)
Definition: math.hpp:341
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v, T e)
Definition: VectorMath.hpp:109
pFlow::abs
INLINE_FUNCTION_HD real abs(real x)
Definition: math.hpp:43
pFlow::acos
INLINE_FUNCTION_HD real acos(real x)
Definition: math.hpp:208
pFlow::mod
INLINE_FUNCTION_HD real mod(real x, real y)
Definition: math.hpp:72
pFlow::tanh
INLINE_FUNCTION_HD real tanh(real x)
Definition: math.hpp:259
pFlow::exp
INLINE_FUNCTION_HD real exp(real x)
Definition: math.hpp:110
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::asinh
INLINE_FUNCTION_HD real asinh(real x)
Definition: math.hpp:268
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::acosh
INLINE_FUNCTION_HD real acosh(real x)
Definition: math.hpp:277
builtinTypes.hpp
pFlow::sqrt
INLINE_FUNCTION_HD real sqrt(real x)
Definition: math.hpp:148
pFlow::cbrt
INLINE_FUNCTION_HD real cbrt(real x)
Definition: math.hpp:158
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138