GeNN
2.2.3
GPU enhanced Neuronal Networks (GeNN)
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
simulation_synapse_policy_sparse.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
simulation_synapse_policy_dense.h
"
4
5
// Standard includes
6
#include <functional>
7
#include <numeric>
8
9
//----------------------------------------------------------------------------
10
// SimulationSynapsePolicySparse
11
//----------------------------------------------------------------------------
12
class
SimulationSynapsePolicySparse
:
public
SimulationSynapsePolicyDense
13
{
14
public
:
15
//----------------------------------------------------------------------------
16
// Public API
17
//----------------------------------------------------------------------------
18
void
Init
()
19
{
20
#define SETUP_THE_C(I) \
21
case I: \
22
allocatesyn##I(10); \
23
theC= &Csyn##I; \
24
break;
25
26
// all different delay groups get same connectivity
27
for
(
int
i = 0; i < 10; i++)
28
{
29
// **YUCK** extract correct sparse projection
30
SparseProjection
*theC;
31
switch
(i)
32
{
33
SETUP_THE_C
(0)
34
SETUP_THE_C
(1)
35
SETUP_THE_C
(2)
36
SETUP_THE_C
(3)
37
SETUP_THE_C
(4)
38
SETUP_THE_C
(5)
39
SETUP_THE_C
(6)
40
SETUP_THE_C
(7)
41
SETUP_THE_C
(8)
42
SETUP_THE_C
(9)
43
};
44
45
// loop through pre-synaptic neurons
46
for
(
int
j = 0; j < 10; j++)
47
{
48
// each pre-synatic neuron gets one target neuron
49
unsigned
int
trg= (j + 1) % 10;
50
theC->
indInG
[j]= j;
51
theC->
ind
[j]= trg;
52
}
53
theC->
indInG
[10]= 10;
54
}
55
56
// Superclass
57
SimulationSynapsePolicyDense::Init
();
58
59
// for all synapse groups
60
for
(
int
i = 0; i < 10; i++)
61
{
62
// for all synapses
63
for
(
int
j = 0; j < 10; j++)
64
{
65
SetTheW
(i, j, 0.0f);
66
}
67
}
68
#ifndef CPU_ONLY
69
initializeAllSparseArrays();
70
#endif // CPU_ONLY
71
}
72
73
template
<
typename
UpdateFn,
typename
StepGeNNFn>
74
float
Simulate
(UpdateFn updateFn, StepGeNNFn stepGeNNFn)
75
{
76
float
err = 0.0f;
77
float
x[10][10];
78
for
(
int
i = 0; i < (int)(20.0f /
DT
); i++)
79
{
80
// **YUCK** update global time - this shouldn't be user responsibility
81
t = i *
DT
;
82
83
// for each delay
84
for
(
int
d = 0; d < 10; d++)
85
{
86
// for all pre-synaptic neurons
87
for
(
int
j = 0; j < 10; j++)
88
{
89
float
newX;
90
if
(updateFn(i, d, j, t, newX))
91
{
92
x[d][j] = newX;
93
}
94
else
if
(i == 0)
95
{
96
x[d][j] = 0.0f;
97
}
98
}
99
100
// Add error for this time step to total
101
err += std::inner_product(&x[d][0], &x[d][10],
102
GetTheW
(d),
103
0.0f,
104
std::plus<float>(),
105
[](
float
a,
float
b){
return
abs(a - b); });
106
}
107
108
// Step GeNN
109
stepGeNNFn();
110
}
111
112
return
err;
113
}
114
};
SimulationSynapsePolicyDense
Definition:
simulation_synapse_policy_dense.h:10
SimulationSynapsePolicyDense::GetTheW
float * GetTheW(unsigned int delay) const
Definition:
simulation_synapse_policy_dense.h:81
SETUP_THE_C
#define SETUP_THE_C(I)
SimulationSynapsePolicySparse::Simulate
float Simulate(UpdateFn updateFn, StepGeNNFn stepGeNNFn)
Definition:
simulation_synapse_policy_sparse.h:74
SparseProjection::ind
unsigned int * ind
Definition:
sparseProjection.h:20
SimulationSynapsePolicySparse
Definition:
simulation_synapse_policy_sparse.h:12
DT
#define DT
This defines the global time step at which the simulation will run.
Definition:
HHVclampGA_project/model/MBody1.cc:21
SimulationSynapsePolicySparse::Init
void Init()
Definition:
simulation_synapse_policy_sparse.h:18
SimulationSynapsePolicyDense::Init
void Init()
Definition:
simulation_synapse_policy_dense.h:16
SparseProjection::indInG
unsigned int * indInG
Definition:
sparseProjection.h:19
SimulationSynapsePolicyDense::SetTheW
void SetTheW(unsigned int i, unsigned int j, float value)
Definition:
simulation_synapse_policy_dense.h:86
simulation_synapse_policy_dense.h
SparseProjection
class (struct) for defining a spars connectivity projection
Definition:
sparseProjection.h:18
tests
utils
simulation_synapse_policy_sparse.h
Generated on Tue May 30 2017 12:01:09 for GeNN by
1.8.11