38 constexpr Double_t Pi()
 
   40    return 3.14159265358979323846;
 
   45 constexpr Double_t TwoPi()
 
   52 constexpr Double_t PiOver2()
 
   59 constexpr Double_t PiOver4()
 
   66 constexpr Double_t InvPi()
 
   74 constexpr Double_t RadToDeg()
 
   82 constexpr Double_t DegToRad()
 
   89 constexpr Double_t Sqrt2()
 
   91    return 1.4142135623730950488016887242097;
 
   97 constexpr Double_t E()
 
   99    return 2.71828182845904523536;
 
  104 constexpr Double_t Ln10()
 
  106    return 2.30258509299404568402;
 
  111 constexpr Double_t LogE()
 
  113    return 0.43429448190325182765;
 
  118 constexpr Double_t C()
 
  125 constexpr Double_t Ccgs()
 
  132 constexpr Double_t CUncertainty()
 
  139 constexpr Double_t G()
 
  146 constexpr Double_t Gcgs()
 
  153 constexpr Double_t GUncertainty()
 
  160 constexpr Double_t GhbarC()
 
  167 constexpr Double_t GhbarCUncertainty()
 
  174 constexpr Double_t Gn()
 
  181 constexpr Double_t GnUncertainty()
 
  189 constexpr Double_t H()
 
  191    return 6.62606876e-34;
 
  196 constexpr Double_t Hcgs()
 
  203 constexpr Double_t HUncertainty()
 
  205    return 0.00000052e-34;
 
  211 constexpr Double_t Hbar()
 
  213    return 1.054571596e-34;
 
  218 constexpr Double_t Hbarcgs()
 
  220    return 1.0e7 * Hbar();
 
  225 constexpr Double_t HbarUncertainty()
 
  227    return 0.000000082e-34;
 
  232 constexpr Double_t HC()
 
  239 constexpr Double_t HCcgs()
 
  241    return Hcgs() * Ccgs();
 
  247 constexpr Double_t K()
 
  249    return 1.3806503e-23;
 
  254 constexpr Double_t Kcgs()
 
  261 constexpr Double_t KUncertainty()
 
  263    return 0.0000024e-23;
 
  269 constexpr Double_t Sigma()
 
  276 constexpr Double_t SigmaUncertainty()
 
  283 constexpr Double_t Na()
 
  285    return 6.02214199e+23;
 
  290 constexpr Double_t NaUncertainty()
 
  292    return 0.00000047e+23;
 
  299 constexpr Double_t R()
 
  306 constexpr Double_t RUncertainty()
 
  308    return R() * ((KUncertainty() / K()) + (NaUncertainty() / Na()));
 
  314 constexpr Double_t MWair()
 
  322 constexpr Double_t Rgair()
 
  324    return (1000.0 * R()) / MWair();
 
  329 constexpr Double_t EulerGamma()
 
  331    return 0.577215664901532860606512090082402431042;
 
  336 constexpr Double_t Qe()
 
  338    return 1.602176462e-19;
 
  343 constexpr Double_t QeUncertainty()
 
  345    return 0.000000063e-19;
 
  354 inline Double_t Sin(Double_t);
 
  355 inline Double_t Cos(Double_t);
 
  356 inline Double_t Tan(Double_t);
 
  357 inline Double_t SinH(Double_t);
 
  358 inline Double_t CosH(Double_t);
 
  359 inline Double_t TanH(Double_t);
 
  360 inline Double_t ASin(Double_t);
 
  361 inline Double_t ACos(Double_t);
 
  362 inline Double_t ATan(Double_t);
 
  363 inline Double_t ATan2(Double_t y, Double_t x);
 
  364 Double_t ASinH(Double_t);
 
  365 Double_t ACosH(Double_t);
 
  366 Double_t ATanH(Double_t);
 
  367 Double_t Hypot(Double_t x, Double_t y);
 
  372 inline Double_t Ceil(Double_t x);
 
  373 inline Int_t CeilNint(Double_t x);
 
  374 inline Double_t Floor(Double_t x);
 
  375 inline Int_t FloorNint(Double_t x);
 
  376 template <
typename T>
 
  377 inline Int_t Nint(T x);
 
  379 inline Double_t Sq(Double_t x);
 
  380 inline Double_t Sqrt(Double_t x);
 
  381 inline Double_t Exp(Double_t x);
 
  382 inline Double_t Ldexp(Double_t x, Int_t exp);
 
  383 Double_t Factorial(Int_t i);
 
  384 inline LongDouble_t Power(LongDouble_t x, LongDouble_t y);
 
  385 inline LongDouble_t Power(LongDouble_t x, Long64_t y);
 
  386 inline LongDouble_t Power(Long64_t x, Long64_t y);
 
  387 inline Double_t Power(Double_t x, Double_t y);
 
  388 inline Double_t Power(Double_t x, Int_t y);
 
  389 inline Double_t Log(Double_t x);
 
  390 Double_t Log2(Double_t x);
 
  391 inline Double_t Log10(Double_t x);
 
  392 inline Int_t Finite(Double_t x);
 
  393 inline Int_t Finite(Float_t x);
 
  394 inline Bool_t IsNaN(Double_t x);
 
  395 inline Bool_t IsNaN(Float_t x);
 
  397 inline Double_t QuietNaN();
 
  398 inline Double_t SignalingNaN();
 
  399 inline Double_t Infinity();
 
  401 template <
typename T>
 
  403    inline static T Min();
 
  404    inline static T Max();
 
  405    inline static T Epsilon();
 
  409    Long_t   Hypot(Long_t x, Long_t y);     
 
  412    inline Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon) {
 
  414       return TMath::Abs(af-bf) < epsilon ||
 
  415              TMath::Abs(af - bf) < Limits<Double_t>::Min(); 
 
  418    inline Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec) {
 
  420       return TMath::Abs(af - bf) <= 0.5 * relPrec * (TMath::Abs(af) + TMath::Abs(bf)) ||
 
  421              TMath::Abs(af - bf) < Limits<Double_t>::Min(); 
 
  428    template <
typename T> T MinElement(Long64_t n, 
const T *a);
 
  429    template <
typename T> T MaxElement(Long64_t n, 
const T *a);
 
  432    template <
typename T> Long64_t  LocMin(Long64_t n, 
const T *a);
 
  433    template <
typename Iterator> Iterator LocMin(Iterator first, Iterator last);
 
  434    template <
typename T> Long64_t  LocMax(Long64_t n, 
const T *a);
 
  435    template <
typename Iterator> Iterator LocMax(Iterator first, Iterator last);
 
  438    ULong_t Hash(
const void *txt, Int_t ntxt);
 
  439    ULong_t Hash(
const char *str);
 
  441    void BubbleHigh(Int_t Narr, Double_t *arr1, Int_t *arr2);
 
  442    void BubbleLow (Int_t Narr, Double_t *arr1, Int_t *arr2);
 
  444    Bool_t   Permute(Int_t n, Int_t *a); 
 
  450    void      Quantiles(Int_t n, Int_t nprob, Double_t *x, Double_t *quantiles, Double_t *prob,
 
  451                        Bool_t isSorted=kTRUE, Int_t *index = 0, Int_t type=7);
 
  454    template <
typename T> Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y);
 
  457    template <
typename T> T *Cross(
const T v1[3],
const T v2[3], T out[3]);
 
  459    Float_t   Normalize(Float_t v[3]);  
 
  460    Double_t  Normalize(Double_t v[3]); 
 
  463    template <
typename T> 
inline T NormCross(
const T v1[3],
const T v2[3],T out[3]);
 
  466    template <
typename T> T *Normal2Plane(
const T v1[3],
const T v2[3],
const T v3[3], T normal[3]);
 
  471    Bool_t    RootsCubic(
const Double_t coef[4],Double_t &a, Double_t &b, Double_t &c);
 
  476    Double_t Binomial(Int_t n,Int_t k);  
 
  477    Double_t BinomialI(Double_t p, Int_t n, Int_t k);
 
  478    Double_t BreitWigner(Double_t x, Double_t mean=0, Double_t gamma=1);
 
  479    Double_t CauchyDist(Double_t x, Double_t t=0, Double_t s=1);
 
  480    Double_t ChisquareQuantile(Double_t p, Double_t ndf);
 
  481    Double_t FDist(Double_t F, Double_t N, Double_t M);
 
  482    Double_t FDistI(Double_t F, Double_t N, Double_t M);
 
  483    Double_t Gaus(Double_t x, Double_t mean=0, Double_t sigma=1, Bool_t norm=kFALSE);
 
  484    Double_t KolmogorovProb(Double_t z);
 
  485    Double_t KolmogorovTest(Int_t na, 
const Double_t *a, Int_t nb, 
const Double_t *b, Option_t *option);
 
  486    Double_t Landau(Double_t x, Double_t mpv=0, Double_t sigma=1, Bool_t norm=kFALSE);
 
  487    Double_t LandauI(Double_t x);
 
  488    Double_t LaplaceDist(Double_t x, Double_t alpha=0, Double_t beta=1);
 
  489    Double_t LaplaceDistI(Double_t x, Double_t alpha=0, Double_t beta=1);
 
  490    Double_t LogNormal(Double_t x, Double_t sigma, Double_t theta=0, Double_t m=1);
 
  491    Double_t NormQuantile(Double_t p);
 
  492    Double_t Poisson(Double_t x, Double_t par);
 
  493    Double_t PoissonI(Double_t x, Double_t par);
 
  494    Double_t Prob(Double_t chi2,Int_t ndf);
 
  495    Double_t Student(Double_t T, Double_t ndf);
 
  496    Double_t StudentI(Double_t T, Double_t ndf);
 
  497    Double_t StudentQuantile(Double_t p, Double_t ndf, Bool_t lower_tail=kTRUE);
 
  498    Double_t Vavilov(Double_t x, Double_t kappa, Double_t beta2);
 
  499    Double_t VavilovI(Double_t x, Double_t kappa, Double_t beta2);
 
  500    Double_t Voigt(Double_t x, Double_t sigma, Double_t lg, Int_t r = 4);
 
  507    template <
typename T> Double_t Mean(Long64_t n, 
const T *a, 
const Double_t *w=0);
 
  508    template <
typename Iterator> Double_t Mean(Iterator first, Iterator last);
 
  509    template <
typename Iterator, 
typename WeightIterator> Double_t Mean(Iterator first, Iterator last, WeightIterator wfirst);
 
  511    template <
typename T> Double_t GeomMean(Long64_t n, 
const T *a);
 
  512    template <
typename Iterator> Double_t GeomMean(Iterator first, Iterator last);
 
  514    template <
typename T> Double_t RMS(Long64_t n, 
const T *a, 
const Double_t *w=0);
 
  515    template <
typename Iterator> Double_t RMS(Iterator first, Iterator last);
 
  516    template <
typename Iterator, 
typename WeightIterator> Double_t RMS(Iterator first, Iterator last, WeightIterator wfirst);
 
  518    template <
typename T> Double_t StdDev(Long64_t n, 
const T *a, 
const Double_t * w = 0) { 
return RMS<T>(n,a,w); }
 
  519    template <
typename Iterator> Double_t StdDev(Iterator first, Iterator last) { 
return RMS<Iterator>(first,last); }
 
  520    template <
typename Iterator, 
typename WeightIterator> Double_t StdDev(Iterator first, Iterator last, WeightIterator wfirst) { 
return RMS<Iterator,WeightIterator>(first,last,wfirst); }
 
  522    template <
typename T> Double_t Median(Long64_t n, 
const T *a,  
const Double_t *w=0, Long64_t *work=0);
 
  525    template <
class Element, 
typename Size> Element KOrdStat(Size n, 
const Element *a, Size k, Size *work = 0);
 
  530    Double_t Beta(Double_t p, Double_t q);
 
  531    Double_t BetaCf(Double_t x, Double_t a, Double_t b);
 
  532    Double_t BetaDist(Double_t x, Double_t p, Double_t q);
 
  533    Double_t BetaDistI(Double_t x, Double_t p, Double_t q);
 
  534    Double_t BetaIncomplete(Double_t x, Double_t a, Double_t b);
 
  537    Double_t BesselI(Int_t n,Double_t x);  
 
  538    Double_t BesselK(Int_t n,Double_t x);  
 
  539    Double_t BesselI0(Double_t x);         
 
  540    Double_t BesselK0(Double_t x);         
 
  541    Double_t BesselI1(Double_t x);         
 
  542    Double_t BesselK1(Double_t x);         
 
  543    Double_t BesselJ0(Double_t x);         
 
  544    Double_t BesselJ1(Double_t x);         
 
  545    Double_t BesselY0(Double_t x);         
 
  546    Double_t BesselY1(Double_t x);         
 
  547    Double_t StruveH0(Double_t x);         
 
  548    Double_t StruveH1(Double_t x);         
 
  549    Double_t StruveL0(Double_t x);         
 
  550    Double_t StruveL1(Double_t x);         
 
  552    Double_t DiLog(Double_t x);
 
  553    Double_t Erf(Double_t x);
 
  554    Double_t ErfInverse(Double_t x);
 
  555    Double_t Erfc(Double_t x);
 
  556    Double_t ErfcInverse(Double_t x);
 
  557    Double_t Freq(Double_t x);
 
  558    Double_t Gamma(Double_t z);
 
  559    Double_t Gamma(Double_t a,Double_t x);
 
  560    Double_t GammaDist(Double_t x, Double_t gamma, Double_t mu=0, Double_t beta=1);
 
  561    Double_t LnGamma(Double_t z);
 
  569 #if defined(R__WIN32) && !defined(__CINT__) 
  571 #      define finite _finite 
  574 #if defined(R__AIX) || defined(R__SOLARIS_CC50) || \ 
  575     defined(R__HPUX11) || defined(R__GLIBC) || \ 
  576     (defined(R__MACOSX) ) 
  579 #   ifdef R__SOLARIS_CC50 
  580        extern "C" { 
int finite(
double); }
 
  593    extern double sin(
double);
 
  594    extern double cos(
double);
 
  595    extern double tan(
double);
 
  596    extern double sinh(
double);
 
  597    extern double cosh(
double);
 
  598    extern double tanh(
double);
 
  599    extern double asin(
double);
 
  600    extern double acos(
double);
 
  601    extern double atan(
double);
 
  602    extern double atan2(
double, 
double);
 
  603    extern double sqrt(
double);
 
  604    extern double exp(
double);
 
  605    extern double pow(
double, 
double);
 
  606    extern double log(
double);
 
  607    extern double log10(
double);
 
  609 #   if !defined(finite) 
  610        extern int finite(
double);
 
  613        extern int isnan(
double);
 
  615    extern double ldexp(
double, 
int);
 
  616    extern double ceil(
double);
 
  617    extern double floor(
double);
 
  619    _CRTIMP 
double ldexp(
double, 
int);
 
  620    _CRTIMP 
double ceil(
double);
 
  621    _CRTIMP 
double floor(
double);
 
  627 inline Double_t TMath::Sin(Double_t x)
 
  631 inline Double_t TMath::Cos(Double_t x)
 
  635 inline Double_t TMath::Tan(Double_t x)
 
  639 inline Double_t TMath::SinH(Double_t x)
 
  643 inline Double_t TMath::CosH(Double_t x)
 
  647 inline Double_t TMath::TanH(Double_t x)
 
  651 inline Double_t TMath::ASin(Double_t x)
 
  652    { 
if (x < -1.) 
return -TMath::Pi()/2;
 
  653      if (x >  1.) 
return  TMath::Pi()/2;
 
  658 inline Double_t TMath::ACos(Double_t x)
 
  659    { 
if (x < -1.) 
return TMath::Pi();
 
  660      if (x >  1.) 
return 0;
 
  665 inline Double_t TMath::ATan(Double_t x)
 
  669 inline Double_t TMath::ATan2(Double_t y, Double_t x)
 
  670    { 
if (x != 0) 
return  atan2(y, x);
 
  671      if (y == 0) 
return  0;
 
  672      if (y >  0) 
return  Pi()/2;
 
  677 inline Double_t TMath::Sq(Double_t x)
 
  681 inline Double_t TMath::Sqrt(Double_t x)
 
  685 inline Double_t TMath::Ceil(Double_t x)
 
  689 inline Int_t TMath::CeilNint(Double_t x)
 
  690    { 
return TMath::Nint(ceil(x)); }
 
  693 inline Double_t TMath::Floor(Double_t x)
 
  697 inline Int_t TMath::FloorNint(Double_t x)
 
  698    { 
return TMath::Nint(floor(x)); }
 
  703 inline Int_t TMath::Nint(T x)
 
  708       if ( i & 1 && x + 0.5 == T(i) ) i--;
 
  711       if ( i & 1 && x - 0.5 == T(i) ) i++;
 
  717 inline Double_t TMath::Exp(Double_t x)
 
  721 inline Double_t TMath::Ldexp(Double_t x, Int_t exp)
 
  722    { 
return ldexp(x, exp); }
 
  725 inline LongDouble_t TMath::Power(LongDouble_t x, LongDouble_t y)
 
  726    { 
return std::pow(x,y); }
 
  729 inline LongDouble_t TMath::Power(LongDouble_t x, Long64_t y)
 
  730    { 
return std::pow(x,(LongDouble_t)y); }
 
  733 inline LongDouble_t TMath::Power(Long64_t x, Long64_t y)
 
  734    { 
return std::pow(x,y); }
 
  737 inline Double_t TMath::Power(Double_t x, Double_t y)
 
  738    { 
return pow(x, y); }
 
  741 inline Double_t TMath::Power(Double_t x, Int_t y) {
 
  743    return std::pow(x, y);
 
  745    return pow(x, (Double_t) y);
 
  750 inline Double_t TMath::Log(Double_t x)
 
  754 inline Double_t TMath::Log10(Double_t x)
 
  761 inline Int_t TMath::Finite(Double_t x)
 
  762 #if defined(R__FAST_MATH) 
  765    const unsigned long long mask = 0x7FF0000000000000LL;
 
  766    union { 
unsigned long long l; 
double d;} v;
 
  768    return (v.l&mask)!=mask;
 
  771 #  if defined(R__HPUX11) 
  772    { 
return isfinite(x); }
 
  773 #  elif defined(R__MACOSX) 
  776    { 
return isfinite(x); }
 
  779    { 
return std::isfinite(x); }
 
  782    { 
return finite(x); }
 
  790 inline Int_t TMath::Finite(Float_t x)
 
  791 #if defined(R__FAST_MATH) 
  794    const unsigned int mask =  0x7f800000;
 
  795    union { 
unsigned int l; 
float d;} v;
 
  797    return (v.l&mask)!=mask;
 
  800 { 
return std::isfinite(x); }
 
  808 #if defined (R__FAST_MATH) 
  835    } ieee_double_shape_type;
 
  837 #define EXTRACT_WORDS(ix0,ix1,d)                                    \ 
  839       ieee_double_shape_type ew_u;                                  \ 
  841       (ix0) = ew_u.parts.msw;                                       \ 
  842       (ix1) = ew_u.parts.lsw;                                       \ 
  845    inline Bool_t IsNaN(Double_t x)
 
  849       EXTRACT_WORDS(hx, lx, x);
 
  853       return (hx == 0x7ff00000) && (lx != 0);
 
  859    } ieee_float_shape_type;
 
  861 #define GET_FLOAT_WORD(i,d)                                         \ 
  863       ieee_float_shape_type gf_u;                                   \ 
  868    inline Bool_t IsNaN(Float_t x)
 
  871       GET_FLOAT_WORD (wx, x);
 
  873       return (Bool_t)(wx > 0x7f800000);
 
  876 #endif // End R__FAST_MATH 
  878 #if defined(R__FAST_MATH) 
  879    inline Bool_t TMath::IsNaN(Double_t x) { 
return ROOT::Internal::Math::IsNaN(x); }
 
  880    inline Bool_t TMath::IsNaN(Float_t x) { 
return ROOT::Internal::Math::IsNaN(x); }
 
  882    inline Bool_t TMath::IsNaN(Double_t x) { 
return std::isnan(x); }
 
  883    inline Bool_t TMath::IsNaN(Float_t x) { 
return std::isnan(x); }
 
  891 inline Double_t TMath::QuietNaN() {
 
  893    return std::numeric_limits<Double_t>::quiet_NaN();
 
  898 inline Double_t TMath::SignalingNaN() {
 
  899    return std::numeric_limits<Double_t>::signaling_NaN();
 
  904 inline Double_t TMath::Infinity() {
 
  905    return std::numeric_limits<Double_t>::infinity();
 
  911 inline T TMath::Limits<T>::Min() {
 
  912    return (std::numeric_limits<T>::min)();    
 
  918 inline T TMath::Limits<T>::Max() {
 
  919    return (std::numeric_limits<T>::max)();  
 
  925 inline T TMath::Limits<T>::Epsilon() {
 
  926    return std::numeric_limits<T>::epsilon();
 
  934 template <
typename T> 
inline T TMath::NormCross(
const T v1[3],
const T v2[3],T out[3])
 
  936    return Normalize(Cross(v1,v2,out));
 
  941 template <
typename T>
 
  942 T TMath::MinElement(Long64_t n, 
const T *a) {
 
  943    return *std::min_element(a,a+n);
 
  948 template <
typename T>
 
  949 T TMath::MaxElement(Long64_t n, 
const T *a) {
 
  950    return *std::max_element(a,a+n);
 
  961 template <
typename T>
 
  962 Long64_t TMath::LocMin(Long64_t n, 
const T *a) {
 
  963    if  (n <= 0 || !a) 
return -1;
 
  966    for  (Long64_t i = 1; i < n; i++) {
 
  978 template <
typename Iterator>
 
  979 Iterator TMath::LocMin(Iterator first, Iterator last) {
 
  981    return std::min_element(first, last);
 
  989 template <
typename T>
 
  990 Long64_t TMath::LocMax(Long64_t n, 
const T *a) {
 
  991    if  (n <= 0 || !a) 
return -1;
 
  994    for  (Long64_t i = 1; i < n; i++) {
 
 1006 template <
typename Iterator>
 
 1007 Iterator TMath::LocMax(Iterator first, Iterator last)
 
 1010    return std::max_element(first, last);
 
 1015 template <
typename Iterator>
 
 1016 Double_t TMath::Mean(Iterator first, Iterator last)
 
 1020    while ( first != last )
 
 1034 template <
typename Iterator, 
typename WeightIterator>
 
 1035 Double_t TMath::Mean(Iterator first, Iterator last, WeightIterator w)
 
 1041    while ( first != last ) {
 
 1043          ::Error(
"TMath::Mean",
"w[%d] = %.4e < 0 ?!",i,*w);
 
 1046       sum  += (*w) * (*first);
 
 1053       ::Error(
"TMath::Mean",
"sum of weights == 0 ?!");
 
 1062 template <
typename T>
 
 1063 Double_t TMath::Mean(Long64_t n, 
const T *a, 
const Double_t *w)
 
 1066       return TMath::Mean(a, a+n, w);
 
 1068       return TMath::Mean(a, a+n);
 
 1075 template <
typename Iterator>
 
 1076 Double_t TMath::GeomMean(Iterator first, Iterator last)
 
 1078    Double_t logsum = 0.;
 
 1080    while ( first != last ) {
 
 1081       if (*first == 0) 
return 0.;
 
 1082       Double_t absa = (Double_t) TMath::Abs(*first);
 
 1083       logsum += TMath::Log(absa);
 
 1088    return TMath::Exp(logsum/n);
 
 1094 template <
typename T>
 
 1095 Double_t TMath::GeomMean(Long64_t n, 
const T *a)
 
 1097    return TMath::GeomMean(a, a+n);
 
 1108 template <
typename Iterator>
 
 1109 Double_t TMath::RMS(Iterator first, Iterator last)
 
 1115    Double_t mean = TMath::Mean(first,last);
 
 1116    while ( first != last ) {
 
 1117       Double_t x = Double_t(*first);
 
 1118       tot += (x - mean)*(x - mean);
 
 1122    Double_t rms = (n > 1) ? TMath::Sqrt(tot/(n-1)) : 0.0;
 
 1132 template <
typename Iterator, 
typename WeightIterator>
 
 1133 Double_t TMath::RMS(Iterator first, Iterator last, WeightIterator w)
 
 1138    Double_t mean = TMath::Mean(first,last,w);
 
 1139    while ( first != last ) {
 
 1140       Double_t x = Double_t(*first);
 
 1142       sumw2 += (*w) * (*w);
 
 1143       tot += (*w) * (x - mean)*(x - mean);
 
 1148    Double_t rms =  TMath::Sqrt(tot * sumw/ (sumw*sumw - sumw2) );
 
 1156 template <
typename T>
 
 1157 Double_t TMath::RMS(Long64_t n, 
const T *a, 
const Double_t * w)
 
 1159    return (w) ? TMath::RMS(a, a+n, w) : TMath::RMS(a, a+n);
 
 1165 template <
typename T> T *TMath::Cross(
const T v1[3],
const T v2[3], T out[3])
 
 1167    out[0] = v1[1] * v2[2] - v1[2] * v2[1];
 
 1168    out[1] = v1[2] * v2[0] - v1[0] * v2[2];
 
 1169    out[2] = v1[0] * v2[1] - v1[1] * v2[0];
 
 1179 template <
typename T> T * TMath::Normal2Plane(
const T p1[3],
const T p2[3],
const T p3[3], T normal[3])
 
 1183    v1[0] = p2[0] - p1[0];
 
 1184    v1[1] = p2[1] - p1[1];
 
 1185    v1[2] = p2[2] - p1[2];
 
 1187    v2[0] = p3[0] - p1[0];
 
 1188    v2[1] = p3[1] - p1[1];
 
 1189    v2[2] = p3[2] - p1[2];
 
 1191    NormCross(v1,v2,normal);
 
 1199 template <
typename T> Bool_t TMath::IsInside(T xp, T yp, Int_t np, T *x, T *y)
 
 1202    Bool_t oddNodes = kFALSE;
 
 1204    for (i=0; i<np; i++) {
 
 1205       if ((y[i]<yp && y[j]>=yp) || (y[j]<yp && y[i]>=yp)) {
 
 1206          if (x[i]+(yp-y[i])/(y[j]-y[i])*(x[j]-x[i])<xp) {
 
 1207             oddNodes = !oddNodes;
 
 1237 template <
typename T> Double_t TMath::Median(Long64_t n, 
const T *a,  
const Double_t *w, Long64_t *work)
 
 1240    const Int_t kWorkMax = 100;
 
 1242    if (n <= 0 || !a) 
return 0;
 
 1243    Bool_t isAllocated = kFALSE;
 
 1246    Long64_t workLocal[kWorkMax];
 
 1253          isAllocated = kTRUE;
 
 1254          ind = 
new Long64_t[n];
 
 1259       Double_t sumTot2 = 0;
 
 1260       for (Int_t j = 0; j < n; j++) {
 
 1262             ::Error(
"TMath::Median",
"w[%d] = %.4e < 0 ?!",j,w[j]);
 
 1263             if (isAllocated)  
delete [] ind;
 
 1271       Sort(n, a, ind, kFALSE);
 
 1275       for (jl = 0; jl < n; jl++) {
 
 1277          if (sum >= sumTot2) 
break;
 
 1282       for (jh = n-1; jh >= 0; jh--) {
 
 1284          if (sum <= sumTot2) 
break;
 
 1287       median = 0.5*(a[ind[jl]]+a[ind[jh]]);
 
 1292          median = KOrdStat(n, a,n/2, ind);
 
 1294          median = 0.5*(KOrdStat(n, a, n/2 -1, ind)+KOrdStat(n, a, n/2, ind));
 
 1322 template <
class Element, 
typename Size>
 
 1323 Element TMath::KOrdStat(Size n, 
const Element *a, Size k, Size *work)
 
 1326    const Int_t kWorkMax = 100;
 
 1330    Bool_t isAllocated = kFALSE;
 
 1331    Size i, ir, j, l, mid;
 
 1334    Index workLocal[kWorkMax];
 
 1342          isAllocated = kTRUE;
 
 1347    for (Size ii=0; ii<n; ii++) {
 
 1355          if (ir == l+1 && a[ind[ir]]<a[ind[l]])
 
 1356             {temp = ind[l]; ind[l]=ind[ir]; ind[ir]=temp;}
 
 1357          Element tmp = a[ind[rk]];
 
 1363          {temp = ind[mid]; ind[mid]=ind[l+1]; ind[l+1]=temp;}
 
 1364          if (a[ind[l]]>a[ind[ir]])  
 
 1365             {temp = ind[l]; ind[l]=ind[ir]; ind[ir]=temp;}
 
 1367          if (a[ind[l+1]]>a[ind[ir]])
 
 1368             {temp=ind[l+1]; ind[l+1]=ind[ir]; ind[ir]=temp;}
 
 1370          if (a[ind[l]]>a[ind[l+1]])
 
 1371             {temp = ind[l]; ind[l]=ind[l+1]; ind[l+1]=temp;}
 
 1377             do i++; 
while (a[ind[i]]<a[arr]);
 
 1378             do j--; 
while (a[ind[j]]>a[arr]);
 
 1380                {temp=ind[i]; ind[i]=ind[j]; ind[j]=temp;}
 
 1384          if (j>=rk) ir = j-1;