From 4a9f959add0d78d72dc8780eeb1853ba9ffa77ef Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 26 Sep 2016 12:22:25 +0200 Subject: [PATCH] Fixed a minor casting bug in random stream implementation and renamed the streams to camel case --- Cortical_Column.cpp | 4 ++-- Cortical_Column.h | 2 +- Random_Stream.h | 14 +++++++------- Stimulation.h | 4 ++-- Thalamic_Column.cpp | 4 ++-- Thalamic_Column.h | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cortical_Column.cpp b/Cortical_Column.cpp index f78eea4..e8fe366 100644 --- a/Cortical_Column.cpp +++ b/Cortical_Column.cpp @@ -48,10 +48,10 @@ void Cortical_Column::set_RNG(void) { Rand_vars.reserve(2*numRandomVariables); for (unsigned i=0; i < numRandomVariables; ++i){ /* Add the RNG for I_{l}*/ - MTRands.push_back(random_stream_normal(0.0, dphi*dt)); + MTRands.push_back(randomStreamNormal(0.0, dphi*dt)); /* Add the RNG for I_{l,0} */ - MTRands.push_back(random_stream_normal(0.0, dt)); + MTRands.push_back(randomStreamNormal(0.0, dt)); /* Get the random number for the first iteration */ Rand_vars.push_back(MTRands[2*i]()); diff --git a/Cortical_Column.h b/Cortical_Column.h index 6209818..7c4ec60 100644 --- a/Cortical_Column.h +++ b/Cortical_Column.h @@ -170,7 +170,7 @@ class Cortical_Column { const std::vector B = {0.75, 0.75, 0.0, 0.0}; /* Random number generators */ - std::vector MTRands; + std::vector MTRands; /* Container for noise */ std::vector Rand_vars; diff --git a/Random_Stream.h b/Random_Stream.h index 6695d38..7cc9120 100644 --- a/Random_Stream.h +++ b/Random_Stream.h @@ -29,11 +29,11 @@ #pragma once #include -class random_stream_normal { +class randomStreamNormal { public: - explicit random_stream_normal(double mean, double stddev) + explicit randomStreamNormal(double mean, double stddev) : mt(rand()), norm_dist(mean, stddev) {} - explicit random_stream_normal(double mean, double stddev, double seed) + explicit randomStreamNormal(double mean, double stddev, double seed) : mt(seed), norm_dist(mean, stddev) {} double operator ()(void) { return norm_dist(mt); } @@ -42,14 +42,14 @@ class random_stream_normal { std::normal_distribution norm_dist; }; -class random_stream_uniform_int { +class randomStreamUniformInt { public: - explicit random_stream_uniform_int(int lower_bound, int upper_bound) + explicit randomStreamUniformInt(int lower_bound, int upper_bound) : mt(rand()), uniform_dist(lower_bound, upper_bound) {} - explicit random_stream_uniform_int(int lower_bound, int upper_bound, double seed) + explicit randomStreamUniformInt(int lower_bound, int upper_bound, double seed) : mt(seed), uniform_dist(lower_bound, upper_bound) {} - double operator ()(void) { return uniform_dist(mt); } + int operator ()(void) { return uniform_dist(mt); } private: std::mt19937_64 mt; std::uniform_int_distribution<> uniform_dist; diff --git a/Stimulation.h b/Stimulation.h index 55b6523..21e0449 100644 --- a/Stimulation.h +++ b/Stimulation.h @@ -141,7 +141,7 @@ class Stim { std::vector marker_stimulation; /* Random number generator in case of semi-periodic stimulation */ - random_stream_uniform_int Uniform_Distribution = random_stream_uniform_int(0, 0); + randomStreamUniformInt Uniform_Distribution = randomStreamUniformInt(0, 0); /* Create MATLAB container for marker storage */ friend mxArray* get_marker(Stim &stim); @@ -190,7 +190,7 @@ void Stim::setup (double* var_stim) { /* If ISI is random create RNG */ if (ISI_range != 0){ /* Generate uniform distribution */ - Uniform_Distribution = random_stream_uniform_int(ISI-ISI_range, ISI+ISI_range); + Uniform_Distribution = randomStreamUniformInt(ISI-ISI_range, ISI+ISI_range); } } else { /* In case of phase dependent stimulation, time_to_stim is the time from minimum detection to start of stimulation */ diff --git a/Thalamic_Column.cpp b/Thalamic_Column.cpp index c697ffc..571b562 100644 --- a/Thalamic_Column.cpp +++ b/Thalamic_Column.cpp @@ -44,10 +44,10 @@ void Thalamic_Column::set_RNG(void) { Rand_vars.reserve(2*numRandomVariables); for (unsigned i=0; i < numRandomVariables; ++i){ /* Add the RNG for I_{l}*/ - MTRands.push_back(random_stream_normal(0.0, dphi*dt)); + MTRands.push_back(randomStreamNormal(0.0, dphi*dt)); /* Add the RNG for I_{l,0} */ - MTRands.push_back(random_stream_normal(0.0, dt)); + MTRands.push_back(randomStreamNormal(0.0, dt)); /* Get the random number for the first iteration */ Rand_vars.push_back(MTRands[2*i]()); diff --git a/Thalamic_Column.h b/Thalamic_Column.h index 4301e28..045c6c3 100644 --- a/Thalamic_Column.h +++ b/Thalamic_Column.h @@ -214,7 +214,7 @@ class Thalamic_Column { const std::vector B = {0.75, 0.75, 0.0, 0.0}; /* Random number generators */ - std::vector MTRands; + std::vector MTRands; /* Container for noise */ std::vector Rand_vars;