Commit 4df14ead authored by Lynn Garren's avatar Lynn Garren
Browse files

change the names of internal variables so -Wshadow does not complain

parent 2e7f93f4
2012-02-01 Lynn Garren <garren@fnal.gov>
* change the names of internal variables so -Wshadow does not complain
==============================
16.12.11 Release CLHEP-2.1.2.0
==============================
......
......@@ -153,9 +153,9 @@ void MTwistEngine::setSeed(long seed, int k) {
theSeed = seed ? seed : 4357;
int mti;
const int N=624;
const int N1=624;
mt[0] = (unsigned int) (theSeed&0xffffffffUL);
for (mti=1; mti<N; mti++) {
for (mti=1; mti<N1; mti++) {
mt[mti] = (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
......
......@@ -154,13 +154,13 @@ double RandGaussQ::transformSmall (double r) {
for ( int i = 1; i < 50; i++ ) {
double vn2 = 1.0/(guess*guess);
double s = -13*11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2*vn2;
s += 11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2;
s += -9*7*5*3 * vn2*vn2*vn2*vn2*vn2;
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(CLHEP::twopi)) ) );
double s1 = -13*11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2*vn2;
s1 += 11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2;
s1 += -9*7*5*3 * vn2*vn2*vn2*vn2*vn2;
s1 += 7*5*3 * vn2*vn2*vn2*vn2;
s1 += -5*3 * vn2*vn2*vn2;
s1 += 3 * vn2*vn2 - vn2 + 1.0;
v = sqrt ( 2.0 * log ( s1 / (r*guess*sqrt(CLHEP::twopi)) ) );
if ( fabs(v-guess) < eps ) break;
guess = v;
}
......
......@@ -97,20 +97,20 @@ long RandPoisson::shoot(double xm) {
// (Adapted from Numerical Recipes in C)
double em, t, y;
double sq, alxm, g;
double sq, alxm, g1;
double om = getOldMean();
HepRandomEngine* anEngine = HepRandom::getTheEngine();
double* status = getPStatus();
sq = status[0];
alxm = status[1];
g = status[2];
g1 = status[2];
if( xm == -1 ) return 0;
if( xm < 12.0 ) {
if( xm != om ) {
setOldMean(xm);
g = exp(-xm);
g1 = exp(-xm);
}
em = -1;
t = 1.0;
......@@ -124,7 +124,7 @@ long RandPoisson::shoot(double xm) {
setOldMean(xm);
sq = sqrt(2.0*xm);
alxm = log(xm);
g = xm*alxm - gammln(xm + 1.0);
g1 = xm*alxm - gammln(xm + 1.0);
}
do {
do {
......@@ -140,14 +140,14 @@ long RandPoisson::shoot(double xm) {
if ( static_cast<long>(em) < 0 )
em = static_cast<long>(xm) >= 0 ? xm : getMaxMean();
}
setPStatus(sq,alxm,g);
setPStatus(sq,alxm,g1);
return long(em);
}
void RandPoisson::shootArray(const int size, long* vect, double m)
void RandPoisson::shootArray(const int size, long* vect, double m1)
{
for( long* v = vect; v != vect + size; ++v )
*v = shoot(m);
*v = shoot(m1);
}
long RandPoisson::shoot(HepRandomEngine* anEngine, double xm) {
......@@ -158,33 +158,33 @@ long RandPoisson::shoot(HepRandomEngine* anEngine, double xm) {
// (Adapted from Numerical Recipes in C)
double em, t, y;
double sq, alxm, g;
double sq, alxm, g1;
double om = getOldMean();
double* status = getPStatus();
sq = status[0];
alxm = status[1];
g = status[2];
g1 = status[2];
if( xm == -1 ) return 0;
if( xm < 12.0 ) {
if( xm != om ) {
setOldMean(xm);
g = exp(-xm);
g1 = exp(-xm);
}
em = -1;
t = 1.0;
do {
em += 1.0;
t *= anEngine->flat();
} while( t > g );
} while( t > g1 );
}
else if ( xm < getMaxMean() ) {
if ( xm != om ) {
setOldMean(xm);
sq = sqrt(2.0*xm);
alxm = log(xm);
g = xm*alxm - gammln(xm + 1.0);
g1 = xm*alxm - gammln(xm + 1.0);
}
do {
do {
......@@ -192,7 +192,7 @@ long RandPoisson::shoot(HepRandomEngine* anEngine, double xm) {
em = sq*y + xm;
} while( em < 0.0 );
em = floor(em);
t = 0.9*(1.0 + y*y)* exp(em*alxm - gammln(em + 1.0) - g);
t = 0.9*(1.0 + y*y)* exp(em*alxm - gammln(em + 1.0) - g1);
} while( anEngine->flat() > t );
}
else {
......@@ -200,15 +200,15 @@ long RandPoisson::shoot(HepRandomEngine* anEngine, double xm) {
if ( static_cast<long>(em) < 0 )
em = static_cast<long>(xm) >= 0 ? xm : getMaxMean();
}
setPStatus(sq,alxm,g);
setPStatus(sq,alxm,g1);
return long(em);
}
void RandPoisson::shootArray(HepRandomEngine* anEngine, const int size,
long* vect, double m)
long* vect, double m1)
{
for( long* v = vect; v != vect + size; ++v )
*v = shoot(anEngine,m);
*v = shoot(anEngine,m1);
}
long RandPoisson::fire() {
......@@ -223,31 +223,31 @@ long RandPoisson::fire(double xm) {
// (Adapted from Numerical Recipes in C)
double em, t, y;
double sq, alxm, g;
double sq, alxm, g1;
sq = status[0];
alxm = status[1];
g = status[2];
g1 = status[2];
if( xm == -1 ) return 0;
if( xm < 12.0 ) {
if( xm != oldm ) {
oldm = xm;
g = exp(-xm);
g1 = exp(-xm);
}
em = -1;
t = 1.0;
do {
em += 1.0;
t *= localEngine->flat();
} while( t > g );
} while( t > g1 );
}
else if ( xm < meanMax ) {
if ( xm != oldm ) {
oldm = xm;
sq = sqrt(2.0*xm);
alxm = log(xm);
g = xm*alxm - gammln(xm + 1.0);
g1 = xm*alxm - gammln(xm + 1.0);
}
do {
do {
......@@ -255,7 +255,7 @@ long RandPoisson::fire(double xm) {
em = sq*y + xm;
} while( em < 0.0 );
em = floor(em);
t = 0.9*(1.0 + y*y)* exp(em*alxm - gammln(em + 1.0) - g);
t = 0.9*(1.0 + y*y)* exp(em*alxm - gammln(em + 1.0) - g1);
} while( localEngine->flat() > t );
}
else {
......@@ -263,7 +263,7 @@ long RandPoisson::fire(double xm) {
if ( static_cast<long>(em) < 0 )
em = static_cast<long>(xm) >= 0 ? xm : getMaxMean();
}
status[0] = sq; status[1] = alxm; status[2] = g;
status[0] = sq; status[1] = alxm; status[2] = g1;
return long(em);
}
......@@ -273,10 +273,10 @@ void RandPoisson::fireArray(const int size, long* vect )
*v = fire( defaultMean );
}
void RandPoisson::fireArray(const int size, long* vect, double m)
void RandPoisson::fireArray(const int size, long* vect, double m1)
{
for( long* v = vect; v != vect + size; ++v )
*v = fire( m );
*v = fire( m1 );
}
std::ostream & RandPoisson::put ( std::ostream & os ) const {
......
......@@ -53,10 +53,10 @@ static const double prec = 4.6566128E-10;
std::string RanecuEngine::name() const {return "RanecuEngine";}
void RanecuEngine::further_randomize (int seq, int col, int index, int modulus)
void RanecuEngine::further_randomize (int seq1, int col, int index, int modulus)
{
table[seq][col] -= (index&0x3FFFFFFF);
while (table[seq][col] <= 0) table[seq][col] += (modulus-1);
table[seq1][col] -= (index&0x3FFFFFFF);
while (table[seq1][col] <= 0) table[seq1][col] += (modulus-1);
} // mf 6/22/10
// Number of instances with automatic seed selection
......
......@@ -249,13 +249,13 @@ double transformSmall (double r) {
for ( int i = 1; i < 50; i++ ) {
double vn2 = 1.0/(guess*guess);
double s = -13*11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2*vn2;
s += 11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2;
s += -9*7*5*3 * vn2*vn2*vn2*vn2*vn2;
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(CLHEP::twopi)) ) );
double s1 = -13*11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2*vn2;
s1 += 11*9*7*5*3 * vn2*vn2*vn2*vn2*vn2*vn2;
s1 += -9*7*5*3 * vn2*vn2*vn2*vn2*vn2;
s1 += 7*5*3 * vn2*vn2*vn2*vn2;
s1 += -5*3 * vn2*vn2*vn2;
s1 += 3 * vn2*vn2 - vn2 + 1.0;
v = sqrt ( 2.0 * log ( s1 / (r*guess*sqrt(CLHEP::twopi)) ) );
if ( abs(v-guess) < eps ) break;
guess = v;
}
......
......@@ -218,8 +218,8 @@ int main() {
output << "This should be a valid sequence." << std::endl;
for (int i=0; i < nNumbers; ++i) {
double r = g->flat();
if( ! printCheck(i,r,output) ) ++badcount;
double r1 = g->flat();
if( ! printCheck(i,r1,output) ) ++badcount;
}
pseeds=g->getTheSeeds();
output << "seeds[0] = " << pseeds[0] << "\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment