30 #if defined(HLTCA_STANDALONE) 37 #include <xmmintrin.h> 47 static inline T
Min(
const T &x,
const T &y)
52 static inline T
Max(
const T &x,
const T &y)
57 static inline T
Sqrt(
const T &x)
62 static inline T
RSqrt(
const T &x)
68 static inline T
Abs(
const T &x)
73 static inline T
Log(
const T &x)
78 static inline T
Log10(
const T &x)
83 static inline T
Sin(
const T &x)
88 static inline T
Cos(
const T &x)
98 static T AtomicMax(T
volatile *addr, T val);
101 template <
typename T>
105 template <
typename T>
108 template <
typename T>
109 static T
Round(
const T &x);
111 template <
typename T>
116 template <
typename T>
117 static T
ATan2(
const T &y,
const T &x);
118 template <
typename T>
119 static T
ASin(
const T &x);
125 return 6.283185307179586f;
127 static inline float Pi()
129 return 3.1415926535897f;
134 int AtomicExch(
int volatile *addr,
int val);
135 int AtomicAdd(
int volatile *addr,
int val);
136 int AtomicMin(
int volatile *addr,
int val);
140 #if defined(HLTCA_STANDALONE) 141 #define choice(c1, c2, c3) c2 143 #define choice(c1, c2, c3) c3 162 inline float RSqrt<float>(
const float &x)
166 asm(
"rsqrtss %0,%1\n\t" 168 :
"+m"(r),
"=x"(tmp));
178 "add $0x1fc00000,%0\n\t" 186 #if defined(HLTCA_STANDALONE) 190 if (x + 0.5
f ==
float(i) && i & 1)
194 if (x - 0.5
f ==
float(i) && i & 1)
207 return choice(1, x < std::numeric_limits<float>::infinity() && -x < std::numeric_limits<float>::infinity(),
TMath::Finite(x));
213 return static_cast<float>(
Nint(x));
223 inline float ASin(
const float &x)
233 return (y >= 0) ? x : -x;
243 #include <tbb/atomic.h> 245 inline int CAMath::AtomicExch(
int volatile *addr,
int val)
247 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
248 return a.fetch_and_store(val);
251 inline int CAMath::AtomicAdd(
int volatile *addr,
int val)
253 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
254 return a.fetch_and_add(val);
259 inline int AtomicMax<int>(
int volatile *addr,
int val)
261 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
264 while (old != a.compare_and_swap(val, old)) {
275 inline unsigned int AtomicMax<unsigned int>(
unsigned int volatile *addr,
unsigned int val)
277 tbb::atomic<unsigned int> &a = *
reinterpret_cast<tbb::atomic<unsigned int> *
>(
const_cast<unsigned int *
>(addr));
278 unsigned int old = a;
280 while (old != a.compare_and_swap(val, old)) {
291 inline int CAMath::AtomicMin(
int volatile *addr,
int val)
293 tbb::atomic<int> &a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>(addr));
296 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)