PandaRoot
CAMath Namespace Reference

Classes

struct  FiniteReturnTypeHelper
 

Functions

template<typename T >
static T Min (const T &x, const T &y)
 
template<typename T >
static T Max (const T &x, const T &y)
 
template<typename T >
static T Sqrt (const T &x)
 
template<typename T >
static T RSqrt (const T &x)
 
template<typename T >
static T Abs (const T &x)
 
template<typename T >
static T Log (const T &x)
 
template<typename T >
static T Log10 (const T &x)
 
template<typename T >
static T Sin (const T &x)
 
template<typename T >
static T Cos (const T &x)
 
template<typename T >
static T Reciprocal (const T &x)
 
template<typename T >
static T ApproxSqrt (const T &x)
 
template<typename T >
static FiniteReturnTypeHelper< T >::R Finite (const T &x)
 
template<typename T >
static T Round (const T &x)
 
template<typename T >
static T Recip (const T &x)
 
template<typename T >
static T ATan2 (const T &y, const T &x)
 
template<typename T >
static T ASin (const T &x)
 
float Tan (float x)
 
float Copysign (float x, float y)
 
static float TwoPi ()
 
static float Pi ()
 
int Nint (float x)
 
template<>
float Reciprocal< float > (const float &x)
 
template<>
double Reciprocal< double > (const double &x)
 
template<>
float ApproxSqrt< float > (const float &x)
 
template<>
bool Finite< float > (const float &x)
 
template<>
float Round< float > (const float &x)
 
template<>
float ATan2< float > (const float &y, const float &x)
 
template<>
float ASin (const float &x)
 
template<>
Vc::int_v Abs< Vc::int_v > (const Vc::int_v &x)
 
template<typename T >
static T Min (const T &x, const T &y)
 
template<typename T >
static T Max (const T &x, const T &y)
 
template<typename T >
static T Sqrt (const T &x)
 
template<typename T >
static T RSqrt (const T &x)
 
template<typename T >
static T Abs (const T &x)
 
template<typename T >
static T Log (const T &x)
 
template<typename T >
static T Log10 (const T &x)
 
template<typename T >
static T Sin (const T &x)
 
template<typename T >
static T Cos (const T &x)
 
template<typename T >
static T Reciprocal (const T &x)
 
template<typename T >
static T ApproxSqrt (const T &x)
 
template<typename T >
static FiniteReturnTypeHelper< T >::R Finite (const T &x)
 
template<typename T >
static T Round (const T &x)
 
template<typename T >
static T Recip (const T &x)
 
template<typename T >
static T ATan2 (const T &y, const T &x)
 
template<typename T >
static T ASin (const T &x)
 
static float TwoPi ()
 
static float Pi ()
 

Detailed Description

The PndFTSCAMath class is the representation of mathematical operators

Function Documentation

◆ Abs() [1/2]

◆ Abs() [2/2]

template<typename T >
static T CAMath::Abs ( const T &  x)
inlinestatic

Definition at line 56 of file PndFTSCAMath.h.

57 {
58  return std::abs(x);
59 }

◆ Abs< Vc::int_v >()

template<>
Vc::int_v CAMath::Abs< Vc::int_v > ( const Vc::int_v &  x)
inline

Definition at line 30 of file PndCAVector.h.

31 {
32  return Vc::abs(x);
33 }

◆ ApproxSqrt() [1/2]

template<typename T >
static T CAMath::ApproxSqrt ( const T &  x)
static

Referenced by Cos().

◆ ApproxSqrt() [2/2]

template<typename T >
static T CAMath::ApproxSqrt ( const T &  x)
static

◆ ApproxSqrt< float >()

template<>
float CAMath::ApproxSqrt< float > ( const float &  x)
inline

Definition at line 162 of file PndCAMath.h.

163 {
164  float r = x;
165  asm("shr %0\n\t"
166  "add $0x1fc00000,%0\n\t"
167  : "+r"(r));
168  return r;
169 }

◆ ASin() [1/3]

template<typename T >
static T CAMath::ASin ( const T &  x)
static

◆ ASin() [2/3]

template<typename T >
static T CAMath::ASin ( const T &  x)
static

◆ ASin() [3/3]

template<>
float CAMath::ASin ( const float &  x)
inline

Definition at line 211 of file PndCAMath.h.

References choice.

212 {
213  return choice(asinf(x), asin(x), TMath::ASin(x));
214 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:131
float ASin(const float &x)
Definition: PndCAMath.h:211

◆ ATan2() [1/2]

template<typename T >
static T CAMath::ATan2 ( const T &  y,
const T &  x 
)
static

◆ ATan2() [2/2]

◆ ATan2< float >()

template<>
float CAMath::ATan2< float > ( const float &  y,
const float &  x 
)
inline

Definition at line 205 of file PndCAMath.h.

References ATan2(), atan2(), and choice.

206 {
207  return choice(atan2f(y, x), atan2(y, x), TMath::ATan2(y, x));
208 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:131
static T ATan2(const T &y, const T &x)
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Definition: P4_F32vec4.h:124

◆ Copysign()

float CAMath::Copysign ( float  x,
float  y 
)
inline

Definition at line 218 of file PndCAMath.h.

References Abs().

Referenced by Recip().

219 {
220  x = CAMath::Abs(x);
221  return (y >= 0) ? x : -x;
222 }
static T Abs(const T &x)
Definition: PndCAMath.h:56

◆ Cos() [1/2]

template<typename T >
static T CAMath::Cos ( const T &  x)
inlinestatic

Definition at line 76 of file PndFTSCAMath.h.

References ApproxSqrt(), cos(), and Reciprocal().

77 {
78  return std::cos(x);
79 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:119

◆ Cos() [2/2]

template<typename T >
static T CAMath::Cos ( const T &  x)
inlinestatic

◆ Finite() [1/2]

template<typename T >
static FiniteReturnTypeHelper<T>::R CAMath::Finite ( const T &  x)
static

◆ Finite() [2/2]

template<typename T >
static FiniteReturnTypeHelper<T>::R CAMath::Finite ( const T &  x)
static

Referenced by Finite< float >().

◆ Finite< float >()

template<>
bool CAMath::Finite< float > ( const float &  x)
inline

Definition at line 193 of file PndCAMath.h.

References choice, and Finite().

194 {
195  return choice(1, x < std::numeric_limits<float>::infinity() && -x < std::numeric_limits<float>::infinity(), TMath::Finite(x));
196 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:131
static FiniteReturnTypeHelper< T >::R Finite(const T &x)

◆ Log() [1/2]

template<typename T >
static T CAMath::Log ( const T &  x)
inlinestatic

Definition at line 61 of file PndFTSCAMath.h.

References log().

62 {
63  return std::log(x);
64 }
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:117

◆ Log() [2/2]

template<typename T >
static T CAMath::Log ( const T &  x)
inlinestatic

Definition at line 61 of file PndCAMath.h.

References log().

62 {
63  return std::log(x);
64 }
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:117

◆ Log10() [1/2]

template<typename T >
static T CAMath::Log10 ( const T &  x)
inlinestatic

Definition at line 66 of file PndFTSCAMath.h.

67 {
68  return std::log10(x);
69 }

◆ Log10() [2/2]

template<typename T >
static T CAMath::Log10 ( const T &  x)
inlinestatic

Definition at line 66 of file PndCAMath.h.

67 {
68  return std::log10(x);
69 }

◆ Max() [1/2]

template<typename T >
static T CAMath::Max ( const T &  x,
const T &  y 
)
inlinestatic

Definition at line 40 of file PndCAMath.h.

References max().

Referenced by PndCATrackLinearisationVector::PndCATrackLinearisationVector(), and PndFTSCATrackLinearisationVector::PndFTSCATrackLinearisationVector().

41 {
42  return std::max(x, y);
43 }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25

◆ Max() [2/2]

template<typename T >
static T CAMath::Max ( const T &  x,
const T &  y 
)
inlinestatic

Definition at line 40 of file PndFTSCAMath.h.

References max().

41 {
42  return std::max(x, y);
43 }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25

◆ Min() [1/2]

template<typename T >
static T CAMath::Min ( const T &  x,
const T &  y 
)
inlinestatic

Definition at line 35 of file PndFTSCAMath.h.

References min().

36 {
37  return std::min(x, y);
38 }
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:24

◆ Min() [2/2]

template<typename T >
static T CAMath::Min ( const T &  x,
const T &  y 
)
inlinestatic

Definition at line 35 of file PndCAMath.h.

References min().

Referenced by PndCATrackLinearisationVector::PndCATrackLinearisationVector(), and PndFTSCATrackLinearisationVector::PndFTSCATrackLinearisationVector().

36 {
37  return std::min(x, y);
38 }
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:24

◆ Nint()

int CAMath::Nint ( float  x)
inline

Definition at line 172 of file PndCAMath.h.

References f, and i.

Referenced by Pi(), and Round< float >().

173 {
174 #if defined(HLTCA_STANDALONE)
175  int i;
176  if (x >= 0) {
177  i = int(x + 0.5f);
178  if (x + 0.5f == float(i) && i & 1)
179  i--;
180  } else {
181  i = int(x - 0.5f);
182  if (x - 0.5f == float(i) && i & 1)
183  i++;
184  }
185  return i;
186 #else
187  return TMath::Nint(x);
188 #endif
189 }
unsigned int i
Definition: P4_F32vec4.h:21
float f
Definition: P4_F32vec4.h:20
int Nint(float x)
Definition: PndCAMath.h:172

◆ Pi() [1/2]

static float CAMath::Pi ( )
inlinestatic

Definition at line 115 of file PndCAMath.h.

References Nint().

Referenced by PndApollonius::ApolloniusTripletFunctions::AddOtherDetectors(), PANDA::CircleTools::PtOnCircle(), and PndApollonius::TripletSolution::SortHits().

116 {
117  return 3.1415926535897f;
118 }

◆ Pi() [2/2]

static float CAMath::Pi ( )
inlinestatic

Definition at line 115 of file PndFTSCAMath.h.

References Nint().

116 {
117  return 3.1415926535897f;
118 }

◆ Recip() [1/2]

template<typename T >
static T CAMath::Recip ( const T &  x)
inlinestatic

Definition at line 100 of file PndCAMath.h.

References ASin(), ATan2(), Copysign(), and Tan().

101 {
102  return T(1) / x;
103 }

◆ Recip() [2/2]

template<typename T >
static T CAMath::Recip ( const T &  x)
inlinestatic

Definition at line 100 of file PndFTSCAMath.h.

References ASin(), ATan2(), Copysign(), and Tan().

101 {
102  return T(1) / x;
103 }

◆ Reciprocal() [1/2]

template<typename T >
static T CAMath::Reciprocal ( const T &  x)
static

◆ Reciprocal() [2/2]

template<typename T >
static T CAMath::Reciprocal ( const T &  x)
static

Referenced by Cos().

◆ Reciprocal< double >()

template<>
double CAMath::Reciprocal< double > ( const double &  x)
inline

Definition at line 143 of file PndCAMath.h.

144 {
145  return 1. / x;
146 }

◆ Reciprocal< float >()

template<>
float CAMath::Reciprocal< float > ( const float &  x)
inline

Definition at line 137 of file PndCAMath.h.

138 {
139  return 1.f / x;
140 }

◆ Round() [1/2]

template<typename T >
static T CAMath::Round ( const T &  x)
static

◆ Round() [2/2]

template<typename T >
static T CAMath::Round ( const T &  x)
static

◆ Round< float >()

template<>
float CAMath::Round< float > ( const float &  x)
inline

Definition at line 199 of file PndCAMath.h.

References Nint().

200 {
201  return static_cast<float>(Nint(x));
202 }
int Nint(float x)
Definition: PndCAMath.h:172

◆ RSqrt() [1/2]

template<typename T >
static T CAMath::RSqrt ( const T &  x)
inlinestatic

Definition at line 50 of file PndCAMath.h.

References f, and sqrt().

Referenced by PndCATrackParamVector::TransportJ0ToX0(), PndFTSCATrackParamVector::TransportJ0ToX0(), PndCATrackParamVector::TransportToX(), and PndFTSCATrackParamVector::TransportToX0().

51 {
52  const T one = T(1.f);
53  return one / std::sqrt(x);
54 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:28
float f
Definition: P4_F32vec4.h:20

◆ RSqrt() [2/2]

template<typename T >
static T CAMath::RSqrt ( const T &  x)
inlinestatic

Definition at line 50 of file PndFTSCAMath.h.

References sqrt().

51 {
52  const T one = 1;
53  return one / std::sqrt(x);
54 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:28

◆ Sin() [1/2]

template<typename T >
static T CAMath::Sin ( const T &  x)
inlinestatic

◆ Sin() [2/2]

template<typename T >
static T CAMath::Sin ( const T &  x)
inlinestatic

Definition at line 71 of file PndFTSCAMath.h.

References sin().

72 {
73  return std::sin(x);
74 }
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:118

◆ Sqrt() [1/2]

◆ Sqrt() [2/2]

template<typename T >
static T CAMath::Sqrt ( const T &  x)
inlinestatic

Definition at line 45 of file PndFTSCAMath.h.

References sqrt().

46 {
47  return std::sqrt(x);
48 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:28

◆ Tan()

float CAMath::Tan ( float  x)
inline

Definition at line 224 of file PndCAMath.h.

References choice.

Referenced by Recip().

225 {
226  return choice(tanf(x), tan(x), TMath::Tan(x));
227 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:131
float Tan(float x)
Definition: PndCAMath.h:224

◆ TwoPi() [1/2]

static float CAMath::TwoPi ( )
inlinestatic

Definition at line 111 of file PndFTSCAMath.h.

112 {
113  return 6.283185307179586f;
114 }

◆ TwoPi() [2/2]

static float CAMath::TwoPi ( )
inlinestatic

Definition at line 111 of file PndCAMath.h.

112 {
113  return 6.283185307179586f;
114 }