Commit a96e45d9 authored by Lynn Garren's avatar Lynn Garren
Browse files

replace M_PI with CLHEP::pi

parent 67efdf48
......@@ -176,21 +176,6 @@ AC_CHECK_HEADERS([string.h])
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
......
......@@ -176,26 +176,11 @@ AC_CHECK_HEADERS([stdlib.h])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
......
// -*- C++ -*-
// $Id: BivariateGaussian.cc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: BivariateGaussian.cc,v 1.2 2003/08/08 13:47:09 garren Exp $
#include "GenericFunctions/defs.h"
#include "CLHEP/GenericFunctions/BivariateGaussian.hh"
#include "CLHEP/Units/PhysicalConstants.h"
#include <assert.h>
#include <cmath> // for exp()
......@@ -47,7 +48,7 @@ double BivariateGaussian::operator() (const Argument & a) const {
double rho = _corr01.getValue();
double dt = (1.0+rho)*(1.0-rho);
return (1.0/(2.0*M_PI*sx*sy*sqrt(dt))) *
return (1.0/(CLHEP::twopi*sx*sy*sqrt(dt))) *
exp(-1.0/(2.0*dt)*(dx*dx/sxs+dy*dy/sys-2.0*rho*dx*dy/sx/sy));
}
......
// -*- C++ -*-
// $Id: Gaussian.cc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: Gaussian.cc,v 1.2 2003/08/08 13:47:09 garren Exp $
#include "GenericFunctions/defs.h"
#include "CLHEP/GenericFunctions/Gaussian.hh"
#include "CLHEP/GenericFunctions/Variable.hh"
#include "CLHEP/Units/PhysicalConstants.h"
#include <assert.h>
#include <cmath> // for exp()
......@@ -27,7 +28,7 @@ _sigma(right._sigma)
double Gaussian::operator() (double x) const {
double s = _sigma.getValue();
double x0 = _mean.getValue();
return (1.0/(sqrt(2.0*M_PI)*s))*
return (1.0/(sqrt(CLHEP::twopi)*s))*
exp(-(x-x0)*(x-x0)/(2.0*s*s));
}
......
// -*- C++ -*-
// $Id: TrivariateGaussian.cc,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: TrivariateGaussian.cc,v 1.2 2003/08/08 13:47:09 garren Exp $
// ---------------------------------------------------------------------------
#include "GenericFunctions/defs.h"
#include "CLHEP/GenericFunctions/TrivariateGaussian.hh"
#include "CLHEP/Units/PhysicalConstants.h"
#include <assert.h>
#include <cmath> // for exp()
......@@ -71,7 +72,7 @@ double TrivariateGaussian::operator() (const Argument & a) const {
double dt = (1.0+rho1*rho2*rho3-rho1*rho1-rho2*rho2-rho3*rho3);
double tmp1 ,tmp2;
tmp1= 1.0/((2.0*M_PI)*sqrt(2.0*M_PI)*sx*sy*sz*sqrt(dt));
tmp1= 1.0/((CLHEP::twopi)*sqrt(CLHEP::twopi)*sx*sy*sz*sqrt(dt));
tmp2= exp(-0.5/dt*(dx*dx*(1.0-rho2*rho2)/sxs+dy*dy*(1.0-rho3*rho3)/sys+dz*dz*(1.0-rho1*rho1)/szs+2.0*dx*dy*(rho2*rho3-rho1)/sx/sy+2.0*dy*dz*(rho1*rho3-rho2)/sy/sz+2.0*dx*dz*(rho1*rho2-rho3)/sx/sz));
......
......@@ -177,26 +177,11 @@ AC_CHECK_HEADERS([stdlib.h])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
......
// -*- C++ -*-
// $Id: testBasicVector3D.cc,v 1.1 2003/07/17 09:05:28 garren Exp $
// $Id: testBasicVector3D.cc,v 1.2 2003/08/08 13:47:09 garren Exp $
// ---------------------------------------------------------------------------
#include <iostream>
......@@ -8,6 +8,7 @@
#include "CLHEP/Geometry/Vector3D.h"
#include "CLHEP/Geometry/Normal3D.h"
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Units/PhysicalConstants.h"
bool EQUAL(double a, double b) {
double del = a - b;
......@@ -125,11 +126,11 @@ using namespace HepGeom;
p55.setMag(14); assert(p55 == point(4,6,12)); \
p55.setR(7); assert(p55 == point(2,3,6)); \
point p56 = p55; \
p56.setPhi(M_PI/6); assert(EQUAL(p56.getPhi(),M_PI/6)); \
p56.setPhi(CLHEP::pi/6); assert(EQUAL(p56.getPhi(),CLHEP::pi/6)); \
assert(EQUAL(p56.mag() ,p55.mag())); \
assert(EQUAL(p56.theta() ,p55.theta())); \
point p57 = p55; \
p57.setTheta(M_PI/3); assert(EQUAL(p57.cosTheta(),0.5)); \
p57.setTheta(CLHEP::pi/3); assert(EQUAL(p57.cosTheta(),0.5)); \
assert(EQUAL(p57.mag() ,p55.mag())); \
assert(EQUAL(p57.phi() ,p55.phi())); \
\
......@@ -149,8 +150,8 @@ using namespace HepGeom;
point p73(3,4,0); assert(p73.perp2(point(0,1,0)) == 9); \
assert(p73.perp (point(1,0,0)) == 4); \
point p74(1,0,0); \
point p75(1,1,0); assert(EQUAL(p74.angle(p75),M_PI/4)); \
assert(EQUAL(p75.angle(p00),M_PI/2)); \
point p75(1,1,0); assert(EQUAL(p74.angle(p75),CLHEP::pi/4)); \
assert(EQUAL(p75.angle(p00),CLHEP::pi/2)); \
\
/* Check related vectors */ \
point p80(1,2,3); \
......@@ -159,19 +160,19 @@ using namespace HepGeom;
\
/* Check rotations */ \
point p90(2,0.5,sqrt(3)/2); \
p90.rotateX(M_PI/6); assert(p90.x() == 2); \
p90.rotateX(CLHEP::pi/6); assert(p90.x() == 2); \
assert(EQUAL(p90.y(),0)); \
assert(EQUAL(p90.z(),1)); \
point p91(sqrt(3)/2,2,0.5); \
p91.rotateY(M_PI/6); assert(EQUAL(p91.x(),1)); \
p91.rotateY(CLHEP::pi/6); assert(EQUAL(p91.x(),1)); \
assert(p91.y() == 2); \
assert(EQUAL(p91.z(),0)); \
point p92(0.5,sqrt(3)/2,2); \
p92.rotateZ(M_PI/6); assert(EQUAL(p92.x(),0)); \
p92.rotateZ(CLHEP::pi/6); assert(EQUAL(p92.x(),0)); \
assert(EQUAL(p92.y(),1)); \
assert(p92.z() == 2); \
point p93(1,1,sqrt(2)); \
p93.rotate(M_PI,Vector3D<float>(-1,-1,sqrt(2))); \
p93.rotate(CLHEP::pi,Vector3D<float>(-1,-1,sqrt(2))); \
assert(EQUAL(p93.x(),-1)); \
assert(EQUAL(p93.y(),-1)); \
assert(EQUAL(p93.z(),-sqrt(2))); \
......@@ -179,7 +180,7 @@ using namespace HepGeom;
/* Check transformations */ \
point p100(1,1,sqrt(2)); \
Transform3D m; \
m = Rotate3D(M_PI,Vector3D<float>(-1,-1,sqrt(2))); \
m = Rotate3D(CLHEP::pi,Vector3D<float>(-1,-1,sqrt(2))); \
p100.transform(m); assert(EQUAL(p100.x(),-1)); \
assert(EQUAL(p100.y(),-1)); \
assert(EQUAL(p100.z(),-sqrt(2))); \
......
// -*- C++ -*-
// $Id: testTransform3D.cc,v 1.1 2003/07/17 09:05:28 garren Exp $
// $Id: testTransform3D.cc,v 1.2 2003/08/08 13:47:09 garren Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
......@@ -10,6 +10,7 @@
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include "CLHEP/Units/PhysicalConstants.h"
typedef HepScale3D Scale;
typedef HepRotate3D Rotation;
......@@ -43,7 +44,7 @@ int main() {
// Rotation + Translation
HepRotation R;
double angA=M_PI/3, angB=M_PI/4, angC=M_PI/6;
double angA=CLHEP::pi/3, angB=CLHEP::pi/4, angC=CLHEP::pi/6;
R.rotateX(angA); R.rotateY(angB); R.rotateZ(angC);
const Hep3Vector D(1, 2, 3);
......
......@@ -185,25 +185,11 @@ AC_CHECK_HEADERS([sstream])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_C_CONST
AC_C_INLINE
AC_CHECK_TYPES([ptrdiff_t])
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
AC_MSG_CHECKING([for ios_base])
iosbase=no
AC_COMPILE_IFELSE(
......
......@@ -180,24 +180,10 @@ AC_CHECK_HEADERS([sstream])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_C_CONST
AC_C_INLINE
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
......
......@@ -177,24 +177,10 @@ AC_CHECK_HEADERS([float.h string.h])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_C_CONST
AC_C_INLINE
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
......
......@@ -183,24 +183,10 @@ AC_CHECK_HEADERS([float.h string.h])
# ----------------------------------------------------------------------
# Check for needed typedefs, structures, and compiler characteristics:
# ----------------------------------------------------------------------
AC_C_CONST
AC_C_INLINE
AC_CHECK_DECL(M_PI,
[],
AC_DEFINE(M_PI, 3.14159265358979323846, [Value of pi]),
[#include <cmath>])
AC_CHECK_DECL(M_PI_2,
[],
AC_DEFINE(M_PI_2, 1.57079632679489661923, [Value of pi/2]),
[#include <cmath>])
AC_CHECK_DECL(M_2PI,
[],
AC_DEFINE(M_2PI, 6.28318530717958647692, [Value of 2*pi]),
[#include <cmath>])
# ----------------------------------------------------------------------
# Check for needed library functions:
# ----------------------------------------------------------------------
......
// $Id: RandBreitWigner.cc,v 1.2 2003/07/17 19:20:02 garren Exp $
// $Id: RandBreitWigner.cc,v 1.3 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -17,6 +17,7 @@
#include "Random/defs.h"
#include "CLHEP/Random/RandBreitWigner.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <algorithm> // for min() and max()
#include <cmath>
......@@ -49,7 +50,7 @@ double RandBreitWigner::shoot(double mean, double gamma)
double rval, displ;
rval = 2.0*HepRandom::getTheEngine()->flat()-1.0;
displ = 0.5*gamma*tan(rval*M_PI_2);
displ = 0.5*gamma*tan(rval*CLHEP::halfpi);
return mean + displ;
}
......@@ -72,7 +73,7 @@ double RandBreitWigner::shootM2(double mean, double gamma )
if ( gamma == 0.0 ) return mean;
val = atan(-mean/gamma);
rval = RandFlat::shoot(val, M_PI_2);
rval = RandFlat::shoot(val, CLHEP::halfpi);
displ = gamma*tan(rval);
return sqrt(mean*mean + mean*displ);
......@@ -128,7 +129,7 @@ double RandBreitWigner::shoot(HepRandomEngine* anEngine,
double rval, displ;
rval = 2.0*anEngine->flat()-1.0;
displ = 0.5*gamma*tan(rval*M_PI_2);
displ = 0.5*gamma*tan(rval*CLHEP::halfpi);
return mean + displ;
}
......@@ -153,7 +154,7 @@ double RandBreitWigner::shootM2(HepRandomEngine* anEngine,
if ( gamma == 0.0 ) return mean;
val = atan(-mean/gamma);
rval = RandFlat::shoot(anEngine,val, M_PI_2);
rval = RandFlat::shoot(anEngine,val, CLHEP::halfpi);
displ = gamma*tan(rval);
return sqrt(mean*mean + mean*displ);
......@@ -216,7 +217,7 @@ double RandBreitWigner::fire(double mean, double gamma)
double rval, displ;
rval = 2.0*localEngine->flat()-1.0;
displ = 0.5*gamma*tan(rval*M_PI_2);
displ = 0.5*gamma*tan(rval*CLHEP::halfpi);
return mean + displ;
}
......@@ -244,7 +245,7 @@ double RandBreitWigner::fireM2(double mean, double gamma )
if ( gamma == 0.0 ) return mean;
val = atan(-mean/gamma);
rval = RandFlat::shoot(localEngine,val, M_PI_2);
rval = RandFlat::shoot(localEngine,val, CLHEP::halfpi);
displ = gamma*tan(rval);
return sqrt(mean*mean + mean*displ);
......
// $Id: RandGaussQ.cc,v 1.2 2003/07/17 19:20:02 garren Exp $
// $Id: RandGaussQ.cc,v 1.3 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -13,6 +13,7 @@
#include "Random/defs.h"
#include "CLHEP/Random/RandGaussQ.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <iostream>
#include <cmath> // for log()
......@@ -172,7 +173,7 @@ double RandGaussQ::transformSmall (double r) {
s += 7*5*3 * vn2*vn2*vn2*vn2;
s += -5*3 * vn2*vn2*vn2;
s += 3 * vn2*vn2 - vn2 + 1.0;
v = sqrt ( 2.0 * log ( s / (r*guess*sqrt(2.0*M_PI)) ) );
v = sqrt ( 2.0 * log ( s / (r*guess*sqrt(CLHEP::twopi)) ) );
if ( fabs(v-guess) < eps ) break;
guess = v;
}
......
// $Id: RandPoisson.cc,v 1.3 2003/07/25 20:59:21 garren Exp $
// $Id: RandPoisson.cc,v 1.4 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -21,6 +21,7 @@
#include "Random/defs.h"
#include "CLHEP/Random/RandPoisson.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <cmath> // for floor()
namespace CLHEP {
......@@ -107,7 +108,7 @@ long RandPoisson::shoot(double xm) {
}
do {
do {
y = tan(M_PI*anEngine->flat());
y = tan(CLHEP::pi*anEngine->flat());
em = sq*y + xm;
} while( em < 0.0 );
em = floor(em);
......@@ -173,7 +174,7 @@ long RandPoisson::shoot(HepRandomEngine* anEngine, double xm) {
}
do {
do {
y = tan(M_PI*anEngine->flat());
y = tan(CLHEP::pi*anEngine->flat());
em = sq*y + xm;
} while( em < 0.0 );
em = floor(em);
......@@ -242,7 +243,7 @@ long RandPoisson::fire(double xm) {
}
do {
do {
y = tan(M_PI*localEngine->flat());
y = tan(CLHEP::pi*localEngine->flat());
em = sq*y + xm;
} while( em < 0.0 );
em = floor(em);
......
// $Id: flatToGaussian.cc,v 1.2 2003/07/17 19:20:02 garren Exp $
// $Id: flatToGaussian.cc,v 1.3 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -20,6 +20,7 @@
#include "CLHEP/Random/Stat.h"
#include "Random/defs.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <iostream>
#include <cmath>
......@@ -254,7 +255,7 @@ double transformSmall (double r) {
s += 7*5*3 * vn2*vn2*vn2*vn2;
s += -5*3 * vn2*vn2*vn2;
s += 3 * vn2*vn2 - vn2 + 1.0;
v = sqrt ( 2.0 * log ( s / (r*guess*sqrt(2.0*M_PI)) ) );
v = sqrt ( 2.0 * log ( s / (r*guess*sqrt(CLHEP::twopi)) ) );
if ( abs(v-guess) < eps ) break;
guess = v;
}
......@@ -294,11 +295,11 @@ double HepStat::erf (double x) {
// And the definition of the erf integral makes that derivative trivial.
// Ultimately,
//
// erf(x) = erfQ(x) - (inverseErf(erfQ(x))-x) * exp(-x**2) * 2/sqrt(M_PI)
// erf(x) = erfQ(x) - (inverseErf(erfQ(x))-x) * exp(-x**2) * 2/sqrt(CLHEP::pi)
//
double t0 = erfQ(x);
double deriv = exp(-x*x) * (2.0 / sqrt(M_PI));
double deriv = exp(-x*x) * (2.0 / sqrt(CLHEP::pi));
return t0 - (inverseErf (t0) - x) * deriv;
......
// $Id: gaussQtables.src,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: gaussQtables.src,v 1.2 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// gaussTables.src
......@@ -51,6 +51,7 @@
// --------------------------------------------------------------
#include "Random/defs.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <iostream>
#include <fstream>
#include <iomanip>
......@@ -187,7 +188,7 @@ int main() {
}
double pdf (double x) {
return exp(-x*x/2.0)/sqrt(2.0*M_PI);
return exp(-x*x/2.0)/sqrt(CLHEP::twopi);
}
......@@ -443,7 +444,7 @@ double approxErrInt (double v) {
// First approximation is e**(-v**2/2) / ( v* sqrt(2PI) )
double errInt = exp(-v*v/2);
errInt = - errInt / ( v*sqrt(2*M_PI) );
errInt = - errInt / ( v*sqrt(CLHEP::twopi) );
// correction factor of
// (1 - 1/v**2 + 3/v**4 - 3*5/v**6 + ... -3*5*7*9*11*13/v**14)
......
// $Id: gaussTables.src,v 1.1.1.1 2003/07/15 20:15:05 garren Exp $
// $Id: gaussTables.src,v 1.2 2003/08/08 13:47:09 garren Exp $
// -*- C++ -*-
//
// gaussTables.src
......@@ -50,6 +50,7 @@
// --------------------------------------------------------------
#include "Random/defs.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include <iostream>
#include <fstream>
#include <iomanip>
......@@ -186,7 +187,7 @@ int main() {
}
double pdf (double x) {
return exp(-x*x/2.0)/sqrt(2.0*M_PI);
return exp(-x*x/2.0)/sqrt(CLHEP::twopi);
}
......@@ -437,7 +438,7 @@ double approxErrInt (double v) {
// First approximation is e**(-v**2/2) / ( v* sqrt(2PI) )
double errInt = exp(-v*v/2);
errInt = - errInt / ( v*sqrt(2*M_PI) );
errInt = - errInt / ( v*sqrt(CLHEP::twopi) );
// correction factor of
// (1 - 1/v**2 + 3/v**4 - 3*5/v**6 + ... -3*5*7*9*11*13/v**14)
......
......@@ -7,6 +7,7 @@
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandPoissonT.h"
#include "CLHEP/Random/RandBit.h"
#include "CLHEP/Units/PhysicalConstants.h"
using std::cin;
using std::cout;
......@@ -168,9 +169,9 @@ if (choice==3) {
for ( x=1; x > .000000001; x *= .9 ) {
cout << x << std::setprecision(20) << " " <<
1 - exp(gammln1(x)) * exp(gammln1(2-x)) * sin(M_PI*(1-x)) / (M_PI*(1-x)) <<
1 - exp(gammln1(x)) * exp(gammln1(2-x)) * sin(CLHEP::pi*(1-x)) / (CLHEP::pi*(1-x)) <<
" " <<
1 - exp(gammln2(x)) * exp(gammln1(2-x)) * sin(M_PI*(1-x)) / (M_PI*(1-x)) <<
1 - exp(gammln2(x)) * exp(gammln1(2-x)) * sin(CLHEP::pi*(1-x)) / (CLHEP::pi*(1-x)) <<
"\n";
}
#endif // GAMMA
......
// -*- C++ -*-
// $Id: testRandDists.cc,v 1.3 2003/08/06 18:30:41 garren Exp $
// $Id: testRandDists.cc,v 1.4 2003/08/08 13:47:09 garren Exp $
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
......@@ -35,6 +35,7 @@
#include "CLHEP/Random/RandGaussT.h"
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandPoissonT.h"
#include "CLHEP/Units/PhysicalConstants.h"
#include "Random/defs.h"
#include <iostream>
#include <cmath> // double abs()
......@@ -98,7 +99,7 @@ double gammln(double x) {
for (int i = 0; i < 6; i++) {
ser += c[i]/(++y);
}
double ans = (-tmp + log (sqrt(2*M_PI)*ser/x));
double ans = (-tmp + log (sqrt(CLHEP::twopi)*ser/x));
return ans;
}
......@@ -486,9 +487,9 @@ bool poissonTest ( RandPoisson & dist, double mu, int N ) {
// and finally, p. Since we only care about it for small values,
// and never care about it past the 10% level, we can use the approximations
// CL(chi^2,n) = 1/sqrt(2*M_PI) * ErrIntC ( y ) with
// CL(chi^2,n) = 1/sqrt(CLHEP::twopi) * ErrIntC ( y ) with
// y = sqrt(2*chi2) - sqrt(2*n-1)
// errIntC (y) = exp((-y^2)/2)/(y*sqrt(2*M_PI))
// errIntC (y) = exp((-y^2)/2)/(y*sqrt(CLHEP::twopi))