Commit 06cf9d79 authored by Lynn Garren's avatar Lynn Garren
Browse files

changes from Gabriele Cosmo

parent c2b1df2b
...@@ -62,6 +62,8 @@ set( pkginclude_HEADERS DoubConv.hh ...@@ -62,6 +62,8 @@ set( pkginclude_HEADERS DoubConv.hh
StaticRandomStates.h StaticRandomStates.h
TripleRand.h TripleRand.h
mixmax.h mixmax.h
mixmax_skip_N8.icc
mixmax_skip_N17.icc
mixmax_skip_N256.icc ) mixmax_skip_N256.icc )
# notice that defs.h is not referenced here # notice that defs.h is not referenced here
......
...@@ -96,11 +96,11 @@ public: ...@@ -96,11 +96,11 @@ public:
bool get (const std::vector<unsigned long> & v); bool get (const std::vector<unsigned long> & v);
bool getState (const std::vector<unsigned long> & v); bool getState (const std::vector<unsigned long> & v);
static const unsigned int VECTOR_STATE_SIZE = 516; // 2N+4 for MIXMAX static const unsigned int VECTOR_STATE_SIZE = 2*N+4; // 2N+4 for MIXMAX
private: private:
// Members defining the current status of the generator. // Pointer to the current status of the generator.
rng_state_st* fRngState; rng_state_st* fRngState;
}; };
......
...@@ -40,9 +40,10 @@ namespace CLHEP { ...@@ -40,9 +40,10 @@ namespace CLHEP {
extern "C" { extern "C" {
#endif #endif
const int N = 256; const int N = 17;
/* The currently recommended N are 3150, 1260, 508, 256, 240, 88 /* The currently recommended N are 3150, 1260, 508, 256, 240, 88, 17, 8
Since the algorithm is linear in N, the cost per number is almost independent of N. Since the algorithm is linear in N, the cost per number is
almost independent of N.
*/ */
#ifndef __LP64__ #ifndef __LP64__
...@@ -79,7 +80,7 @@ void print_state(rng_state_t* X); ...@@ -79,7 +80,7 @@ void print_state(rng_state_t* X);
typedef uint32_t myID_t; typedef uint32_t myID_t;
void seed_uniquestream(rng_state_t* X, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID ); void seed_uniquestream(rng_state_t* X, myID_t clusterID, myID_t machineID, myID_t runID, myID_t streamID);
/* /*
best choice: will make a state vector from which you can get at least 10^100 numbers best choice: will make a state vector from which you can get at least 10^100 numbers
guaranteed mathematically to be non-colliding with any other stream prepared from another set of 32bit IDs, guaranteed mathematically to be non-colliding with any other stream prepared from another set of 32bit IDs,
......
This diff is collapsed.
This diff is collapsed.
...@@ -136,7 +136,7 @@ void MixMaxRng::showStatus() const ...@@ -136,7 +136,7 @@ void MixMaxRng::showStatus() const
void MixMaxRng::setSeed(long longSeed, int /* extraSeed */) void MixMaxRng::setSeed(long longSeed, int /* extraSeed */)
{ {
unsigned long seed0, seed1= 0, seed2= 0, seed3= 0; unsigned long seed0;
theSeed = longSeed; theSeed = longSeed;
if( sizeof(long) > 4) // C standard says long is at least 32-bits if( sizeof(long) > 4) // C standard says long is at least 32-bits
...@@ -144,7 +144,7 @@ void MixMaxRng::setSeed(long longSeed, int /* extraSeed */) ...@@ -144,7 +144,7 @@ void MixMaxRng::setSeed(long longSeed, int /* extraSeed */)
else else
seed0= longSeed; seed0= longSeed;
seed_uniquestream(this->fRngState, seed3, seed2, seed1, seed0 ); seed_spbox(fRngState, seed0);
} }
// Preferred Seeding method // Preferred Seeding method
...@@ -175,7 +175,7 @@ void MixMaxRng::setSeeds(const long* Seeds, int seedNum) ...@@ -175,7 +175,7 @@ void MixMaxRng::setSeeds(const long* Seeds, int seedNum)
} }
theSeed = Seeds[0]; theSeed = Seeds[0];
theSeeds = Seeds; theSeeds = Seeds;
seed_uniquestream(this->fRngState, seed3, seed2, seed1, seed0 ); seed_uniquestream(fRngState, seed3, seed2, seed1, seed0);
} }
double MixMaxRng::flat() double MixMaxRng::flat()
...@@ -183,9 +183,10 @@ double MixMaxRng::flat() ...@@ -183,9 +183,10 @@ double MixMaxRng::flat()
return get_next_float(fRngState); return get_next_float(fRngState);
} }
void MixMaxRng::flatArray(const int size, double* arrayDbl ) void MixMaxRng::flatArray(const int size, double* vect )
{ {
fill_array( fRngState, size, arrayDbl ); // fill_array( fRngState, size, arrayDbl );
for (int i=0; i<size; ++i) { vect[i] = flat(); }
} }
MixMaxRng::operator unsigned int() MixMaxRng::operator unsigned int()
...@@ -269,7 +270,7 @@ std::istream & MixMaxRng::getState ( std::istream& is ) ...@@ -269,7 +270,7 @@ std::istream & MixMaxRng::getState ( std::istream& is )
<< "\nInput stream is probably mispositioned now.\n"; << "\nInput stream is probably mispositioned now.\n";
return is; return is;
} }
if ( fRngState->counter < 0 || fRngState->counter > N-1 ) { if ( fRngState->counter < 0 || fRngState->counter > rng_get_N() ) {
std::cerr << "\nMixMaxRng::getState(): " std::cerr << "\nMixMaxRng::getState(): "
<< "vector read wrong value of counter from file!" << "vector read wrong value of counter from file!"
<< "\nInput stream is probably mispositioned now.\n"; << "\nInput stream is probably mispositioned now.\n";
......
...@@ -254,7 +254,7 @@ inline myuint fmodmulM61(myuint cum, myuint a, myuint b){ ...@@ -254,7 +254,7 @@ inline myuint fmodmulM61(myuint cum, myuint a, myuint b){
inline myuint fmodmulM61(myuint cum, myuint s, myuint a) inline myuint fmodmulM61(myuint cum, myuint s, myuint a)
{ {
register myuint o,ph,pl,ah,al; myuint o,ph,pl,ah,al;
o=(s)*a; o=(s)*a;
ph = ((s)>>32); ph = ((s)>>32);
pl = (s) & MASK32; pl = (s) & MASK32;
...@@ -379,10 +379,14 @@ myuint apply_bigskip(myuint* Vout, myuint* Vin, myID_t clusterID, myID_t machine ...@@ -379,10 +379,14 @@ myuint apply_bigskip(myuint* Vout, myuint* Vin, myID_t clusterID, myID_t machine
const myuint skipMat[128][N] = const myuint skipMat[128][N] =
//#if (N==88) //#if (N==8)
//#include "CLHEP/Random/mixmax_skip_N8.icc"
//#elif (N==17)
#include "CLHEP/Random/mixmax_skip_N17.icc"
//#elif (N==88)
//#include "CLHEP/Random/mixmax_skip_N88.icc" // to make this file, delete all except some chosen 128 rows of the coefficients table //#include "CLHEP/Random/mixmax_skip_N88.icc" // to make this file, delete all except some chosen 128 rows of the coefficients table
//#elif (N==256) //#elif (N==256)
#include "CLHEP/Random/mixmax_skip_N256.icc" //#include "CLHEP/Random/mixmax_skip_N256.icc"
//#elif (N==1000) //#elif (N==1000)
//#include "CLHEP/Random/mixmax_skip_N1000.icc" //#include "CLHEP/Random/mixmax_skip_N1000.icc"
//#elif (N==3150) //#elif (N==3150)
......
mixmax state, file version 1.0
N=17; V[N]={1453984192957921435, 804652513657857407, 270418329788844794, 741834957927375096, 1741281920985478599, 1332641075228742960, 2099232912322291429, 1738741064982476428, 566812234924154600, 1229365387441643041, 149491510002607069, 1952100454524859547, 2081178518358049274, 2237709327787214286, 588540303762780558, 691158626143021296, 1292807317550370760}; counter=4; sumtot=219363565422443020;
...@@ -225,9 +225,9 @@ int main() { ...@@ -225,9 +225,9 @@ int main() {
CLHEP::MixMaxRng engine1; CLHEP::MixMaxRng engine1;
CLHEP::MixMaxRng engine2; CLHEP::MixMaxRng engine2;
CLHEP::MixMaxRng engine3; CLHEP::MixMaxRng engine3;
if(std::fabs(engine1.flat() - 0.925809) > epsilon || if(std::fabs(engine1.flat() - 0.13049) > epsilon ||
std::fabs(engine2.flat() - 0.918272) > epsilon || std::fabs(engine2.flat() - 0.519572) > epsilon ||
std::fabs(engine3.flat() - 0.0354222) > epsilon) { std::fabs(engine3.flat() - 0.840834) > epsilon) {
output << "Error, default seeds changed for MixMaxRng random engine.\n"; output << "Error, default seeds changed for MixMaxRng random engine.\n";
return 1; return 1;
} }
......
2016-05-10 Gabriele Cosmo <Gabriele.Cosmo@cern.ch>
* SystemOfUnits.h, PhysicalConstants.h: converted all symbols and
constants from "static const" to "static constexpr".
Added symbols 'us' and 'ps' for microsecond and picosecond respectively;
updated Evaluator/src/setSystemOfUnits.cc accordingly.
* mixmax.[h,cc]: changed default number of N in mixmax generator to 17
(was 256). Removed use of obsolete 'register' keyword.
* Provided new skipping coefficients for the new value of N and for the
case N=8.
* MixMaxRng.[h,cc]: use simple loop for flatArray(); engine built-in
function turns out to be extremely slow and unefficient.
Use seed_spbox() for seeding MixMax with single seed.
Avoid hard-coded constant for initialisation of VECTOR_STATE_SIZE in
MixMaxRng, to directly use actual value of "N" from mixmax generator.
Corrected check for counter range in method getState().
2016-04-22 Lynn Garren <garren@fnal.gov> 2016-04-22 Lynn Garren <garren@fnal.gov>
* Units/SystemOfUnits.h, Units/PhysicalConstants.h: * Units/SystemOfUnits.h, Units/PhysicalConstants.h:
......
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