Commit 478f365a79315b5bc286e627f914cde1b94c72a3
1 parent
029c021a
added pptx file format
Showing
2 changed files
with
8 additions
and
10 deletions
Show diff stats
No preview for this file type
stim/math/random.h
@@ -12,25 +12,23 @@ namespace stim{ | @@ -12,25 +12,23 @@ namespace stim{ | ||
12 | template<class T> | 12 | template<class T> |
13 | class Random{ | 13 | class Random{ |
14 | protected: | 14 | protected: |
15 | - void init(int seed = 0) | ||
16 | - { | ||
17 | - if(seed <= 0) | ||
18 | - srand(time(NULL)); | ||
19 | - else if(seed > 0) | ||
20 | - srand(time(seed)); | ||
21 | - else | ||
22 | - std::cout << "Error: Unknown value: in STIM::RANDOM" << std::endl; | 15 | + void init() { |
16 | + srand(time(NULL)); | ||
17 | + } | ||
18 | + | ||
19 | + void init(unsigned int seed){ | ||
20 | + srand(seed); | ||
23 | } | 21 | } |
24 | 22 | ||
25 | public: | 23 | public: |
26 | /// Default Constructor | 24 | /// Default Constructor |
27 | Random(){ | 25 | Random(){ |
28 | - init(-1); | 26 | + init(); |
29 | } | 27 | } |
30 | 28 | ||
31 | /// Constructor from a seed. | 29 | /// Constructor from a seed. |
32 | /// A positive seed sets, 0 or negative yeilds the | 30 | /// A positive seed sets, 0 or negative yeilds the |
33 | - Random(int seed){ | 31 | + Random(unsigned int seed){ |
34 | init(seed); | 32 | init(seed); |
35 | } | 33 | } |
36 | 34 |