Classes | Functions | Variables
osc::analytic Namespace Reference

Classes

class  _OscCalc
 
struct  cmplx
 std::complex takes a lot of care with inf/nan which we don't want More...
 
struct  Eigenvalues
 
struct  Hermitian
 
class  ProbCache
 
class  Probs
 

Functions

template<class T , class U >
cmplx< T, U > make_cmplx (const T &re, const U &im)
 
template<class A , class B , class C , class D >
 __attribute__ ((always_inline)) auto operator*(const cmplx<A
 
template<class A , class B , class C >
 __attribute__ ((always_inline)) auto operator*(const A &x
 
template<class T , class U >
 __attribute__ ((always_inline)) auto operator/(const cmplx< T > &x
 
template<class T >
 __attribute__ ((always_inline)) cmplx< T > operator-(const cmplx< T > &x)
 
template<class T >
T sqr (T x)
 
template<class T >
T cube (T x)
 
template<class T >
std::array< T, 3 > SolveCubic (T b, T c, T d)
 Solve x^3 + b*x^2 + c*x + d = 0. More...
 

Variables

B & x
 
B const cmplx< C, D > & y
 
const double sqrt3 = sqrt(3)
 

Function Documentation

template<class A , class B , class C , class D >
osc::analytic::__attribute__ ( (always_inline)  ) const
inline

Referenced by make_cmplx().

template<class A , class B , class C >
osc::analytic::__attribute__ ( (always_inline)  ) const
inline
template<class T , class U >
osc::analytic::__attribute__ ( (always_inline)  ) const
inline
template<class T >
osc::analytic::__attribute__ ( (always_inline)  ) const
inline

Definition at line 93 of file OscCalcAnalytic.cxx.

References make_cmplx().

95  {
96  return make_cmplx(-x.re, -x.im);
97  }
cmplx< T, U > make_cmplx(const T &re, const U &im)
template<class T >
T osc::analytic::cube ( T  x)

Definition at line 212 of file OscCalcAnalytic.cxx.

References x.

Referenced by SolveCubic().

212 {return x*x*x;}
template<class T , class U >
cmplx<T, U> osc::analytic::make_cmplx ( const T re,
const U &  im 
)

Definition at line 31 of file OscCalcAnalytic.cxx.

References __attribute__().

Referenced by __attribute__().

31 {return cmplx<T, U>(re, im);}
template<class T >
std::array<T, 3> osc::analytic::SolveCubic ( T  b,
T  c,
T  d 
)

Solve x^3 + b*x^2 + c*x + d = 0.

Definition at line 218 of file OscCalcAnalytic.cxx.

References osc::analytic::_OscCalc< T >::_P(), std::acos(), b, plot_validation_datamc::c, osc::analytic::_OscCalc< T >::c12, osc::analytic::_OscCalc< T >::c13, osc::analytic::_OscCalc< T >::c23, osc::analytic::_OscCalc< T >::cCP, osc::analytic::_OscCalc< T >::ClearProbCaches(), osc::analytic::cmplx< T, U >::conj(), cube(), d, osc::_IOscCalcAdjustable< T >::fDmsq21, osc::_IOscCalcAdjustable< T >::fDmsq32, osc::analytic::_OscCalc< T >::Hee, osc::analytic::_OscCalc< T >::Hem, osc::analytic::_OscCalc< T >::Het, osc::analytic::_OscCalc< T >::Hmm, osc::analytic::_OscCalc< T >::Hmt, osc::analytic::_OscCalc< T >::Htt, P, r(), osc::analytic::_OscCalc< T >::s12, osc::analytic::_OscCalc< T >::s13, osc::analytic::_OscCalc< T >::s23, osc::analytic::_OscCalc< T >::sCP, sincos(), sqr(), std::sqrt(), T, getGoodRuns4SAM::t0, getGoodRuns4SAM::t1, t2, osc::analytic::_OscCalc< T >::Ue2, osc::analytic::_OscCalc< T >::Ue3, osc::analytic::_OscCalc< T >::Um2, osc::analytic::_OscCalc< T >::Um3, osc::analytic::_OscCalc< T >::Ut2, and osc::analytic::_OscCalc< T >::Ut3.

219  {
220  b /= 3;
221  // Now solving x^3 + 3*b*x^2 + c*x + d = 0
222 
223  // https://en.wikipedia.org/wiki/Cubic_equation#Depressed_cubic
224  const T p = c/3 - sqr(b);
225  const T q = 2*cube(b) - b*c + d;
226  // Now solving t^3 + 3*p*t + q = 0
227 
228  // https://en.wikipedia.org/wiki/Cubic_equation#Trigonometric_solution_for_three_real_roots
229  //
230  // Cardano's formula looks simpler, but you still have to involve trig
231  // operations anyway for the cube root, and it's harder to keep everything
232  // explicitly real.
233 
234  const T s = sqrt(-p);
235 
236  const T r = acos(q/(2*p*s)) / 3;
237 
238  // t_k = 2*s * cos(r/3 + 2pi*k/3)
239 
240  // Use cos(a+b) = cosa*cosb - sina*sinb to save one trig operation
241  T sinr, cosr;
242  sincos(r, &sinr, &cosr);
243 
244  const T t0 = 2*s*cosr;
245  const T t1 = s*(sqrt3*sinr - cosr);
246  const T t2 = -t0-t1;
247 
248  return {t0 - b, t1 - b, t2 - b};
249  }
const char * p
Definition: xmltok.h:285
T sqrt(T number)
Definition: d0nt_math.hpp:156
void sincos(T &x, Eigen::ArrayX< U > *sx, Eigen::ArrayX< U > *cx)
T acos(T number)
Definition: d0nt_math.hpp:54
const XML_Char * s
Definition: expat.h:262
const double sqrt3
Float_t d
Definition: plot.C:236
double t2
const hit & b
Definition: hits.cxx:21
TRandom3 r(0)
double T
Definition: Xdiff_gwt.C:5
template<class T >
T osc::analytic::sqr ( T  x)

Definition at line 211 of file OscCalcAnalytic.cxx.

References x.

Referenced by SolveCubic().

211 {return x*x;}

Variable Documentation

const double osc::analytic::sqrt3 = sqrt(3)

Definition at line 214 of file OscCalcAnalytic.cxx.

B & osc::analytic::x

Definition at line 34 of file OscCalcAnalytic.cxx.

Referenced by cube(), and sqr().

const cmplx< B, C > & osc::analytic::y
Initial value:
{
return make_cmplx(x.re*y.re - x.im*y.im, x.re*y.im + x.im*y.re)
cmplx< T, U > make_cmplx(const T &re, const U &im)
B const cmplx< C, D > & y

Definition at line 35 of file OscCalcAnalytic.cxx.