diff --git a/src/phasicFlow/commandLine/CLI/Validators.hpp b/src/phasicFlow/commandLine/CLI/Validators.hpp index 03eb77b6..ffddd84b 100644 --- a/src/phasicFlow/commandLine/CLI/Validators.hpp +++ b/src/phasicFlow/commandLine/CLI/Validators.hpp @@ -11,7 +11,7 @@ #include "TypeTools.hpp" // [CLI11:public_includes:set] -#include +#include "math.hpp" #include #include #include diff --git a/src/phasicFlow/types/basicTypes/math.hpp b/src/phasicFlow/types/basicTypes/math.hpp index cd61e2d3..29482eae 100755 --- a/src/phasicFlow/types/basicTypes/math.hpp +++ b/src/phasicFlow/types/basicTypes/math.hpp @@ -21,16 +21,16 @@ Licence: #ifndef __math_hpp__ #define __math_hpp__ -#include - -#include "pFlowMacros.hpp" -#include "builtinTypes.hpp" - #ifdef __CUDACC__ #include "math.h" +#else +#include #endif +#include "pFlowMacros.hpp" +#include "builtinTypes.hpp" + //* * * * * * * * * * * List of functinos * * * * * * * * // @@ -44,7 +44,8 @@ namespace pFlow { -INLINE_FUNCTION_HD real abs(real x) +INLINE_FUNCTION_HD +real abs(real x) { #ifdef __CUDACC__ return ::fabs(x); @@ -53,24 +54,20 @@ INLINE_FUNCTION_HD real abs(real x) #endif } - -INLINE_FUNCTION_HD int64 abs(int64 x) -{ -#ifdef __CUDACC__ - return ::abs(x); -#else - return std::abs(x); +#ifndef __CUDACC__ + INLINE_FUNCTION_HD + int64 abs(int64 x) + { + return std::abs(x); + } #endif -} +#ifndef __CUDACC__ INLINE_FUNCTION_HD int32 abs(int32 x) { -#ifdef __CUDACC__ - return ::abs(x); -#else return std::abs(x); -#endif } +#endif INLINE_FUNCTION_HD real mod(real x, real y) @@ -102,163 +99,132 @@ INLINE_FUNCTION_HD auto mod(uint32 x, uint32 y) return x%y; } +#ifndef __CUDACC__ INLINE_FUNCTION_HD real remainder(real x, real y) { -#ifdef __CUDACC__ - return ::remainder(x,y); -#else return std::remainder(x,y); -#endif } +#endif -INLINE_FUNCTION_HD real exp(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_H +real exp(real x) { -#ifdef __CUDACC__ - return ::exp(x); -#else return std::exp(x); -#endif } +#endif -INLINE_FUNCTION_HD real log(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real log(real x) { -#ifdef __CUDACC__ - return ::log(x); -#else return std::log(x); -#endif } +#endif -INLINE_FUNCTION_HD real log10(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real log10(real x) { -#ifdef __CUDACC__ - return ::log10(x); -#else return std::log10(x); -#endif } +#endif -INLINE_FUNCTION_HD real pow(real x, real y) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real pow(real x, real y) { -#ifdef __CUDACC__ - return ::pow(x, y); -#else return std::pow(x, y); +} #endif -} - - -INLINE_FUNCTION_HD real sqrt(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real sqrt(real x) { -#ifdef __CUDACC__ - return ::sqrt(x); -#else return std::sqrt(x); -#endif } +#endif - -INLINE_FUNCTION_HD real cbrt (real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real cbrt (real x) { -#ifdef __CUDACC__ - return ::cbrt (x); -#else return std::cbrt (x); -#endif } +#endif - -INLINE_FUNCTION_HD real sin(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real sin(real x) { -#ifdef __CUDACC__ - return ::sin(x); -#else return std::sin(x); -#endif } +#endif - -INLINE_FUNCTION_HD real cos(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real cos(real x) { -#ifdef __CUDACC__ - return ::cos(x); -#else return std::cos(x); -#endif } +#endif - -INLINE_FUNCTION_HD real tan(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real tan(real x) { -#ifdef __CUDACC__ - return ::tan(x); -#else return std::tan(x); -#endif } +#endif -INLINE_FUNCTION_HD real asin(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real asin(real x) { -#ifdef __CUDACC__ - return ::asin(x); -#else return std::asin(x); -#endif - } +#endif - -INLINE_FUNCTION_HD real acos(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real acos(real x) { -#ifdef __CUDACC__ - return ::acos(x); -#else return std::acos(x); -#endif } +#endif - -INLINE_FUNCTION_HD real atan(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real atan(real x) { -#ifdef __CUDACC__ - return ::atan(x); -#else return std::atan(x); +} #endif -} - - -INLINE_FUNCTION_HD real atan2(real y, real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD real +atan2(real y, real x) { -#ifdef __CUDACC__ - return ::atan2(y, x); -#else return std::atan2(y, x); -#endif } +#endif - -INLINE_FUNCTION_HD real sinh(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real sinh(real x) { -#ifdef __CUDACC__ - return ::sinh(x); -#else return std::sinh(x); -#endif } +#endif - -INLINE_FUNCTION_HD real cosh(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real cosh(real x) { -#ifdef __CUDACC__ - return ::cosh(x); -#else return std::cosh(x); -#endif } - +#endif INLINE_FUNCTION_HD real tanh(real x) { @@ -287,14 +253,14 @@ INLINE_FUNCTION_HD real acosh(real x) #endif } -INLINE_FUNCTION_HD real atanh(real x) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +real atanh(real x) { -#ifdef __CUDACC__ - return ::atanh(x); -#else return std::atanh(x); -#endif } +#endif + INLINE_FUNCTION_HD real min(real x, real y) { @@ -305,43 +271,36 @@ INLINE_FUNCTION_HD real min(real x, real y) #endif } -INLINE_FUNCTION_HD int64 min(int32 x, int32 y) +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +int64 min(int32 x, int32 y) { -#ifdef __CUDACC__ - return ::min(x, y); -#else return std::min(x, y); -#endif } - -INLINE_FUNCTION_HD int64 min(int64 x, int64 y) -{ -#ifdef __CUDACC__ - return ::min(x, y); -#else - return std::min(x, y); -#endif -} - -INLINE_FUNCTION_HD uint64 min(uint64 x, uint64 y) -{ -#ifdef __CUDACC__ - return ::min(x, y); -#else - return std::min(x, y); #endif +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +int64 min(int64 x, int64 y) +{ + return std::min(x, y); } +#endif +#ifndef __CUDACC__ +INLINE_FUNCTION_HD +uint64 min(uint64 x, uint64 y) +{ + return std::min(x, y); +} +#endif + +#ifndef __CUDACC__ INLINE_FUNCTION_HD uint32 min(uint32 x, uint32 y) { -#ifdef __CUDACC__ - return ::min(x, y); -#else return std::min(x, y); -#endif } - +#endif INLINE_FUNCTION_HD real max(real x, real y) @@ -353,42 +312,34 @@ INLINE_FUNCTION_HD real max(real x, real y) #endif } + +#ifndef __CUDACC__ INLINE_FUNCTION_HD int64 max(int64 x, int64 y) { -#ifdef __CUDACC__ - return ::max(x, y); -#else return std::max(x, y); -#endif } +#endif +#ifndef __CUDACC__ INLINE_FUNCTION_HD int32 max(int32 x, int32 y) { -#ifdef __CUDACC__ - return ::max(x, y); -#else return std::max(x, y); -#endif } +#endif +#ifndef __CUDACC__ INLINE_FUNCTION_HD uint64 max(uint64 x, uint64 y) { -#ifdef __CUDACC__ - return ::max(x, y); -#else return std::max(x, y); -#endif } +#endif - +#ifndef __CUDACC__ INLINE_FUNCTION_HD uint32 max(uint32 x, uint32 y) { -#ifdef __CUDACC__ - return ::max(x, y); -#else return std::max(x, y); -#endif } +#endif } // pFlow diff --git a/src/phasicFlow/types/triple/tripleMath.hpp b/src/phasicFlow/types/triple/tripleMath.hpp index 00566ed3..dc016739 100644 --- a/src/phasicFlow/types/triple/tripleMath.hpp +++ b/src/phasicFlow/types/triple/tripleMath.hpp @@ -18,18 +18,22 @@ Licence: -----------------------------------------------------------------------------*/ +namespace pFlow + +{ + #define T3Func(fnName) \ template \ -INLINE_FUNCTION_HD pFlow::triple pFlow::fnName(const pFlow::triple& v) \ +INLINE_FUNCTION_HD triple fnName(const triple& v) \ { \ - return pFlow::triple(fnName(v.x_), fnName(v.y_), fnName(v.z_)); \ + return triple(fnName(v.x_), fnName(v.y_), fnName(v.z_)); \ } #define T3Func2(fnName) \ template \ -INLINE_FUNCTION_HD pFlow::triple pFlow::fnName(const pFlow::triple& arg1, const pFlow::triple& arg2) \ +INLINE_FUNCTION_HD triple fnName(const triple& arg1, const triple& arg2) \ { \ - return pFlow::triple(fnName(arg1.x_, arg2.x_), fnName(arg1.y_,arg2.y_), fnName(arg1.z_, arg2.z_)); \ + return triple(fnName(arg1.x_, arg2.x_), fnName(arg1.y_,arg2.y_), fnName(arg1.z_, arg2.z_)); \ } //* * * * * * * * * * * List of functinos * * * * * * * * // @@ -68,21 +72,21 @@ T3Func2(max); // elements of t3 raised by e template -INLINE_FUNCTION_HD pFlow::triple pFlow::pow(const pFlow::triple& t3, T e) +INLINE_FUNCTION_HD triple pow(const triple& t3, T e) { - return pFlow::triple( pow(t3.x_, e), pow(t3.y_,e), pow(t3.z_,e)); + return triple( pow(t3.x_, e), pow(t3.y_,e), pow(t3.z_,e)); } // return the min of 3 elements x, y, z template -INLINE_FUNCTION_HD T pFlow::min(const pFlow::triple& t3) +INLINE_FUNCTION_HD T min(const triple& t3) { return min( min(t3.x_, t3.y_), t3.z_); } // return the max of 3 elements x, y, z template -INLINE_FUNCTION_HD T pFlow::max(const pFlow::triple& t3) +INLINE_FUNCTION_HD T max(const triple& t3) { return max( max(t3.x_, t3.y_), t3.z_); } @@ -90,4 +94,6 @@ INLINE_FUNCTION_HD T pFlow::max(const pFlow::triple& t3) #undef T3Func -#undef T3Func2 \ No newline at end of file +#undef T3Func2 + +} diff --git a/src/phasicFlow/types/types.hpp b/src/phasicFlow/types/types.hpp index 7025b734..924e41cc 100644 --- a/src/phasicFlow/types/types.hpp +++ b/src/phasicFlow/types/types.hpp @@ -50,6 +50,8 @@ using realx3x3 = triple; using realx4 = quadruple; +using realx4x3 = quadruple; + template<> inline word basicTypeName(){ return "int8x3"; } @@ -85,6 +87,8 @@ inline word basicTypeName(){ return "realx3x3"; } template<> inline word basicTypeName(){ return "realx4"; } +template<> +inline word basicTypeName(){ return "realx4x3"; } extern const realx3 zero3; extern const realx3 one3;