7#ifndef PXR_BASE_ARCH_MATH_H
8#define PXR_BASE_ARCH_MATH_H
15#include "pxr/base/arch/defines.h"
18#if defined(ARCH_COMPILER_MSVC)
24#define M_PI 3.14159265358979323846
27PXR_NAMESPACE_OPEN_SCOPE
32#if defined (ARCH_CPU_INTEL) || defined (ARCH_CPU_ARM) || defined (doxygen)
36#define ARCH_MIN_FLOAT_EPS_SQR 0.000244141F
40 return (val > 0) - (val < 0);
88#error Unknown system architecture.
91#if defined(ARCH_OS_LINUX) || defined(doxygen)
94inline void ArchSinCosf(
float v,
float *s,
float *c) { sincosf(v, s, c); }
97inline void ArchSinCos(
double v,
double *s,
double *c) { sincos(v, s, c); }
99#elif defined(ARCH_OS_DARWIN) || defined(ARCH_OS_WINDOWS)
101inline void ArchSinCosf(
float v,
float *s,
float *c) {
105inline void ArchSinCos(
double v,
double *s,
double *c) {
111#error Unknown architecture.
120#if defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG)
121 return __builtin_ctzl(x);
122#elif defined(ARCH_COMPILER_MSVC)
124 _BitScanForward64(&index, x);
128 x = (x ^ (x - 1)) >> 1;
140PXR_NAMESPACE_CLOSE_SCOPE
void ArchSinCos(double v, double *s, double *c)
Computes the sine and cosine of the specified value as a double.
long ArchSign(long val)
Three-valued sign. Return 1 if val > 0, 0 if val == 0, or -1 if val < 0.
void ArchSinCosf(float v, float *s, float *c)
Computes the sine and cosine of the specified value as a float.
uint32_t ArchFloatToBitPattern(float v)
Returns The IEEE-754 bit pattern of the specified single precision value as a 32-bit unsigned integer...
uint64_t ArchDoubleToBitPattern(double v)
Returns The IEEE-754 bit pattern of the specified double precision value as a 64-bit unsigned integer...
float ArchBitPatternToFloat(uint32_t v)
Returns The single 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.
double ArchBitPatternToDouble(uint64_t v)
Returns The double precision floating point value corresponding to the given IEEE-754 bit pattern.