COPASI API  4.16.103
Public Member Functions | Private Attributes | Friends | List of all members
CStepMatrixColumn Class Reference

#include <CStepMatrixColumn.h>

Collaboration diagram for CStepMatrixColumn:
Collaboration graph
[legend]

Public Member Functions

void convert (const CZeroSet::CIndex &bit)
 
 CStepMatrixColumn (const size_t &size=0)
 
 CStepMatrixColumn (const CZeroSet &set, CStepMatrixColumn const *pPositive, CStepMatrixColumn const *pNegative)
 
void getAllUnsetBitIndexes (CVector< size_t > &indexes) const
 
const C_INT64getMultiplier () const
 
std::vector< C_INT64 > & getReaction ()
 
const CZeroSetgetZeroSet () const
 
void push_front (const C_INT64 &value)
 
void setIterator (CStepMatrixColumn **it)
 
void truncate ()
 
void unsetBit (const CZeroSet::CIndex &index)
 
 ~CStepMatrixColumn ()
 

Private Attributes

CStepMatrixColumn ** mIterator
 
std::vector< C_INT64mReaction
 
CZeroSet mZeroSet
 

Friends

std::ostream & operator<< (std::ostream &, const CStepMatrixColumn &)
 

Detailed Description

Definition at line 26 of file CStepMatrixColumn.h.

Constructor & Destructor Documentation

CStepMatrixColumn::CStepMatrixColumn ( const size_t &  size = 0)

Definition at line 28 of file CStepMatrixColumn.cpp.

28  :
29  mZeroSet(size),
30  mReaction(),
31  mIterator(NULL)
32 {}
std::vector< C_INT64 > mReaction
CStepMatrixColumn ** mIterator
CStepMatrixColumn::CStepMatrixColumn ( const CZeroSet set,
CStepMatrixColumn const *  pPositive,
CStepMatrixColumn const *  pNegative 
)

Definition at line 34 of file CStepMatrixColumn.cpp.

References abs64, C_INT64, CBitPatternTreeMethod::GCD(), getMultiplier(), and mReaction.

36  :
37  mZeroSet(set),
38  mReaction(),
39  mIterator(NULL)
40 {
41  C_INT64 PosMult = -pNegative->getMultiplier();
42  C_INT64 NegMult = pPositive->getMultiplier();
43 
44  C_INT64 GCD1 = abs64(PosMult);
45  C_INT64 GCD2 = abs64(NegMult);
46 
47  // Divide PosMult and NegMult by GCD(PosMult, NegMult);
48  CBitPatternTreeMethod::GCD(GCD1, GCD2);
49 
50  if (GCD1 != 1)
51  {
52  PosMult /= GCD1;
53  NegMult /= GCD1;
54  }
55 
56  // -1 is used to identify the start of the GCD search.
57  GCD1 = -1;
58 
59  mReaction.resize(pPositive->mReaction.size());
60  std::vector< C_INT64 >::iterator it = mReaction.begin();
61  std::vector< C_INT64 >::iterator end = mReaction.end();
62 
63  std::vector< C_INT64 >::const_iterator itPos = pPositive->mReaction.begin();
64  std::vector< C_INT64 >::const_iterator itNeg = pNegative->mReaction.begin();
65 
66  for (; it != end; ++it, ++itPos, ++itNeg)
67  {
68  // TODO We need to check that we do not have numerical overflow
69  *it = PosMult * *itPos + NegMult * *itNeg;
70 
71  if (*it == 0 || GCD1 == 1)
72  {
73  continue;
74  }
75 
76  if (GCD1 == -1)
77  {
78  GCD1 = abs64(*it);
79  continue;
80  }
81 
82  GCD2 = abs64(*it);
83 
84  CBitPatternTreeMethod::GCD(GCD1, GCD2);
85  }
86 
87  if (GCD1 > 1)
88  {
89  for (it = mReaction.begin(); it != end; ++it)
90  {
91  *it /= GCD1;
92  }
93  }
94 }
static void GCD(C_INT64 &m, C_INT64 &n)
std::vector< C_INT64 > mReaction
#define C_INT64
Definition: copasi.h:88
#define abs64
Definition: copasi.h:94
CStepMatrixColumn ** mIterator
CStepMatrixColumn::~CStepMatrixColumn ( )

Definition at line 96 of file CStepMatrixColumn.cpp.

References mIterator.

97 {
98  assert(*mIterator = this);
99 
100  *mIterator = NULL;
101 }
CStepMatrixColumn ** mIterator

Member Function Documentation

void CStepMatrixColumn::convert ( const CZeroSet::CIndex bit)
void CStepMatrixColumn::getAllUnsetBitIndexes ( CVector< size_t > &  indexes) const

Definition at line 113 of file CStepMatrixColumn.cpp.

References CVectorCore< CType >::array(), CZeroSet::getNumberOfBits(), CZeroSet::isSet(), mReaction, mZeroSet, and CVector< CType >::resize().

Referenced by CStepMatrix::getAllUnsetBitIndexes().

114 {
115  size_t Size = mZeroSet.getNumberOfBits();
116  indexes.resize(Size);
117  size_t * pIndex = indexes.array();
118 
119  CZeroSet::CIndex Index;
120  size_t i = 0;
121  size_t imax = Size - mReaction.size();
122 
123  for (; i < imax; ++i, ++Index)
124  {
125  if (!mZeroSet.isSet(Index))
126  {
127  *pIndex = i;
128  pIndex++;
129  }
130  }
131 
132  for (i = mReaction.size(); i > 0;)
133  {
134  --i;
135 
136  if (mReaction[i] != 0)
137  {
138  *pIndex = (mReaction.size() - i - 1) + imax;
139  pIndex++;
140  }
141  }
142 
143  Size = pIndex - indexes.array();
144  indexes.resize(Size, true);
145 
146  //DebugFile << *this << std::endl;
147  //DebugFile << "@CSMC: " << indexes << std::endl;
148 }
size_t getNumberOfBits() const
Definition: CZeroSet.h:95
std::vector< C_INT64 > mReaction
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
bool isSet(const CIndex &index) const
Definition: CZeroSet.h:80
CType * array()
Definition: CVector.h:139
const C_INT64& CStepMatrixColumn::getMultiplier ( ) const
inline

Definition at line 50 of file CStepMatrixColumn.h.

References mReaction.

Referenced by CStepMatrixColumn().

51  {
52  return mReaction.back();
53  }
std::vector< C_INT64 > mReaction
std::vector< C_INT64 > & CStepMatrixColumn::getReaction ( )

Definition at line 108 of file CStepMatrixColumn.cpp.

References mReaction.

109 {
110  return mReaction;
111 }
std::vector< C_INT64 > mReaction
const CZeroSet & CStepMatrixColumn::getZeroSet ( ) const
void CStepMatrixColumn::push_front ( const C_INT64 value)

Definition at line 150 of file CStepMatrixColumn.cpp.

References mReaction.

Referenced by CBitPatternMethod::buildFluxModeMatrix(), CStepMatrix::CStepMatrix(), and CBitPatternMethod::initialize().

151 {
152  mReaction.insert(mReaction.begin(), value);
153 }
std::vector< C_INT64 > mReaction
void CStepMatrixColumn::setIterator ( CStepMatrixColumn **  it)
inline

Definition at line 63 of file CStepMatrixColumn.h.

References mIterator.

Referenced by CStepMatrix::add().

64  {
65  mIterator = it;
66  }
CStepMatrixColumn ** mIterator
void CStepMatrixColumn::truncate ( )

Definition at line 155 of file CStepMatrixColumn.cpp.

References mReaction.

156 {
157  mReaction.pop_back();
158 }
std::vector< C_INT64 > mReaction
void CStepMatrixColumn::unsetBit ( const CZeroSet::CIndex index)
inline

Definition at line 45 of file CStepMatrixColumn.h.

References mZeroSet, and CZeroSet::unsetBit().

46  {
47  mZeroSet.unsetBit(index);
48  }
void unsetBit(const CIndex &index)
Definition: CZeroSet.h:74

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const CStepMatrixColumn  
)
friend

Definition at line 160 of file CStepMatrixColumn.cpp.

161 {
162  os << ' ';
163 
164  size_t Size = c.mZeroSet.getNumberOfBits();
165  CZeroSet::CIndex Index;
166  size_t i = 0;
167  size_t imax = Size - c.mReaction.size();
168 
169  for (; i < imax; ++i, ++Index)
170  {
171  if (c.mZeroSet.isSet(Index))
172  {
173  os << "*\t";
174  }
175  else
176  {
177  os << ".\t";
178  }
179  }
180 
181  for (i = c.mReaction.size(); i > 0;)
182  {
183  --i;
184 
185  os << c.mReaction[i] << "\t";;
186  }
187 
188  return os;
189 }
size_t getNumberOfBits() const
Definition: CZeroSet.h:95
std::vector< C_INT64 > mReaction
bool isSet(const CIndex &index) const
Definition: CZeroSet.h:80

Member Data Documentation

CStepMatrixColumn** CStepMatrixColumn::mIterator
private

Definition at line 74 of file CStepMatrixColumn.h.

Referenced by setIterator(), and ~CStepMatrixColumn().

std::vector< C_INT64 > CStepMatrixColumn::mReaction
private
CZeroSet CStepMatrixColumn::mZeroSet
private

Definition at line 70 of file CStepMatrixColumn.h.

Referenced by getAllUnsetBitIndexes(), getZeroSet(), operator<<(), and unsetBit().


The documentation for this class was generated from the following files: