Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
06cf9d79
Commit
06cf9d79
authored
May 26, 2016
by
Lynn Garren
Browse files
changes from Gabriele Cosmo
parent
c2b1df2b
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Random/Random/CMakeLists.txt
View file @
06cf9d79
...
...
@@ -62,6 +62,8 @@ set( pkginclude_HEADERS DoubConv.hh
StaticRandomStates.h
TripleRand.h
mixmax.h
mixmax_skip_N8.icc
mixmax_skip_N17.icc
mixmax_skip_N256.icc
)
# notice that defs.h is not referenced here
...
...
Random/Random/MixMaxRng.h
View file @
06cf9d79
...
...
@@ -96,11 +96,11 @@ public:
bool
get
(
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:
//
Members defining
the current status of the generator.
//
Pointer to
the current status of the generator.
rng_state_st
*
fRngState
;
};
...
...
Random/Random/mixmax.h
View file @
06cf9d79
...
...
@@ -40,9 +40,10 @@ namespace CLHEP {
extern
"C"
{
#endif
const
int
N
=
256
;
/* The currently recommended N are 3150, 1260, 508, 256, 240, 88
Since the algorithm is linear in N, the cost per number is almost independent of N.
const
int
N
=
17
;
/* 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.
*/
#ifndef __LP64__
...
...
@@ -79,7 +80,7 @@ void print_state(rng_state_t* X);
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
guaranteed mathematically to be non-colliding with any other stream prepared from another set of 32bit IDs,
...
...
Random/Random/mixmax_skip_N17.icc
0 → 100644
View file @
06cf9d79
This diff is collapsed.
Click to expand it.
Random/Random/mixmax_skip_N8.icc
0 → 100644
View file @
06cf9d79
This diff is collapsed.
Click to expand it.
Random/src/MixMaxRng.cc
View file @
06cf9d79
...
...
@@ -136,7 +136,7 @@ void MixMaxRng::showStatus() const
void
MixMaxRng
::
setSeed
(
long
longSeed
,
int
/* extraSeed */
)
{
unsigned
long
seed0
,
seed1
=
0
,
seed2
=
0
,
seed3
=
0
;
unsigned
long
seed0
;
theSeed
=
longSeed
;
if
(
sizeof
(
long
)
>
4
)
// C standard says long is at least 32-bits
...
...
@@ -144,7 +144,7 @@ void MixMaxRng::setSeed(long longSeed, int /* extraSeed */)
else
seed0
=
longSeed
;
seed_
uniquestream
(
this
->
fRngState
,
seed3
,
seed2
,
seed1
,
seed0
);
seed_
spbox
(
fRngState
,
seed0
);
}
// Preferred Seeding method
...
...
@@ -175,7 +175,7 @@ void MixMaxRng::setSeeds(const long* Seeds, int seedNum)
}
theSeed
=
Seeds
[
0
];
theSeeds
=
Seeds
;
seed_uniquestream
(
this
->
fRngState
,
seed3
,
seed2
,
seed1
,
seed0
);
seed_uniquestream
(
fRngState
,
seed3
,
seed2
,
seed1
,
seed0
);
}
double
MixMaxRng
::
flat
()
...
...
@@ -183,9 +183,10 @@ double MixMaxRng::flat()
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
()
...
...
@@ -269,7 +270,7 @@ std::istream & MixMaxRng::getState ( std::istream& is )
<<
"
\n
Input stream is probably mispositioned now.
\n
"
;
return
is
;
}
if
(
fRngState
->
counter
<
0
||
fRngState
->
counter
>
N
-
1
)
{
if
(
fRngState
->
counter
<
0
||
fRngState
->
counter
>
rng_get_N
()
)
{
std
::
cerr
<<
"
\n
MixMaxRng::getState(): "
<<
"vector read wrong value of counter from file!"
<<
"
\n
Input stream is probably mispositioned now.
\n
"
;
...
...
Random/src/mixmax.cc
View file @
06cf9d79
...
...
@@ -254,7 +254,7 @@ inline myuint fmodmulM61(myuint cum, myuint a, myuint b){
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
;
ph
=
((
s
)
>>
32
);
pl
=
(
s
)
&
MASK32
;
...
...
@@ -379,10 +379,14 @@ myuint apply_bigskip(myuint* Vout, myuint* Vin, myID_t clusterID, myID_t machine
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
//#elif (N==256)
#include
"CLHEP/Random/mixmax_skip_N256.icc"
//
#include "CLHEP/Random/mixmax_skip_N256.icc"
//#elif (N==1000)
//#include "CLHEP/Random/mixmax_skip_N1000.icc"
//#elif (N==3150)
...
...
Random/test/MixMaxRng.oldsav
0 → 100644
View file @
06cf9d79
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;
Random/test/testThreaded.cc
View file @
06cf9d79
...
...
@@ -225,9 +225,9 @@ int main() {
CLHEP
::
MixMaxRng
engine1
;
CLHEP
::
MixMaxRng
engine2
;
CLHEP
::
MixMaxRng
engine3
;
if
(
std
::
fabs
(
engine1
.
flat
()
-
0.
92580
9
)
>
epsilon
||
std
::
fabs
(
engine2
.
flat
()
-
0.
9182
72
)
>
epsilon
||
std
::
fabs
(
engine3
.
flat
()
-
0.
0354222
)
>
epsilon
)
{
if
(
std
::
fabs
(
engine1
.
flat
()
-
0.
1304
9
)
>
epsilon
||
std
::
fabs
(
engine2
.
flat
()
-
0.
5195
72
)
>
epsilon
||
std
::
fabs
(
engine3
.
flat
()
-
0.
840834
)
>
epsilon
)
{
output
<<
"Error, default seeds changed for MixMaxRng random engine.
\n
"
;
return
1
;
}
...
...
Units/ChangeLog
View file @
06cf9d79
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>
* Units/SystemOfUnits.h, Units/PhysicalConstants.h:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment