Permalink
Browse files

Major cleanup and code modernization

  • Loading branch information...
1 parent d3adf69 commit d86ed6a219c3a4c69f2fba6d0460abb7b19c7acb @miscco committed Sep 13, 2016
Showing with 435 additions and 553 deletions.
  1. +8 −19 Data_Storage.h
  2. +10 −7 NM_Thalamus.pro
  3. +22 −45 Random_Stream.h
  4. +117 −188 Thalamic_Column.cpp
  5. +179 −190 Thalamic_Column.h
  6. +30 −36 Thalamus.cpp
  7. +69 −68 Thalamus_mex.cpp
View
@@ -20,28 +20,17 @@
* THE SOFTWARE.
*
* AUTHORS: Michael Schellenberger Costa: mschellenbergercosta@gmail.com
- *
- * Based on: A thalamocortical neural mass model of the EEG during NREM sleep and its response
- * to auditory stimulation.
- * M Schellenberger Costa, A Weigenand, H-VV Ngo, L Marshall, J Born, T Martinetz,
- * JC Claussen.
- * PLoS Computational Biology (in review).
*/
-/****************************************************************************************************/
-/* Functions for data storage */
-/****************************************************************************************************/
+/******************************************************************************/
+/* Functions for data storage */
+/******************************************************************************/
#pragma once
+#include <vector>
#include "Thalamic_Column.h"
-/****************************************************************************************************/
-/* Save data */
-/****************************************************************************************************/
-void get_data(int counter, Thalamic_Column& Col, double* Vt, double* Vr, double* ah) {
- Vt [counter] = Col.Vt [0];
- Vr [counter] = Col.Vr [0];
- ah [counter] = Col.act_h ();
+void get_data(unsigned counter, Thalamic_Column& Thalamus, std::vector<double*> pData) {
+ pData[0][counter] = Thalamus.Vt [0];
+ pData[0][counter] = Thalamus.Vr [0];
+ pData[0][counter] = Thalamus.act_h ();
}
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
View
@@ -6,14 +6,17 @@ CONFIG -= qt
TARGET = Thalamus.cpp
SOURCES += Thalamic_Column.cpp \
- Thalamus.cpp \
- Thalamus_mex.cpp
+ Thalamus.cpp \
+ Thalamus_mex.cpp
HEADERS += Data_Storage.h \
- ODE.h \
- Random_Stream.h \
- Thalamic_Column.h
-
-QMAKE_CXXFLAGS += -std=c++11 -O3
+ ODE.h \
+ Random_Stream.h \
+ Thalamic_Column.h
SOURCES -= Thalamus_mex.cpp
+
+QMAKE_CXXFLAGS += -std=c++11
+QMAKE_CXXFLAGS_RELEASE -= -O1
+QMAKE_CXXFLAGS_RELEASE -= -O2
+QMAKE_CXXFLAGS_RELEASE *= -O3
View
@@ -23,58 +23,35 @@
* Stefanie Gareis: gareis@inb.uni-luebeck.de
*/
-/****************************************************************************************************/
-/* Random number streams */
-/****************************************************************************************************/
+/******************************************************************************/
+/* Random number streams */
+/******************************************************************************/
#pragma once
#include <random>
-/****************************************************************************************************/
-/* Struct for normal distribution */
-/****************************************************************************************************/
-struct random_stream_normal
-{
- /* Random number engine: Mersenne-Twister */
+class random_stream_normal {
+public:
+ explicit random_stream_normal(double mean, double stddev)
+ : mt(rand()), norm_dist(mean, stddev) {}
+ explicit random_stream_normal(double mean, double stddev, double seed)
+ : mt(seed), norm_dist(mean, stddev) {}
+
+ double operator ()(void) { return norm_dist(mt); }
+private:
std::mt19937_64 mt;
- /* Random number generator: Normal-distribution */
std::normal_distribution<double> norm_dist;
-
- /* Constructors */
- random_stream_normal(){}
- random_stream_normal(double mean, double stddev)
- : mt(rand()) , norm_dist(mean, stddev)
- {}
-
- /* Overwrites the function-call operator "( )" */
- double operator( )(void) {
- return norm_dist(mt);
- }
};
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
-/****************************************************************************************************/
-/* Struct for uniform int distribution */
-/****************************************************************************************************/
-struct random_stream_uniform_int
-{
- /* Random number engine: Mersenne-Twister */
+class random_stream_uniform_int {
+public:
+ explicit random_stream_uniform_int(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)
+ : mt(seed), uniform_dist(lower_bound, upper_bound) {}
+
+ double operator ()(void) { return uniform_dist(mt); }
+private:
std::mt19937_64 mt;
- /* Random number generator: Uniform integer-distribution */
std::uniform_int_distribution<> uniform_dist;
-
- /* Constructors */
- random_stream_uniform_int(){}
- random_stream_uniform_int(double lower_bound, double upper_bound)
- : mt(rand()) , uniform_dist(lower_bound, upper_bound)
- {}
-
- /* Overwrites the function-call operator "( )" */
- double operator( )(void) {
- return uniform_dist(mt);
- }
};
-/****************************************************************************************************/
-/* end */
-/****************************************************************************************************/
+
Oops, something went wrong.

0 comments on commit d86ed6a

Please sign in to comment.