From b2697bdeb2379a9facf14f202c91bf30c590b502 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 26 Sep 2016 12:23:57 +0200 Subject: [PATCH] Fixed minor casting bug in random stream and renamed them to camel case --- Cortex_mex.cpp | 1 + Cortical_Column.cpp | 6 ++---- Cortical_Column.h | 2 +- Random_Stream.h | 14 +++++++------- Stimulation.h | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cortex_mex.cpp b/Cortex_mex.cpp index 910089a..5b59ede 100644 --- a/Cortex_mex.cpp +++ b/Cortex_mex.cpp @@ -37,6 +37,7 @@ #include #include +#include "Cortical_Column.h" #include "Data_Storage.h" #include "Stimulation.h" mxArray* SetMexArray(int N, int M); diff --git a/Cortical_Column.cpp b/Cortical_Column.cpp index 5b6b239..4adb4b6 100644 --- a/Cortical_Column.cpp +++ b/Cortical_Column.cpp @@ -42,10 +42,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]()); @@ -67,12 +67,10 @@ double Cortical_Column::noise_aRK(int M) const{ /******************************************************************************/ /* Firing Rate functions */ /******************************************************************************/ -/* Pyramidal firing rate */ double Cortical_Column::get_Qp (int N) const{ return Qp_max / (1 + exp(-C1 * (Vp[N] - theta_p) / sigma_p)); } -/* Inhibitory firing rate */ double Cortical_Column::get_Qi (int N) const{ return Qi_max / (1 + exp(-C1 * (Vi[N] - theta_i) / sigma_i)); } diff --git a/Cortical_Column.h b/Cortical_Column.h index 81afd68..7ee6d03 100644 --- a/Cortical_Column.h +++ b/Cortical_Column.h @@ -80,7 +80,7 @@ class Cortical_Column { {var[0] = (-3*var[0] + 2*var[1] + 4*var[2] + 2*var[3] + var[4])/6 + noise_aRK(noise);} /* 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 7644107..5de540e 100644 --- a/Stimulation.h +++ b/Stimulation.h @@ -122,7 +122,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); @@ -167,7 +167,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