GeNN  3.3.0
GPU enhanced Neuronal Networks (GeNN)
initVarSnippet.h
Go to the documentation of this file.
1 #pragma once
2 
3 // GeNN includes
4 #include "snippet.h"
5 
6 //----------------------------------------------------------------------------
7 // Macros
8 //----------------------------------------------------------------------------
9 #define SET_CODE(CODE) virtual std::string getCode() const override{ return CODE; }
10 
11 //----------------------------------------------------------------------------
12 // InitVarSnippet::Base
13 //----------------------------------------------------------------------------
15 namespace InitVarSnippet
16 {
17 class Base : public Snippet::Base
18 {
19 public:
20  //----------------------------------------------------------------------------
21  // Declared virtuals
22  //----------------------------------------------------------------------------
23  virtual std::string getCode() const{ return ""; }
24 };
25 
26 //----------------------------------------------------------------------------
27 // InitVarSnippet::Uninitialised
28 //----------------------------------------------------------------------------
30 class Uninitialised : public Base
31 {
32 public:
34 };
35 
36 //----------------------------------------------------------------------------
37 // InitVarSnippet::Constant
38 //----------------------------------------------------------------------------
40 
46 class Constant : public Base
47 {
48 public:
50 
51  SET_CODE("$(value) = $(constant);");
52 
53  SET_PARAM_NAMES({"constant"});
54 };
55 
56 //----------------------------------------------------------------------------
57 // InitVarSnippet::Uniform
58 //----------------------------------------------------------------------------
60 
64 class Uniform : public Base
65 {
66 public:
68 
69  SET_CODE(
70  "const scalar scale = $(max) - $(min);\n"
71  "$(value) = $(min) + ($(gennrand_uniform) * scale);");
72 
73  SET_PARAM_NAMES({"min", "max"});
74 };
75 
76 //----------------------------------------------------------------------------
77 // InitVarSnippet::Normal
78 //----------------------------------------------------------------------------
80 
84 class Normal : public Base
85 {
86 public:
88 
89  SET_CODE("$(value) = $(mean) + ($(gennrand_normal) * $(sd));");
90 
91  SET_PARAM_NAMES({"mean", "sd"});
92 };
93 
94 //----------------------------------------------------------------------------
95 // InitVarSnippet::Exponential
96 //----------------------------------------------------------------------------
98 
101 class Exponential : public Base
102 {
103 public:
105 
106  SET_CODE("$(value) = $(lambda) * $(gennrand_exponential);");
107 
108  SET_PARAM_NAMES({"lambda"});
109 };
110 
111 //----------------------------------------------------------------------------
112 // InitVarSnippet::Gamma
113 //----------------------------------------------------------------------------
115 
118 class Gamma : public Base
119 {
120 public:
122 
123  SET_CODE("$(value) = $(b) * $(gennrand_gamma, $(a));");
124 
125  SET_PARAM_NAMES({"a", "b"});
126 };
127 } // namespace InitVarSnippet
Initialises variable by sampling from the exponential distribution.
Definition: initVarSnippet.h:101
Initialises variable by sampling from the exponential distribution.
Definition: initVarSnippet.h:118
Initialises variable to a constant value.
Definition: initVarSnippet.h:46
Initialises variable by sampling from the normal distribution.
Definition: initVarSnippet.h:84
Used to mark variables as uninitialised - no initialisation code will be run.
Definition: initVarSnippet.h:30
Initialises variable by sampling from the uniform distribution.
Definition: initVarSnippet.h:64
#define DECLARE_SNIPPET(TYPE, NUM_PARAMS)
Definition: snippet.h:11
Definition: initVarSnippet.h:17
Base class for all value initialisation snippets.
Definition: initVarSnippet.h:15
Base class for all code snippets.
Definition: snippet.h:105
#define SET_PARAM_NAMES(...)
Definition: snippet.h:28
#define SET_CODE(CODE)
Definition: initVarSnippet.h:9
virtual std::string getCode() const
Definition: initVarSnippet.h:23