18 #if defined(HLTCA_STANDALONE) 25 #include <xmmintrin.h> 35 static inline T
Min(
const T &x,
const T &y)
40 static inline T
Max(
const T &x,
const T &y)
45 static inline T
Sqrt(
const T &x)
50 static inline T
RSqrt(
const T &x)
56 static inline T
Abs(
const T &x)
61 static inline T
Log(
const T &x)
66 static inline T
Log10(
const T &x)
71 static inline T
Sin(
const T &x)
76 static inline T
Cos(
const T &x)
86 static T AtomicMax(T
volatile *addr, T val);
97 static T
Round(
const T &x);
104 template <
typename T>
105 static T
ATan2(
const T &y,
const T &x);
106 template <
typename T>
107 static T
ASin(
const T &x);
113 return 6.283185307179586f;
115 static inline float Pi()
117 return 3.1415926535897f;
122 int AtomicExch(
int volatile *addr,
int val);
123 int AtomicAdd(
int volatile *addr,
int val);
124 int AtomicMin(
int volatile *addr,
int val);
128 #if defined(HLTCA_STANDALONE) 129 #define choice(c1, c2, c3) c2 131 #define choice(c1, c2, c3) c3 150 inline float RSqrt<float>(
const float &x)
154 asm(
"rsqrtss %0,%1\n\t" 156 :
"+m"(r),
"=x"(tmp));
166 "add $0x1fc00000,%0\n\t" 174 #if defined(HLTCA_STANDALONE) 178 if (x + 0.5
f ==
float(i) && i & 1)
182 if (x - 0.5
f ==
float(i) && i & 1)
195 return choice(1, x < std::numeric_limits<float>::infinity() && -x < std::numeric_limits<float>::infinity(),
TMath::Finite(x));
201 return static_cast<float>(
Nint(x));
211 inline float ASin(
const float &x)
221 return (y >= 0) ? x : -x;
231 #include <tbb/atomic.h> 233 inline int CAMath::AtomicExch(
int volatile *addr,
int val)
235 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
236 return a.fetch_and_store(val);
239 inline int CAMath::AtomicAdd(
int volatile *addr,
int val)
241 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
242 return a.fetch_and_add(val);
247 inline int AtomicMax<int>(
int volatile *addr,
int val)
249 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
252 while (old != a.compare_and_swap(val, old)) {
263 inline unsigned int AtomicMax<unsigned int>(
unsigned int volatile *addr,
unsigned int val)
265 tbb::atomic<unsigned int> &a = *
reinterpret_cast<tbb::atomic<unsigned int> *
>(
const_cast<unsigned int *
>(addr));
266 unsigned int old = a;
268 while (old != a.compare_and_swap(val, old)) {
279 inline int CAMath::AtomicMin(
int volatile *addr,
int val)
281 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
284 while (old != a.compare_and_swap(val, old)) {
static T ASin(const T &x)
friend F32vec4 cos(const F32vec4 &a)
float Round< float >(const float &x)
#define choice(c1, c2, c3)
friend F32vec4 sqrt(const F32vec4 &a)
static T Sqrt(const T &x)
static T ApproxSqrt(const T &x)
friend F32vec4 sin(const F32vec4 &a)
float ASin(const float &x)
friend F32vec4 log(const F32vec4 &a)
static T Round(const T &x)
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
static T Log10(const T &x)
float Copysign(float x, float y)
static T RSqrt(const T &x)
bool Finite< float >(const float &x)
static T Min(const T &x, const T &y)
static T ATan2(const T &y, const T &x)
static T Reciprocal(const T &x)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
float ATan2< float >(const float &y, const float &x)
double Reciprocal< double >(const double &x)
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
static T Max(const T &x, const T &y)
float Reciprocal< float >(const float &x)
static FiniteReturnTypeHelper< T >::R Finite(const T &x)
float ApproxSqrt< float >(const float &x)
static T Recip(const T &x)