COPASI API  4.16.103
CMathEnum.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/math/CMathEnum.cpp,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/06/07 19:59:41 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #include "copasi.h"
15 
16 #include "CMathEnum.h"
17 
19  mpStack(NULL),
20  mContext(Body),
21  mVariableLevel(C_INVALID_INDEX),
22  mBodyLevel(C_INVALID_INDEX)
23 {}
24 
26  mpStack(&stack),
27  mContext(Body),
28  mVariableLevel(C_INVALID_INDEX),
29  mBodyLevel(C_INVALID_INDEX)
30 {}
31 
33  mpStack(src.mpStack),
34  mContext(src.mContext),
35  mVariableLevel(src.mVariableLevel),
36  mBodyLevel(src.mBodyLevel)
37 {}
38 
40 {}
41 
43 {
44  mpStack->push_back(stackElement);
45  mBodyLevel++;
46 }
47 
49 {
50  mpStack->pop_back();
51  mBodyLevel--;
52 }
53 
55 {
56  return mpStack->size();
57 }
58 
59 const CEvaluationNode * CMath::CVariableStack::operator [](const size_t & index) const
60 {
61  size_t Level = C_INVALID_INDEX;
62 
63  switch (mContext)
64  {
65  case Variable:
66  Level = mVariableLevel;
67  break;
68 
69  case Body:
70  Level = mBodyLevel;
71 
72  break;
73  }
74 
75  assert(Level < mpStack->size());
76  assert(index < mpStack->at(Level).size());
77 
78  return mpStack->at(Level)[index];
79 }
80 
81 std::ostream & operator << (std::ostream & os, const CMath::CVariableStack & s)
82 {
83  switch (s.mContext)
84  {
86  os << "Context: variable ";
87  break;
88 
90  os << "Context: body ";
91  break;
92  }
93 
94  os << "Variable Level: " << s.mVariableLevel << " Body Level: " << s.mBodyLevel;
95 
96  return os;
97 }
98 
100  nDiscontinuous(0),
101  nTotalRoots(0),
102  nRootsPerDiscontinuity()
103 {}
104 
106  nDiscontinuous(src.nDiscontinuous),
107  nTotalRoots(src.nTotalRoots),
108  nRootsPerDiscontinuity(src.nRootsPerDiscontinuity)
109 {}
110 
112 {}
113 
116 {
117  nDiscontinuous = rhs.nDiscontinuous;
118  nTotalRoots = rhs.nTotalRoots;
119  nRootsPerDiscontinuity = rhs.nRootsPerDiscontinuity;
120 
121  return *this;
122 }
123 
126 {
127  nDiscontinuous += rhs.nDiscontinuous;
128  nTotalRoots += rhs.nTotalRoots;
129  nRootsPerDiscontinuity.insert(nRootsPerDiscontinuity.end(),
130  rhs.nRootsPerDiscontinuity.begin(),
131  rhs.nRootsPerDiscontinuity.end());
132 
133  return *this;
134 }
135 
137  mpStack(NULL),
138  mContext(Body),
141 {}
142 
144  mpStack(&stack),
145  mContext(Body),
146  mVariableLevel(C_INVALID_INDEX),
147  mBodyLevel(C_INVALID_INDEX)
148 {}
149 
151  mpStack(src.mpStack),
152  mContext(src.mContext),
153  mVariableLevel(src.mVariableLevel),
154  mBodyLevel(src.mBodyLevel)
155 {}
156 
158 {}
159 
161 {
162  mpStack->push_back(stackElement);
163  mBodyLevel++;
164 }
165 
167 {
168  mpStack->pop_back();
169  mBodyLevel--;
170 }
171 
173 {
174  return mpStack->size();
175 }
176 
178 CMath::CAllocationStack::operator [](const size_t & index) const
179 {
180  size_t Level = C_INVALID_INDEX;
181 
182  switch (mContext)
183  {
184  case Variable:
185  Level = mVariableLevel;
186  break;
187 
188  case Body:
189  Level = mBodyLevel;
190 
191  break;
192  }
193 
194  assert(Level < mpStack->size());
195  assert(index < mpStack->at(Level).size());
196 
197  return mpStack->at(Level)[index];
198 }
199 
200 std::ostream & operator << (std::ostream & os, const CMath::CAllocationStack::CAllocation & s)
201 {
202  os << "Discontinuities: " << s.nDiscontinuous;
203  return os;
204 }
205 
const CEvaluationNode * operator[](const size_t &index) const
Definition: CMathEnum.cpp:59
std::vector< StackElement > Buffer
Definition: CMathEnum.h:229
std::vector< StackElement > Buffer
Definition: CMathEnum.h:294
std::vector< CAllocation > StackElement
Definition: CMathEnum.h:293
CAllocation & operator+=(const CAllocation &rhs)
Definition: CMathEnum.cpp:125
#define C_INVALID_INDEX
Definition: copasi.h:222
const CAllocation & operator[](const size_t &index) const
Definition: CMathEnum.cpp:178
std::vector< size_t > nRootsPerDiscontinuity
Definition: CMathEnum.h:290
std::vector< const CEvaluationNode * > StackElement
Definition: CMathEnum.h:228
std::ostream & operator<<(std::ostream &os, const CMath::CVariableStack &s)
Definition: CMathEnum.cpp:81
CAllocation & operator=(const CAllocation &rhs)
Definition: CMathEnum.cpp:115
void push(const StackElement &stackElement)
Definition: CMathEnum.cpp:42
size_t size() const
Definition: CMathEnum.cpp:54
void push(const StackElement &stackElement)
Definition: CMathEnum.cpp:160
size_t size() const
Definition: CMathEnum.cpp:172