24 #ifndef PXR_BASE_ARCH_MATH_H 25 #define PXR_BASE_ARCH_MATH_H 32 #include "pxr/base/arch/defines.h" 35 #if defined(ARCH_COMPILER_MSVC) 41 #define M_PI 3.14159265358979323846 44 PXR_NAMESPACE_OPEN_SCOPE
49 #if defined (ARCH_CPU_INTEL) || defined (ARCH_CPU_ARM) || defined (doxygen) 53 #define ARCH_MIN_FLOAT_EPS_SQR 0.000244141F 57 return (val > 0) - (val < 0);
101 return value._double;
105 #error Unknown system architecture. 108 #if defined(ARCH_OS_LINUX) || defined(doxygen) 111 inline void ArchSinCosf(
float v,
float *s,
float *c) { sincosf(v, s, c); }
114 inline void ArchSinCos(
double v,
double *s,
double *c) { sincos(v, s, c); }
116 #elif defined(ARCH_OS_DARWIN) || defined(ARCH_OS_WINDOWS) 118 inline void ArchSinCosf(
float v,
float *s,
float *c) {
122 inline void ArchSinCos(
double v,
double *s,
double *c) {
128 #error Unknown architecture. 137 #if defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG) 138 return __builtin_ctzl(x);
139 #elif defined(ARCH_COMPILER_MSVC) 141 _BitScanForward64(&index, x);
145 x = (x ^ (x - 1)) >> 1;
157 PXR_NAMESPACE_CLOSE_SCOPE
159 #endif // PXR_BASE_ARCH_MATH_H double ArchBitPatternToDouble(uint64_t v)
Returns The double precision floating point value corresponding to the given IEEE-754 bit pattern.
int ArchCountTrailingZeros(uint64_t x)
Return the number of consecutive 0-bits in x starting from the least significant bit position.
float ArchBitPatternToFloat(uint32_t v)
Returns The single precision floating point value corresponding to the given IEEE-754 bit pattern.
uint64_t ArchDoubleToBitPattern(double v)
Returns The IEEE-754 bit pattern of the specified double precision value as a 64-bit unsigned integer...
void ArchSinCosf(float v, float *s, float *c)
Computes the sine and cosine of the specified value as a float.
long ArchSign(long val)
Three-valued sign. Return 1 if val > 0, 0 if val == 0, or -1 if val < 0.
uint32_t ArchFloatToBitPattern(float v)
Returns The IEEE-754 bit pattern of the specified single precision value as a 32-bit unsigned integer...
void ArchSinCos(double v, double *s, double *c)
Computes the sine and cosine of the specified value as a double.