Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CLHEP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CLHEP
CLHEP
Commits
553b44d1
Commit
553b44d1
authored
18 years ago
by
Lynn Garren
Browse files
Options
Downloads
Patches
Plain Diff
improve seeding method - MF's fix
parent
84b96104
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Random/ChangeLog
+4
-0
4 additions, 0 deletions
Random/ChangeLog
Random/src/MTwistEngine.cc
+26
-6
26 additions, 6 deletions
Random/src/MTwistEngine.cc
with
30 additions
and
6 deletions
Random/ChangeLog
+
4
−
0
View file @
553b44d1
2006-11-15 Mark Fischler <mf@fnal.gov>
* Random/src/MTwistEngine.cc: improve seeding method
==============================
18.10.06 Release CLHEP-2.0.3.0
==============================
...
...
This diff is collapsed.
Click to expand it.
Random/src/MTwistEngine.cc
+
26
−
6
View file @
553b44d1
// $Id: MTwistEngine.cc,v 1.4.4.
2
200
5/04
/15 1
6:32:53
garren Exp $
// $Id: MTwistEngine.cc,v 1.4.4.
3
200
6/11
/15 1
7:23:01
garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
...
...
@@ -32,6 +32,10 @@
// getState() for anonymous restores 12/27/04
// M. Fischler - put/get for vectors of ulongs 3/14/05
// M. Fischler - State-saving using only ints, for portability 4/12/05
// M. Fischler - Improved seeding in setSeed (Savanah bug #17479) 11/15/06
// - (Possible optimization - now that the seeding is improved,
// is it still necessary for ctor to "warm up" by discarding
// 2000 iterations?)
//
// =======================================================================
...
...
@@ -164,15 +168,31 @@ void MTwistEngine::flatArray( const int size, double *vect ) {
}
void
MTwistEngine
::
setSeed
(
long
seed
,
int
k
)
{
// MF 11/15/06 - Change seeding algorithm to a newer one recommended
// by Matsumoto: The original algorithm was
// mt[i] = (69069 * mt[i-1]) & 0xffffffff and this gives
// problems when the seed bit pattern has lots of zeros
// (for example, 0x08000000). Savanah bug #17479.
theSeed
=
seed
?
seed
:
4357
;
mt
[
0
]
=
(
unsigned
int
)
theSeed
;
int
i
;
for
(
i
=
1
;
i
<
624
;
++
i
)
{
mt
[
i
]
=
(
69069
*
mt
[
i
-
1
])
&
0xffffffff
;
int
mti
;
const
int
N
=
624
;
mt
[
0
]
=
(
unsigned
int
)
(
theSeed
&
0xffffffffUL
);
for
(
mti
=
1
;
mti
<
N
;
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 */
/* only MSBs of the array mt[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
mt
[
mti
]
&=
0xffffffffUL
;
/* for >32 bit machines */
}
for
(
i
=
1
;
i
<
624
;
++
i
)
{
for
(
int
i
=
1
;
i
<
624
;
++
i
)
{
mt
[
i
]
^=
k
;
// MF 9/16/98: distinguish starting points
}
// MF 11/15/06 This distinction of starting points based on values of k
// is kept even though the seeding algorithm itself is improved.
}
void
MTwistEngine
::
setSeeds
(
const
long
*
seeds
,
int
k
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment