-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdynNode.cpp
221 lines (158 loc) · 4.21 KB
/
dynNode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#include "dynNode.h"
#include "gslNoise.h"
namespace conedy
{
baseType dynNode::time = 0.0;
void dynNode::setState( baseType a1, baseType a2 , baseType a3 , baseType a4 , baseType a5 , baseType a6 , baseType a7 , baseType a8 , baseType a9 , baseType a10 , baseType a11 , baseType a12 )
{
vector <baseType> argList;
argList.push_back (a1);
if (a2 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a2);
if (a3 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a3);
if (a4 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a4);
if (a5 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a5);
if (a6 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a6);
if (a7 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a7);
if (a8 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a8);
if (a9 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a9);
if (a10 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a10);
if (a11 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a11);
if (a12 == numeric_limits<baseType>::max())
{
setStateVec( argList);
return;
}
argList.push_back (a12);
setStateVec( argList);
return;
}
void dynNode::excite(baseType couplingStrength)
{
x[0]+= couplingStrength;
}
void dynNode::printStatistics(ostream &os, int nodeVerbosity, int edgeVerbosity ) {
node::printStatistics(os, nodeVerbosity, edgeVerbosity);
if (nodeVerbosity >= 2)
{
params<baseType>::printStatistics();
if (dimension() > 0)
{
cout << "state: " ;
for (unsigned int i = 0; i <dimension(); i++)
cout << x[i]<< " " ;
}
}
os << endl;
}
dynNode* dynNode::lookUp (nodeDescriptor n)
{
#ifdef DEBUG
if (!match (n, _dynNode_))
throw "Error. Trying to cast node to dynNode.!";
#endif
return (dynNode*) node::theNodes[n];
}
dynNode::dynNode ( networkElementType n, unsigned int dim): params<baseType>(n)
{
x = (baseType* ) calloc ( dim, sizeof (baseType));
}
dynNode::dynNode( const dynNode &b ) : node ( b ), params<baseType>(b)
{
if ( b.dimension() > 0 )
{
x = ( baseType* ) calloc ( b.dimension(),sizeof ( baseType ) );
for (unsigned int i = 0; i < b.dimension(); i++)
x[i] = b.x[i];
}
else
x = NULL;
}
/* void dynNode::setInitialConditionVec ( vector <baseType> argList )
{
dynamic_cast<dynNode*>( ( node::theNodes[nodeNumber] ) )->setInitialCondition(argList);
else
throw "Error. Der Knoten ist gar nicht vom Typ Dynnode.";
}
*/
void dynNode::randomizeState ( vector<boost::function<baseType () > > &r )
{
vector<baseType> values (r.size());
for ( unsigned int i = 0; i < r.size(); i++ )
values[i]=r[i]();
setStateVec (values);
}
void dynNode::setStateVec (vector <baseType> &r)
{
for (unsigned int i = 0 ; i < dimension(); i++)
x[i] = r[i];
}
bool match (nodeBlueprint *l, nodeDescriptor r)
{
if (l->getNodeInfo().theNodeKind == _dynNode_ && match (r, _dynNode_))
return true;
if (!match (l->getNodeInfo().theNodeType, r))
return false;
dynNode *n = (dynNode*) node::theNodes[r];
if ( l->isStandard())
{
return true;
}
else if (( l-> row == (n-> params<baseType>::row) || ( l->compareSheets( l-> row , n->row) ))) // match nodes, if their parameter are the same.
return true;
else
return false;
}
bool match (nodeDescriptor l, nodeBlueprint *r) {return match (r,l); }
baseType dynNode::endTime = 0.0;
baseType dynNode::startTime = 0.0;
}