Commit c6611a58ca92533dfad0e785a9d842f8de85752a
Merge branch 'master' of git.stim.ee.uh.edu:codebase/stimlib into merging_VS
Showing
3 changed files
with
10 additions
and
12 deletions
Show diff stats
No preview for this file type
stim/iVote/ivote2.cuh
@@ -64,7 +64,7 @@ namespace stim { | @@ -64,7 +64,7 @@ namespace stim { | ||
64 | } | 64 | } |
65 | 65 | ||
66 | T th_step = ((Imax - Imin) / th_num); | 66 | T th_step = ((Imax - Imin) / th_num); |
67 | - vector<T> var_b; | 67 | + std::vector<T> var_b; |
68 | for (unsigned int t0 = 0; t0 < th_num; t0++) { | 68 | for (unsigned int t0 = 0; t0 < th_num; t0++) { |
69 | T th = t0 * th_step + Imin; | 69 | T th = t0 * th_step + Imin; |
70 | unsigned int n_b(0), n_o(0); //these variables save the number of elements that are below and over the threshold | 70 | unsigned int n_b(0), n_o(0); //these variables save the number of elements that are below and over the threshold |
@@ -86,7 +86,7 @@ namespace stim { | @@ -86,7 +86,7 @@ namespace stim { | ||
86 | var_b.push_back(n_b * n_o * pow((m_b - m_o), 2)); | 86 | var_b.push_back(n_b * n_o * pow((m_b - m_o), 2)); |
87 | } | 87 | } |
88 | 88 | ||
89 | - vector<float>::iterator max_var = std::max_element(var_b.begin(), var_b.end()); //finding maximum elements in the vector | 89 | + std::vector<float>::iterator max_var = std::max_element(var_b.begin(), var_b.end()); //finding maximum elements in the vector |
90 | size_t th_idx = std::distance(var_b.begin(), max_var); | 90 | size_t th_idx = std::distance(var_b.begin(), max_var); |
91 | T threshold = Imin + (T)(th_idx * th_step); | 91 | T threshold = Imin + (T)(th_idx * th_step); |
92 | return threshold; | 92 | return threshold; |
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 |