COPASI API  4.16.103
CMathEnum.h
Go to the documentation of this file.
1 // Copyright (C) 2011 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #ifndef COPASI_CMathEnum
7 #define COPASI_CMathEnum
8 
9 #include <map>
10 #include <vector>
11 
12 class CCopasiObject;
13 class CMathObject;
14 class CEvaluationNode;
15 
16 template <class Enum> class CMathFlags
17 {
18 public:
20  mFlags(0)
21  {}
22 
23  CMathFlags(const CMathFlags & src):
24  mFlags(src.mFlags)
25  {}
26 
27  CMathFlags(const Enum & flag):
28  mFlags((int) flag)
29  {}
30 
31  CMathFlags(const int & flag):
32  mFlags(flag)
33  {}
34 
36 
37  operator int () const
38  {
39  return mFlags;
40  }
41 
42  Enum operator & (const Enum & flag) const
43  {
44  return (Enum)(mFlags & flag);
45  }
46 
47  CMathFlags operator & (const CMathFlags & mask) const
48  {
49  return (mFlags & mask);
50  }
51 
52  CMathFlags operator & (const int & mask) const
53  {
54  return (mFlags & mask);
55  }
56 
58  {
59  mFlags = rhs.mFlags;
60  return *this;
61  }
62 
63  CMathFlags operator | (const Enum & flag) const
64  {
65  return (mFlags | flag);
66  }
67 
68  CMathFlags operator | (const CMathFlags & other) const
69  {
70  return (mFlags | other);
71  }
72 
74  {
75  mFlags |= other.mFlags;
76  return *this;
77  }
78 
79 private:
80  int mFlags;
81 };
82 
83 class CMath
84 {
85 public:
86  struct sPointers
87  {
88  public:
97 
106 
115 
124 
133 
142  };
143 
144 public:
146  {
147  Default = 0x0,
148  // This is used to indicate deterministic simulation
150  // This must be set when using the reduced model
151  UseMoieties = 0x2,
152  // This updates the total mass of a moiety and must be set
153  // at the beginning of the simulation or after events
155  // This is used to indicate stochastic simulation
156  Stochastic = 0x8,
157  // Event handling
159  };
160 
162 
164  {
180  };
181 
183  {
193  };
194 
196  {
208  };
209 
210  template < class Type > class Variables: public std::vector< Type >
211  {
212  public:
214  std::vector< Type >()
215  {}
216 
217  Variables(const std::vector< Type > & src):
218  std::vector< Type >(src)
219  {}
220 
222  {}
223  };
224 
226  {
227  public:
228  typedef std::vector< const CEvaluationNode * > StackElement;
229  typedef std::vector< StackElement > Buffer;
230 
231  friend std::ostream & operator << (std::ostream & os, const CVariableStack & s);
232 
233  enum Context
234  {
237  };
238 
239  private:
240  CVariableStack();
241 
242  public:
243  CVariableStack(Buffer & stack);
244 
245  CVariableStack(const CVariableStack & src);
246 
247  ~CVariableStack();
248 
249  void push(const StackElement & stackElement);
250 
251  void pop();
252 
253  size_t size() const;
254 
255  const CEvaluationNode * operator [](const size_t & index) const;
256 
257  private:
259 
260  private:
262 
264 
265  size_t mBodyLevel;
266  };
267 
269  {
270  public:
272  {
273  public:
274  friend std::ostream & operator << (std::ostream & os, const CAllocation & s);
275 
276  CAllocation();
277 
278  CAllocation(const CAllocation & src);
279 
280  ~CAllocation();
281 
282  CAllocation & operator = (const CAllocation & rhs);
283 
284  CAllocation & operator += (const CAllocation & rhs);
285 
287 
288  size_t nTotalRoots;
289 
290  std::vector< size_t > nRootsPerDiscontinuity;
291  };
292 
293  typedef std::vector< CAllocation > StackElement;
294  typedef std::vector< StackElement > Buffer;
295 
296  enum Context
297  {
300  };
301 
302  private:
304 
305  public:
306  CAllocationStack(Buffer & stack);
307 
308  CAllocationStack(const CAllocationStack & src);
309 
311 
312  void push(const StackElement & stackElement);
313 
314  void pop();
315 
316  size_t size() const;
317 
318  const CAllocation & operator [](const size_t & index) const;
319 
320  private:
322 
323  private:
325 
327 
328  size_t mBodyLevel;
329  };
330 };
331 
332 std::ostream & operator << (std::ostream & os, const CMath::CVariableStack & s);
333 
334 std::ostream & operator << (std::ostream & os, const CMath::CAllocationStack::CAllocation & s);
335 
336 #endif // COPASI_CMathEnum
C_FLOAT64 * pDiscontinuous
Definition: CMathEnum.h:114
CMathObject * pInitialTotalMassesObject
Definition: CMathEnum.h:122
CMathObject * pEventRootsObject
Definition: CMathEnum.h:137
C_FLOAT64 * pPropensities
Definition: CMathEnum.h:112
CMathObject * pDiscontinuousObject
Definition: CMathEnum.h:141
CMathObject * pIntensiveValuesObject
Definition: CMathEnum.h:126
const CEvaluationNode * operator[](const size_t &index) const
Definition: CMathEnum.cpp:59
friend std::ostream & operator<<(std::ostream &os, const CVariableStack &s)
Definition: CMathEnum.cpp:81
std::vector< StackElement > Buffer
Definition: CMathEnum.h:229
C_FLOAT64 * pInitialExtensiveRates
Definition: CMathEnum.h:91
C_FLOAT64 * pEventRoots
Definition: CMathEnum.h:110
SimulationType
Definition: CMathEnum.h:182
C_FLOAT64 * pEventDelays
Definition: CMathEnum.h:107
C_FLOAT64 * pEventRootStates
Definition: CMathEnum.h:111
CMathObject * pExtensiveValuesObject
Definition: CMathEnum.h:125
std::vector< StackElement > Buffer
Definition: CMathEnum.h:294
CMathObject * pInitialExtensiveValuesObject
Definition: CMathEnum.h:116
std::vector< CAllocation > StackElement
Definition: CMathEnum.h:293
CMathFlags(const Enum &flag)
Definition: CMathEnum.h:27
CAllocation & operator+=(const CAllocation &rhs)
Definition: CMathEnum.cpp:125
C_FLOAT64 * pTotalMasses
Definition: CMathEnum.h:104
Enum operator&(const Enum &flag) const
Definition: CMathEnum.h:42
CMathObject * pEventRootStatesObject
Definition: CMathEnum.h:138
CMathFlags & operator=(const CMathFlags &rhs)
Definition: CMathEnum.h:57
C_FLOAT64 * pInitialFluxes
Definition: CMathEnum.h:94
C_FLOAT64 * pParticleFluxes
Definition: CMathEnum.h:102
std::ostream & operator<<(std::ostream &os, const CMath::CVariableStack &s)
Definition: CMathEnum.cpp:81
CMathObject * pExtensiveRatesObject
Definition: CMathEnum.h:127
const CAllocation & operator[](const size_t &index) const
Definition: CMathEnum.cpp:178
C_FLOAT64 * pIntensiveRates
Definition: CMathEnum.h:101
CMathObject * pFluxesObject
Definition: CMathEnum.h:130
C_FLOAT64 * pInitialEventTriggers
Definition: CMathEnum.h:96
CMathFlags(const int &flag)
Definition: CMathEnum.h:31
EntityType
Definition: CMathEnum.h:195
C_FLOAT64 * pIntensiveValues
Definition: CMathEnum.h:99
C_FLOAT64 * pInitialIntensiveRates
Definition: CMathEnum.h:92
CMathFlags(const CMathFlags &src)
Definition: CMathEnum.h:23
CMathObject * pParticleFluxesObject
Definition: CMathEnum.h:129
ValueType
Definition: CMathEnum.h:163
CMathObject * pInitialIntensiveValuesObject
Definition: CMathEnum.h:117
CMathObject * pInitialIntensiveRatesObject
Definition: CMathEnum.h:119
C_FLOAT64 * pInitialParticleFluxes
Definition: CMathEnum.h:93
C_FLOAT64 * pEventPriorities
Definition: CMathEnum.h:108
C_FLOAT64 * pExtensiveRates
Definition: CMathEnum.h:100
~CMathFlags()
Definition: CMathEnum.h:35
C_FLOAT64 * pExtensiveValues
Definition: CMathEnum.h:98
Variables(const std::vector< Type > &src)
Definition: CMathEnum.h:217
SimulationContext
Definition: CMathEnum.h:145
C_FLOAT64 * pEventAssignments
Definition: CMathEnum.h:109
friend std::ostream & operator<<(std::ostream &os, const CAllocation &s)
Definition: CMathEnum.cpp:200
std::vector< size_t > nRootsPerDiscontinuity
Definition: CMathEnum.h:290
CMathFlags & operator|=(const CMathFlags &other)
Definition: CMathEnum.h:73
CMathObject * pEventTriggersObject
Definition: CMathEnum.h:132
CMathFlags()
Definition: CMathEnum.h:19
C_FLOAT64 * pInitialExtensiveValues
Definition: CMathEnum.h:89
CMathObject * pInitialEventTriggersObject
Definition: CMathEnum.h:123
CMathObject * pEventAssignmentsObject
Definition: CMathEnum.h:136
long int flag
Definition: f2c.h:52
std::vector< const CEvaluationNode * > StackElement
Definition: CMathEnum.h:228
CAllocation & operator=(const CAllocation &rhs)
Definition: CMathEnum.cpp:115
CMathObject * pEventDelaysObject
Definition: CMathEnum.h:134
#define C_FLOAT64
Definition: copasi.h:92
void push(const StackElement &stackElement)
Definition: CMathEnum.cpp:42
CMathFlags< SimulationContext > SimulationContextFlag
Definition: CMathEnum.h:161
int mFlags
Definition: CMathEnum.h:80
CMathObject * pInitialExtensiveRatesObject
Definition: CMathEnum.h:118
CMathFlags operator|(const Enum &flag) const
Definition: CMathEnum.h:63
size_t size() const
Definition: CMathEnum.cpp:54
CMathObject * pEventPrioritiesObject
Definition: CMathEnum.h:135
void push(const StackElement &stackElement)
Definition: CMathEnum.cpp:160
C_FLOAT64 * pEventTriggers
Definition: CMathEnum.h:105
CMathObject * pInitialFluxesObject
Definition: CMathEnum.h:121
CMathObject * pPropensitiesObject
Definition: CMathEnum.h:139
CMathObject * pDependentMassesObject
Definition: CMathEnum.h:140
C_FLOAT64 * pInitialTotalMasses
Definition: CMathEnum.h:95
C_FLOAT64 * pInitialIntensiveValues
Definition: CMathEnum.h:90
size_t size() const
Definition: CMathEnum.cpp:172
C_FLOAT64 * pDependentMasses
Definition: CMathEnum.h:113
C_FLOAT64 * pFluxes
Definition: CMathEnum.h:103
CMathObject * pIntensiveRatesObject
Definition: CMathEnum.h:128
CMathObject * pInitialParticleFluxesObject
Definition: CMathEnum.h:120
CMathObject * pTotalMassesObject
Definition: CMathEnum.h:131