COPASI API  4.16.103
CTableauLine.cpp
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/elementaryFluxModes/CTableauLine.cpp,v $
3  $Revision: 1.18 $
4  $Name: $
5  $Author: ssahle $
6  $Date: 2012/04/22 14:51:18 $
7  End CVS Header */
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 /**
24  * CTableauLine class.
25  * This store one row of the Tableau Matrix
26  *
27  * Created for COPASI by Stefan Hoops 2002-05-08
28  * (C) Stefan Hoops 2002
29  */
30 
31 #include <iostream>
32 #include <cmath>
33 
34 #include "copasi.h"
35 #include "CTableauLine.h"
36 
38 
39 CTableauLine::CTableauLine(const std::vector <C_FLOAT64> & reaction,
40  bool reversible,
41  const size_t & reactionCounter,
42  const size_t & reactionNumber)
43 {
45  mReaction = reaction;
46  mReversible = reversible;
47 
48  mFluxMode.resize(reactionNumber, 0);
49  mFluxMode[reactionCounter] = 1;
50 
52 }
53 
55  const CTableauLine & src1,
56  C_FLOAT64 m2,
57  const CTableauLine & src2)
58 {
60 
61  // We need to remove common factors in m1 and m2
62  reduce(m1, m2);
63 
64  mReversible = (src1.mReversible && src2.mReversible);
65 
66  mReaction.resize(src1.mReaction.size());
67  mFluxMode.resize(src1.mFluxMode.size());
68 
69  std::vector< C_FLOAT64 >::const_iterator it1 = src1.mReaction.begin();
70  std::vector< C_FLOAT64 >::const_iterator it2 = src2.mReaction.begin();
71  std::vector< C_FLOAT64 >::iterator it = mReaction.begin();
72  std::vector< C_FLOAT64 >::iterator end = mReaction.end();
73 
74  for (; it != end; ++it, ++it1, ++it2)
75  *it = m1 * *it1 + m2 * *it2;
76 
77  it1 = src1.mFluxMode.begin();
78  it2 = src2.mFluxMode.begin();
79  it = mFluxMode.begin();
80  end = mFluxMode.end();
81 
82  for (; it != end; ++it, ++it1, ++it2)
83  *it = m1 * *it1 + m2 * *it2;
84 
86 }
88 
90 {
91  return *mpFluxScore;
92 }
93 
94 const C_FLOAT64 & CTableauLine::getMultiplier(const size_t & index) const
95 {return mReaction[mReaction.size() - index - 1];}
96 
97 const std::vector < C_FLOAT64 > & CTableauLine::getFluxMode() const
98 {
99  return mFluxMode;
100 }
101 
103 {
104  return mReversible;
105 }
106 
107 /*
108 void CTableauLine::truncate()
109 {
110  mReaction.pop_back();
111 }
112  */
113 std::ostream & operator << (std::ostream & os, const CTableauLine & l)
114 {
115  size_t i, imax = l.mReaction.size();
116  size_t j, jmax = l.mFluxMode.size();
117 
118  if (l.isReversible())
119  os << "reversible: ";
120  else
121  os << "irreversible:";
122 
123  for (i = 0; i < imax; i++)
124  os << " " << l.mReaction[i];
125 
126  os << "\t";
127 
128  for (j = 0; j < jmax; j++)
129  os << " " << l.mFluxMode[j];
130 
131  os << std::endl;
132 
133  return os;
134 }
135 
136 // static
138 {
139  if (floor(r1) != r1 || floor(r2) != r2)
140  return;
141 
142  C_INT32 GCD1 = (C_INT32) fabs(r1);
143  C_INT32 GCD2 = (C_INT32) fabs(r2);
144 
145  while (GCD1 != GCD2)
146  {
147  if (GCD1 > GCD2)
148  {
149  GCD1 %= GCD2;
150 
151  if (GCD1 == 0)
152  {
153  GCD1 = GCD2;
154  }
155  }
156  else
157  {
158  GCD2 %= GCD1;
159 
160  if (GCD2 == 0)
161  {
162  GCD2 = GCD1;
163  }
164  }
165  }
166 
167  r1 /= (C_FLOAT64) GCD1;
168  r2 /= (C_FLOAT64) GCD2;
169 }
#define pdelete(p)
Definition: copasi.h:215
std::ostream & operator<<(std::ostream &os, const CTableauLine &l)
const CFluxScore & getScore() const
bool mReversible
Definition: CTableauLine.h:51
const std::vector< C_FLOAT64 > & getFluxMode() const
#define C_INT32
Definition: copasi.h:90
std::vector< C_FLOAT64 > mReaction
Definition: CTableauLine.h:46
static void reduce(C_FLOAT64 &r1, C_FLOAT64 &r2)
#define DESTRUCTOR_TRACE
Definition: copasi.h:206
bool isReversible() const
const C_FLOAT64 & getMultiplier(const size_t &index) const
#define C_FLOAT64
Definition: copasi.h:92
CFluxScore * mpFluxScore
Definition: CTableauLine.h:61
std::vector< C_FLOAT64 > mFluxMode
Definition: CTableauLine.h:56
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202