ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/md_code/randomSPRNG.cpp
(Generate patch)

Comparing trunk/mdtools/md_code/randomSPRNG.cpp (file contents):
Revision 221 by chuckv, Thu Jan 2 20:14:08 2003 UTC vs.
Revision 223 by chuckv, Fri Jan 3 22:04:50 2003 UTC

# Line 3 | Line 3
3  
4   #include "randomSPRNG.hpp"
5   #include "simError.h"
6 + #include "sprng.h"
7 +
8   #ifdef IS_MPI
9   #include "mpiSimulation.hpp"
10   #endif
# Line 10 | Line 12 | int randomSPRNG::nStreamsInitialized;
12   /* randomStreamSPRNF creates a new SPRNG stream for random numbers
13   */
14  
15 < int randomSPRNG::nStreamsInitialized;
15 > int randomSPRNG::nStreamsInitialized = 0;
16  
17   randomSPRNG::randomSPRNG(iseed){
18 < #ifdef IS_MPI
18 >  int newSeed;
19    nStreamsInitialized++;
20 <  //Fix this
21 < #error "Fix instance of mpiSimulation in randomSPRNG"
20 <  nSPRNGStreams = getnumberProcessors();
21 <  myStreamNumber = nStreamsInitialized*(getMyNode() + nSPRNGStreams);
20 >  newSeed = abs(iseed) + nStreamsInitialized;  
21 >  if( newSeed < 0 ) newSeed = abs( newSeed );
22  
23 + #ifdef IS_MPI
24  
25 +  nSPRNGStreams = mpiSim->getNumberProcessors();
26 +
27 +  myStreamNumber = mpiSim->getMyNode();
28 +
29 +  
30 +
31   #else
32 <  nStreamsInitialized++;
32 >
33    nSPRNGStreams = 1;
34 <  myStreamNumber = nSPRNGStreams;
34 >  myStreamNumber = nStreamsInitialized;
35  
36   #endif
37  
38    thisStream = init_sprng(GTYPE,myStreamNumber,nSPRNGStreams,
39 <                          iseed,SPRNG_DEFAULT);
39 >                          newSeed,SPRNG_DEFAULT);
40   }
41  
42   randomSPRNG::~randomSPRNG(){
# Line 41 | Line 48 | double randomSPRNG::getRandom(){
48  
49  
50   double randomSPRNG::getRandom(){
51 <  double ranNum;
45 <  ranNum = sprng(thisStream);
46 <  return ranNum;
51 >  return sprng(thisStream);
52   }
53  
54  
55   // Gaussian SPRNG class...
56  
52 gaussianSPRNG::gaussianSPRNG() : randomSPRNG()
53 {
54 }
55
56 gaussianSPRNG::~gaussianSPRNG() : ~randomSPRNG()
57 {
58 }
59
57   double gaussianSPRNG::getGaussian(){
58    double ranNum1;
59    double ranNum2;
60    double gaussianNumber;
64  double R1;
65  double R2;
61  
62    ranNum1 = getRandom();
63    ranNum2 = getRandom();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines