COPASI API  4.16.103
CZeroSet.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/elementaryFluxModes/CZeroSet.cpp,v $
3 // $Revision: 1.8 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:27:36 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 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 #include "copasi.h"
20 
21 #include "CZeroSet.h"
22 #include "CStepMatrixColumn.h"
23 
24 CZeroSet::CIndex::CIndex(const size_t & index):
25  mIndex(index / (CHAR_BIT * sizeof(size_t))),
26  mBit(1 << (index % (CHAR_BIT * sizeof(size_t)))),
27  mNotBit(C_INVALID_INDEX - mBit)
28 {}
29 
31  mIndex(src.mIndex),
32  mBit(src.mBit),
33  mNotBit(src.mNotBit)
34 {}
35 
37 {}
38 
40 {
41  mBit <<= 1;
42  mNotBit = C_INVALID_INDEX - mBit;
43 
44  if (mBit == 0)
45  {
46  mIndex++;
47  mBit = 1;
48  mNotBit = C_INVALID_INDEX;
49  }
50 
51  return *this;
52 }
53 
55 {
56  mIndex = rhs.mIndex;
57  mBit = rhs.mBit;
58  mNotBit = rhs.mNotBit;
59 
60  return *this;
61 }
62 
64 {
65  mIndex = index / (CHAR_BIT * sizeof(size_t));
66  mBit = ((size_t) 1) << (index % (CHAR_BIT * sizeof(size_t)));
67  mNotBit = C_INVALID_INDEX - mBit;
68 
69  return *this;
70 }
71 
73 {
74  if (mIndex == rhs.mIndex)
75  return mBit < rhs.mBit;
76 
77  return mIndex < rhs.mIndex;
78 }
79 
80 CZeroSet::CZeroSet(const size_t & size):
81  mBitSet(size / (CHAR_BIT * sizeof(size_t)) + 1),
82  mIgnoredBits(mBitSet.size() * CHAR_BIT * sizeof(size_t) - size),
83  mNumberSetBits(size)
84 {
86 }
87 
89  mBitSet(src.mBitSet),
90  mIgnoredBits(src.mIgnoredBits),
91  mNumberSetBits(src.mNumberSetBits)
92 {}
93 
95 {}
96 
97 bool CZeroSet::isExtremeRay(const std::vector< CStepMatrixColumn * > & columns) const
98 {
99  std::vector< CStepMatrixColumn * >::const_iterator it = columns.begin();
100  std::vector< CStepMatrixColumn * >::const_iterator end = columns.end();
101 
102  for (; it != end; ++it)
103  {
104  if (*it != NULL &&
105  (*it)->getZeroSet() >= *this)
106  {
107  return false;
108  }
109  }
110 
111  return true;
112 }
113 
114 std::ostream & operator << (std::ostream & os, const CZeroSet & set)
115 {
116  const size_t * pIt = set.mBitSet.array();
117  const size_t * pEnd = pIt + set.mBitSet.size();
118 
119  size_t CurrentBit = 0;
120  size_t LastBit = set.mBitSet.size() * CHAR_BIT * sizeof(size_t) - set.mIgnoredBits;
121 
122  os << ' ';
123 
124  for (; pIt != pEnd; ++pIt)
125  {
126  for (size_t i = 0;
127  i < CHAR_BIT * sizeof(size_t) && CurrentBit < LastBit;
128  ++i, ++CurrentBit)
129  {
130  if ((*pIt >> i) & 1)
131  {
132  os << 1;
133  }
134  else
135  {
136  os << 0;
137  }
138  }
139 
140  os << ' ';
141  }
142 
143  os << " " << set.mNumberSetBits << std::endl;
144 
145  return os;
146 }
size_t mIndex
Definition: CZeroSet.h:55
CZeroSet(const size_t &index=0)
Definition: CZeroSet.cpp:80
CIndex & operator=(const CIndex &rhs)
Definition: CZeroSet.cpp:54
~CZeroSet()
Definition: CZeroSet.cpp:94
bool operator<(const CIndex &rhs) const
Definition: CZeroSet.cpp:72
CIndex(const size_t &index=0)
Definition: CZeroSet.cpp:24
std::ostream & operator<<(std::ostream &os, const CZeroSet &set)
Definition: CZeroSet.cpp:114
#define C_INVALID_INDEX
Definition: copasi.h:222
size_t mIgnoredBits
Definition: CZeroSet.h:174
size_t mNotBit
Definition: CZeroSet.h:57
CIndex & operator++()
Definition: CZeroSet.cpp:39
size_t mNumberSetBits
Definition: CZeroSet.h:176
size_t size() const
Definition: CVector.h:100
bool isExtremeRay(const std::vector< CStepMatrixColumn * > &columns) const
Definition: CZeroSet.cpp:97
CType * array()
Definition: CVector.h:139
CVector< size_t > mBitSet
Definition: CZeroSet.h:172