1 |
#include <iostream> |
2 |
#include <cmath> |
3 |
|
4 |
#include "randomSPRNG.hpp" |
5 |
#include "simError.h" |
6 |
|
7 |
|
8 |
/* randomStreamSPRNF creates a new SPRNG stream for random numbers |
9 |
*/ |
10 |
|
11 |
int ranStreamSPRNG::nSPRNGStreams; |
12 |
|
13 |
randomStreamSPRNG::randomStreamSPRNG(){ |
14 |
#ifdef IS_MPI |
15 |
|
16 |
|
17 |
|
18 |
#else |
19 |
nSPRNGStreams++; |
20 |
|
21 |
myStreamNumber = nSPRNGStreams; |
22 |
|
23 |
thisStream = init_sprng(GTYPE,streamnum,nstreams,SEED,SPRNG_DEFAULT); |
24 |
|
25 |
|
26 |
#endif |
27 |
} |
28 |
|
29 |
randomStreamSPRNG::~randomStreamSPRNG(){ |
30 |
|
31 |
free_sprng(int *thisStream); |
32 |
nSPRNGStreams--; |
33 |
|
34 |
|
35 |
} |
36 |
|
37 |
|
38 |
double getRanStreamSPRNG(){ |
39 |
double ranNum; |
40 |
nanNum = sprng(thisStream); |
41 |
return ranNum; |
42 |
} |