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) || \
33 defined(ARCH_OS_WASM_VM) || defined (doxygen)
37#define ARCH_MIN_FLOAT_EPS_SQR 0.000244141F
41 return (val > 0) - (val < 0);
89#error Unknown system architecture.
92#if defined(ARCH_OS_LINUX) || defined(doxygen)
95inline void ArchSinCosf(
float v,
float *s,
float *c) { sincosf(v, s, c); }
98inline void ArchSinCos(
double v,
double *s,
double *c) { sincos(v, s, c); }
100#elif defined(ARCH_OS_DARWIN) || defined(ARCH_OS_WINDOWS) || \
101 defined(ARCH_OS_WASM_VM)
103inline void ArchSinCosf(
float v,
float *s,
float *c) {
107inline void ArchSinCos(
double v,
double *s,
double *c) {
113#error Unknown architecture.
122#if defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG) && \
123 !defined(ARCH_OS_WASM_VM)
124 return __builtin_ctzl(x);
125#elif defined(ARCH_COMPILER_MSVC)
127 _BitScanForward64(&index, x);
131 x = (x ^ (x - 1)) >> 1;
143PXR_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.