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 68 of file PndFTSCAMath.h.

69 {
70  return std::abs(x);
71 }

◆ Abs< Vc::int_v >()

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

Definition at line 42 of file PndCAVector.h.

43 {
44  return Vc::abs(x);
45 }

◆ 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 174 of file PndCAMath.h.

175 {
176  float r = x;
177  asm("shr %0\n\t"
178  "add $0x1fc00000,%0\n\t"
179  : "+r"(r));
180  return r;
181 }

◆ 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 223 of file PndCAMath.h.

References choice.

224 {
225  return choice(asinf(x), asin(x), TMath::ASin(x));
226 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:143
float ASin(const float &x)
Definition: PndCAMath.h:223

◆ 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 217 of file PndCAMath.h.

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

218 {
219  return choice(atan2f(y, x), atan2(y, x), TMath::ATan2(y, x));
220 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:143
static T ATan2(const T &y, const T &x)
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Definition: P4_F32vec4.h:136

◆ Copysign()

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

Definition at line 230 of file PndCAMath.h.

References Abs().

Referenced by Recip().

231 {
232  x = CAMath::Abs(x);
233  return (y >= 0) ? x : -x;
234 }
static T Abs(const T &x)
Definition: PndCAMath.h:68

◆ Cos() [1/2]

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

Definition at line 88 of file PndFTSCAMath.h.

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

89 {
90  return std::cos(x);
91 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:131

◆ 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 205 of file PndCAMath.h.

References choice, and Finite().

206 {
207  return choice(1, x < std::numeric_limits<float>::infinity() && -x < std::numeric_limits<float>::infinity(), TMath::Finite(x));
208 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:143
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 73 of file PndFTSCAMath.h.

References log().

74 {
75  return std::log(x);
76 }
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:129

◆ Log() [2/2]

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

Definition at line 73 of file PndCAMath.h.

References log().

74 {
75  return std::log(x);
76 }
friend F32vec4 log(const F32vec4 &a)
Definition: P4_F32vec4.h:129

◆ Log10() [1/2]

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

Definition at line 78 of file PndFTSCAMath.h.

79 {
80  return std::log10(x);
81 }

◆ Log10() [2/2]

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

Definition at line 78 of file PndCAMath.h.

79 {
80  return std::log10(x);
81 }

◆ Max() [1/2]

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

Definition at line 52 of file PndCAMath.h.

References max().

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

53 {
54  return std::max(x, y);
55 }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37

◆ Max() [2/2]

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

Definition at line 52 of file PndFTSCAMath.h.

References max().

53 {
54  return std::max(x, y);
55 }
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37

◆ Min() [1/2]

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

Definition at line 47 of file PndFTSCAMath.h.

References min().

48 {
49  return std::min(x, y);
50 }
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:36

◆ Min() [2/2]

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

Definition at line 47 of file PndCAMath.h.

References min().

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

48 {
49  return std::min(x, y);
50 }
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:36

◆ Nint()

int CAMath::Nint ( float  x)
inline

Definition at line 184 of file PndCAMath.h.

References f, and i.

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

185 {
186 #if defined(HLTCA_STANDALONE)
187  int i;
188  if (x >= 0) {
189  i = int(x + 0.5f);
190  if (x + 0.5f == float(i) && i & 1)
191  i--;
192  } else {
193  i = int(x - 0.5f);
194  if (x - 0.5f == float(i) && i & 1)
195  i++;
196  }
197  return i;
198 #else
199  return TMath::Nint(x);
200 #endif
201 }
unsigned int i
Definition: P4_F32vec4.h:33
float f
Definition: P4_F32vec4.h:32
int Nint(float x)
Definition: PndCAMath.h:184

◆ Pi() [1/2]

static float CAMath::Pi ( )
inlinestatic

Definition at line 127 of file PndCAMath.h.

References Nint().

Referenced by PANDA::CircleTools::PtOnCircle().

128 {
129  return 3.1415926535897f;
130 }

◆ Pi() [2/2]

static float CAMath::Pi ( )
inlinestatic

Definition at line 127 of file PndFTSCAMath.h.

References Nint().

128 {
129  return 3.1415926535897f;
130 }

◆ Recip() [1/2]

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

Definition at line 112 of file PndCAMath.h.

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

113 {
114  return T(1) / x;
115 }

◆ Recip() [2/2]

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

Definition at line 112 of file PndFTSCAMath.h.

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

113 {
114  return T(1) / x;
115 }

◆ 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 155 of file PndCAMath.h.

156 {
157  return 1. / x;
158 }

◆ Reciprocal< float >()

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

Definition at line 149 of file PndCAMath.h.

150 {
151  return 1.f / x;
152 }

◆ 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 211 of file PndCAMath.h.

References Nint().

212 {
213  return static_cast<float>(Nint(x));
214 }
int Nint(float x)
Definition: PndCAMath.h:184

◆ RSqrt() [1/2]

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

Definition at line 62 of file PndCAMath.h.

References f, and sqrt().

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

63 {
64  const T one = T(1.f);
65  return one / std::sqrt(x);
66 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:40
float f
Definition: P4_F32vec4.h:32

◆ RSqrt() [2/2]

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

Definition at line 62 of file PndFTSCAMath.h.

References sqrt().

63 {
64  const T one = 1;
65  return one / std::sqrt(x);
66 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:40

◆ 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 83 of file PndFTSCAMath.h.

References sin().

84 {
85  return std::sin(x);
86 }
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:130

◆ Sqrt() [1/2]

◆ Sqrt() [2/2]

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

Definition at line 57 of file PndFTSCAMath.h.

References sqrt().

58 {
59  return std::sqrt(x);
60 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:40

◆ Tan()

float CAMath::Tan ( float  x)
inline

Definition at line 236 of file PndCAMath.h.

References choice.

Referenced by Recip().

237 {
238  return choice(tanf(x), tan(x), TMath::Tan(x));
239 }
#define choice(c1, c2, c3)
Definition: PndCAMath.h:143
float Tan(float x)
Definition: PndCAMath.h:236

◆ TwoPi() [1/2]

static float CAMath::TwoPi ( )
inlinestatic

Definition at line 123 of file PndFTSCAMath.h.

124 {
125  return 6.283185307179586f;
126 }

◆ TwoPi() [2/2]

static float CAMath::TwoPi ( )
inlinestatic

Definition at line 123 of file PndCAMath.h.

124 {
125  return 6.283185307179586f;
126 }