HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_MathCbrt.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_MathCbrt.h (SYS Library, C++)
7  *
8  * COMMENTS: This is taken out of SYS_Math.h to avoid including > 1200 boost
9  * header files.
10  */
11 
12 #ifndef __SYS_MATHCBRT_H_INCLUDED__
13 #define __SYS_MATHCBRT_H_INCLUDED__
14 
15 #include "SYS_Types.h"
16 #include "SYS_MathLib.h"
17 
18 #if defined(SYS_MATHLIB_COREMATH)
19 
20 extern "C"
21 {
22 // Windows already has these symbols defined in corecrt_math.h
23 #if !defined(WIN32)
24  float cbrtf(float x); double cbrt(double x);
25 #endif
26 }
27 
28 static inline fpreal32 SYScbrt(const fpreal32 x)
29  { return ::cbrtf(x); }
30 static inline fpreal64 SYScbrt(const fpreal64 x)
31  { return ::cbrt(x); }
32 static inline fpreal64 SYScbrt(const int32 x)
33  { return ::cbrt((fpreal64)x); }
34 static inline fpreal64 SYScbrt(const int64 x)
35  { return ::cbrt((fpreal64)x); }
36 
37 #else // !defined(SYS_MATHLIB_COREMATH)
38 
39 #include <hboost/math/special_functions/cbrt.hpp>
40 #include <hboost/math/policies/policy.hpp>
41 
42 // This policy is used instead of the default error-handling policy for
43 // the cube root function SYScbrt.
44 // This is needed to ensure that no exceptions are thrown.
45 namespace SYS_MathCBRT
46 {
47  typedef hboost::math::policies::policy<
48  hboost::math::policies::domain_error<hboost::math::policies::ignore_error>,
49  hboost::math::policies::pole_error<hboost::math::policies::ignore_error>,
50  hboost::math::policies::overflow_error<hboost::math::policies::ignore_error>,
51  hboost::math::policies::underflow_error<hboost::math::policies::ignore_error>,
52  hboost::math::policies::denorm_error<hboost::math::policies::ignore_error>,
53  hboost::math::policies::rounding_error<hboost::math::policies::ignore_error>,
54  hboost::math::policies::evaluation_error<hboost::math::policies::ignore_error>,
55  hboost::math::policies::indeterminate_result_error<hboost::math::policies::ignore_error>
56  > policy;
57 }
58 
59 // Use the same cbrt() implementation on all platforms, and never use
60 // pow(x,1.0/3.0)!
61 static inline fpreal32 SYScbrt(const fpreal32 x)
62  { return hboost::math::cbrt(x, SYS_MathCBRT::policy()); }
63 static inline fpreal64 SYScbrt(const fpreal64 x)
64  { return hboost::math::cbrt(x, SYS_MathCBRT::policy()); }
65 static inline fpreal64 SYScbrt(const int32 x)
66  { return hboost::math::cbrt(fpreal64(x), SYS_MathCBRT::policy()); }
67 static inline fpreal64 SYScbrt(const int64 x)
68  { return hboost::math::cbrt(fpreal64(x), SYS_MathCBRT::policy()); }
69 
70 #endif
71 
72 #endif // __SYS_MATHCBRT_H_INCLUDED__
int int32
Definition: SYS_Types.h:39
float fpreal32
Definition: SYS_Types.h:200
float cbrtf(float x)
double fpreal64
Definition: SYS_Types.h:201
long long int64
Definition: SYS_Types.h:116
GLint GLenum GLint x
Definition: glcorearb.h:409
double cbrt(double x)