18 #if defined(HLTCA_STANDALONE)
25 #include <xmmintrin.h>
35 template<
typename T>
static inline T Min (
const T &
x,
const T &
y ) {
return std::min( x, y ); }
36 template<
typename T>
static inline T Max (
const T &
x,
const T &
y ) {
return std::max( x, y ); }
38 template<
typename T>
static inline T RSqrt(
const T &
x ) {
const T one =
T(1.
f);
return one /
std::sqrt( x ); }
39 template<
typename T>
static inline T Abs (
const T &
x ) {
return std::abs( x ); }
40 template<
typename T>
static inline T Log (
const T &
x ) {
return std::log( x ); }
41 template<
typename T>
static inline T Log10(
const T &
x ) {
return std::log10( x ); }
42 template<
typename T>
static inline T Sin (
const T &
x ) {
return std::sin( x ); }
43 template<
typename T>
static inline T Cos (
const T &
x ) {
return std::cos( x ); }
47 template<
typename T>
static T AtomicMax(
T volatile *addr,
T val );
53 template<
typename T>
static T Round(
const T &
x );
55 template<
typename T>
static inline T Recip(
const T &
x ) {
return T( 1 ) /
x; }
56 template<
typename T>
static T ATan2(
const T &
y,
const T &
x );
57 template<
typename T>
static T ASin(
const T &
x );
61 static inline float TwoPi() {
return 6.283185307179586f; }
62 static inline float Pi() {
return 3.1415926535897f; }
66 int AtomicExch(
int volatile *addr,
int val );
67 int AtomicAdd (
int volatile *addr,
int val );
68 int AtomicMin (
int volatile *addr,
int val );
72 #if defined( HLTCA_STANDALONE )
73 #define choice(c1,c2,c3) c2
75 #define choice(c1,c2,c3) c3
92 template<>
inline float RSqrt<float>(
const float &
x )
99 :
"+m"(
r ),
"=x"( tmp )
110 "add $0x1fc00000,%0\n\t"
119 #if defined(HLTCA_STANDALONE)
123 if ( x + 0.5
f ==
float( i ) && i & 1 ) i--;
126 if ( x - 0.5
f ==
float( i ) && i & 1 ) i++;
139 x < std::numeric_limits<float>::infinity() && -
x < std::numeric_limits<float>::infinity(),
150 template<>
inline float ASin(
const float &
x )
161 return ( y >= 0 ) ? x : -
x;
172 #include <tbb/atomic.h>
174 inline int CAMath::AtomicExch(
int volatile *addr,
int val )
176 tbb::atomic<int> &
a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>( addr ) );
177 return a.fetch_and_store(
val );
180 inline int CAMath::AtomicAdd (
int volatile *addr,
int val )
182 tbb::atomic<int> &
a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>( addr ) );
183 return a.fetch_and_add(
val );
188 template<>
inline int AtomicMax<int>(
int volatile *addr,
int val )
190 tbb::atomic<int> &
a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>( addr ) );
193 while ( old !=
a.compare_and_swap(
val, old ) ) {
203 template<>
inline unsigned int AtomicMax<unsigned int>(
unsigned int volatile *addr,
unsigned int val )
205 tbb::atomic<unsigned int> &
a = *
reinterpret_cast<tbb::atomic<unsigned int> *
>(
const_cast<unsigned int *
>( addr ) );
206 unsigned int old =
a;
208 while ( old !=
a.compare_and_swap(
val, old ) ) {
219 inline int CAMath::AtomicMin (
int volatile *addr,
int val )
221 tbb::atomic<int> &
a = *
reinterpret_cast<tbb::atomic<int> *
>(
const_cast<int *
>( addr ) );
224 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)
Double_t val[nBoxes][nFEBox]
static T Sqrt(const T &x)
static T ApproxSqrt(const T &x)
friend F32vec4 sin(const F32vec4 &a)
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)