www.cemf.ir
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 
25 #include "builtinTypes.hpp"
26 #include "pFlowMacros.hpp"
27 
28 #ifdef __CUDACC__
29 #include "math.h"
30 #else
31 #include <cmath>
32 #endif
33 
34 //* * * * * * * * * * * List of functinos * * * * * * * * //
35 // abs, mod, exp, log, log10, pow, sqrt, cbrt
36 // sin, cos, tan, asin, acos, atan, atan2
37 // sinh, cosh, tanh, asinh, acosh, atanh
38 // min, max
39 //* * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace pFlow
42 {
43 
45 real
47 {
48 #ifdef __CUDACC__
49  return ::fabs(x);
50 #else
51  return std::fabs(x);
52 #endif
53 }
54 
56 int64
58 {
59 #ifdef __CUDACC__
60  return ::abs(x);
61 #else
62  return std::abs(x);
63 #endif
64 }
65 
68 {
69 #ifdef __CUDACC__
70  return ::abs(x);
71 #else
72  return std::abs(x);
73 #endif
74 }
75 
77 mod(real x, real y)
78 {
79 #ifdef __CUDACC__
80  return ::fmod(x, y);
81 #else
82  return std::fmod(x, y);
83 #endif
84 }
85 
86 
89 {
90  return x % y;
91 }
92 
95 {
96  return x % y;
97 }
98 
101 {
102  return x % y;
103 }
104 
107 {
108  return x % y;
109 }
110 
113 {
114 #ifdef __CUDACC__
115  return ::remainder(x,y);
116 #else
117  return std::remainder(x, y);
118 #endif
119 }
120 
121 
123 real
125 {
126 #ifdef __CUDACC__
127  return ::exp(x);
128 #else
129  return std::exp(x);
130 #endif
131 }
132 
133 
135 real
137 {
138 #ifdef __CUDACC__
139  return ::log(x);
140 #else
141  return std::log(x);
142 #endif
143 }
144 
145 
147 real
149 {
150 #ifdef __CUDACC__
151  return ::log10(x);
152 #else
153  return std::log10(x);
154 #endif
155 }
156 
158 real
159 pow(real x, real y)
160 {
161 #ifdef __CUDACC__
162  return ::pow(x,y);
163 #else
164  return std::pow(x, y);
165 #endif
166 }
167 
168 
170 real
172 {
173 #ifdef __CUDACC__
174  return ::sqrt(x);
175 #else
176  return std::sqrt(x);
177 #endif
178 }
179 
180 
181 
183 real
185 {
186 #ifdef __CUDACC__
187  return ::cbrt(x);
188 #else
189  return std::cbrt(x);
190 #endif
191 }
192 
194 real
196 {
197 #ifdef __CUDACC__
198  return ::sin(x);
199 #else
200  return std::sin(x);
201 #endif
202 }
203 
205 real
207 {
208 #ifdef __CUDACC__
209  return ::cos(x);
210 #else
211  return std::cos(x);
212 #endif
213 }
214 
215 
216 
218 real
220 {
221 #ifdef __CUDACC__
222  return ::tan(x);
223 #else
224  return std::tan(x);
225 #endif
226 }
227 
229 real
231 {
232 #ifdef __CUDACC__
233  return ::asin(x);
234 #else
235  return std::asin(x);
236 #endif
237 }
238 
240 real
242 {
243 #ifdef __CUDACC__
244  return ::acos(x);
245 #else
246  return std::acos(x);
247 #endif
248 }
249 
251 real
253 {
254 #ifdef __CUDACC__
255  return ::atan(x);
256 #else
257  return std::atan(x);
258 #endif
259 }
260 
263 {
264 #ifdef __CUDACC__
265  return ::atan2(y,x);
266 #else
267  return std::atan2(y, x);
268 #endif
269 }
270 
272 real
274 {
275 #ifdef __CUDACC__
276  return ::sinh(x);
277 #else
278  return std::sinh(x);
279 #endif
280 }
281 
283 real
285 {
286 #ifdef __CUDACC__
287  return ::cosh(x);
288 #else
289  return std::cosh(x);
290 #endif
291 }
292 
293 
296 {
297 #ifdef __CUDACC__
298  return ::tanh(x);
299 #else
300  return std::tanh(x);
301 #endif
302 }
303 
306 {
307 #ifdef __CUDACC__
308  return ::asinh(x);
309 #else
310  return std::asinh(x);
311 #endif
312 }
313 
316 {
317 #ifdef __CUDACC__
318  return ::acosh(x);
319 #else
320  return std::acosh(x);
321 #endif
322 }
323 
325 real
327 {
328 #ifdef __CUDACC__
329  return ::atanh(x);
330 #else
331  return std::atanh(x);
332 #endif
333 }
334 
335 
337 min(real x, real y)
338 {
339 #ifdef __CUDACC__
340  return ::fmin(x, y);
341 #else
342  return std::fmin(x, y);
343 #endif
344 }
345 
347 int64
349 {
350 #ifdef __CUDACC__
351  return ::min(x,y);
352 #else
353  return std::min(x, y);
354 #endif
355 }
356 
357 
359 int64
361 {
362 #ifdef __CUDACC__
363  return ::min(x,y);
364 #else
365  return std::min(x, y);
366 #endif
367 }
368 
369 
370 
372 uint64
374 {
375 #ifdef __CUDACC__
376  return ::min(x,y);
377 #else
378  return std::min(x, y);
379 #endif
380 }
381 
382 
383 
386 {
387 #ifdef __CUDACC__
388  return ::min(x,y);
389 #else
390  return std::min(x, y);
391 #endif
392 }
393 
394 
396 max(real x, real y)
397 {
398 #ifdef __CUDACC__
399  return ::fmax(x, y);
400 #else
401  return std::fmax(x, y);
402 #endif
403 }
404 
407 {
408 #ifdef __CUDACC__
409  return ::max(x, y);
410 #else
411  return std::max(x, y);
412 #endif
413 }
414 
415 
416 
419 {
420 #ifdef __CUDACC__
421  return ::max(x, y);
422 #else
423  return std::max(x, y);
424 #endif
425 }
426 
429 {
430 #ifdef __CUDACC__
431  return ::max(x, y);
432 #else
433  return std::max(x, y);
434 #endif
435 }
436 
439 {
440 #ifdef __CUDACC__
441  return ::max(x, y);
442 #else
443  return std::max(x, y);
444 #endif
445 }
446 
447 
448 } // pFlow
449 
450 #endif // __math_hpp__
pFlow::atan
INLINE_FUNCTION_HD real atan(real x)
Definition: math.hpp:252
pFlow::exp
Vector< T, Allocator > exp(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:86
pFlow::atan
Vector< T, Allocator > atan(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:97
pFlow::asin
Vector< T, Allocator > asin(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:95
pFlow::cbrt
Vector< T, Allocator > cbrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:91
pFlow::sinh
Vector< T, Allocator > sinh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:99
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::atan2
INLINE_FUNCTION_HD real atan2(real y, real x)
Definition: math.hpp:262
pFlow::abs
INLINE_FUNCTION_HD int32 abs(int32 x)
Definition: math.hpp:67
pFlow::pow
Vector< T, Allocator > pow(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:89
pFlow::sqrt
Vector< T, Allocator > sqrt(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:90
pFlow::cosh
Vector< T, Allocator > cosh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:100
pFlow::atanh
INLINE_FUNCTION_HD real atanh(real x)
Definition: math.hpp:326
pFlow::cos
INLINE_FUNCTION_HD real cos(real x)
Definition: math.hpp:206
pFlow::cos
Vector< T, Allocator > cos(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:93
pFlow::sin
INLINE_FUNCTION_HD real sin(real x)
Definition: math.hpp:195
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::cosh
INLINE_FUNCTION_HD real cosh(real x)
Definition: math.hpp:284
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::asin
INLINE_FUNCTION_HD real asin(real x)
Definition: math.hpp:230
pFlow::log10
INLINE_FUNCTION_HD real log10(real x)
Definition: math.hpp:148
pFlow::log
INLINE_FUNCTION_HD real log(real x)
Definition: math.hpp:136
pFlow::min
INLINE_FUNCTION_HD uint32 min(uint32 x, uint32 y)
Definition: math.hpp:385
pFlow::tan
INLINE_FUNCTION_HD real tan(real x)
Definition: math.hpp:219
pFlow
Definition: demGeometry.hpp:27
pFlow::pow
INLINE_FUNCTION_HD real pow(real x, real y)
Definition: math.hpp:159
pFlow::asinh
Vector< T, Allocator > asinh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:102
pFlow::remainder
INLINE_FUNCTION_HD real remainder(real x, real y)
Definition: math.hpp:112
pFlow::log10
Vector< T, Allocator > log10(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:88
pFlow::sinh
INLINE_FUNCTION_HD real sinh(real x)
Definition: math.hpp:273
pFlowMacros.hpp
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::log
Vector< T, Allocator > log(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:87
pFlow::mod
Vector< T, Allocator > mod(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:85
pFlow::acos
INLINE_FUNCTION_HD real acos(real x)
Definition: math.hpp:241
pFlow::abs
Vector< T, Allocator > abs(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:84
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::tanh
INLINE_FUNCTION_HD real tanh(real x)
Definition: math.hpp:295
pFlow::exp
INLINE_FUNCTION_HD real exp(real x)
Definition: math.hpp:124
pFlow::asinh
INLINE_FUNCTION_HD real asinh(real x)
Definition: math.hpp:305
pFlow::sin
Vector< T, Allocator > sin(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:92
pFlow::atanh
Vector< T, Allocator > atanh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:104
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::acosh
INLINE_FUNCTION_HD real acosh(real x)
Definition: math.hpp:315
pFlow::tanh
Vector< T, Allocator > tanh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:101
builtinTypes.hpp
pFlow::atan2
Vector< T, Allocator > atan2(const Vector< T, Allocator > &v1, const Vector< T, Allocator > &v2)
Definition: VectorMath.hpp:98
pFlow::sqrt
INLINE_FUNCTION_HD real sqrt(real x)
Definition: math.hpp:171
pFlow::max
INLINE_FUNCTION_HD uint32 max(uint32 x, uint32 y)
Definition: math.hpp:438
pFlow::cbrt
INLINE_FUNCTION_HD real cbrt(real x)
Definition: math.hpp:184
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::tan
Vector< T, Allocator > tan(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:94
pFlow::acosh
Vector< T, Allocator > acosh(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:103
pFlow::acos
Vector< T, Allocator > acos(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:96