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

#include <CFluxScore.h>

Collaboration diagram for CFluxScore:
Collaboration graph
[legend]

Public Member Functions

 CFluxScore ()
 
 CFluxScore (const std::vector< C_FLOAT64 > &fluxModes)
 
bool operator< (const CFluxScore &rhs) const
 
 ~CFluxScore ()
 

Private Attributes

CVector< unsigned char > mScore
 

Friends

std::ostream & operator<< (std::ostream &os, const CFluxScore &A)
 

Detailed Description

CFluxScore class. Used to compare flux modes

Created for Copasi by Stefan Hoops 2002-05-08 (C) Stefan Hoops 2002

Definition at line 28 of file CFluxScore.h.

Constructor & Destructor Documentation

CFluxScore::CFluxScore ( )

Default constructor

CFluxScore class. Used to compare flux modes

Created for COPASI by Stefan Hoops 2002-05-08 (C) Stefan Hoops 2002

Definition at line 36 of file CFluxScore.cpp.

References CONSTRUCTOR_TRACE.

#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CFluxScore::CFluxScore ( const std::vector< C_FLOAT64 > &  fluxModes)

Specific constructor

Parameters
const vector < C_FLOAT64 > &fluxModes

Definition at line 38 of file CFluxScore.cpp.

References CVectorCore< CType >::array(), CONSTRUCTOR_TRACE, mScore, and CVector< CType >::resize().

39 {
41  unsigned char Remainder = fluxMode.size() % (CHAR_BIT * sizeof(unsigned char));
42  size_t imax = fluxMode.size() / (CHAR_BIT * sizeof(unsigned char));
43  unsigned char k, kmax = CHAR_BIT * sizeof(unsigned char);
44 
45  // Size the scoring vector.
46  // Note we have to allocate an extra int if Remainder != 0
47  mScore.resize(imax + (Remainder ? 1 : 0));
48 
49  std::vector < C_FLOAT64 >::const_iterator itMode = fluxMode.begin();
50  unsigned char * pScore = mScore.array();
51  unsigned char * pScoreEnd = pScore + imax;
52 
53  // Set the bits to 1 if the corresponding fluxMode coefficient is non zero.
54  for (; pScore != pScoreEnd; ++pScore)
55  {
56  *pScore = 0;
57 
58  for (k = kmax; k > 0; ++itMode)
59  {
60  k--;
61 
62  if (*itMode != 0)
63  (*pScore) |= (0x01 << k);
64  }
65  }
66 
67  // Do the same for the remaining fluxMode coefficients.
68  if (Remainder)
69  {
70  k = kmax;
71  kmax -= Remainder;
72 
73  *pScore = 0;
74 
75  for (; k > kmax; ++itMode)
76  {
77  k--;
78 
79  if (*itMode != 0)
80  (*pScore) |= (0x01 << k);
81  }
82  }
83 }
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
CVector< unsigned char > mScore
Definition: CFluxScore.h:36
CType * array()
Definition: CVector.h:139
#define CONSTRUCTOR_TRACE
Definition: copasi.h:202
CFluxScore::~CFluxScore ( )

Destructor();

Definition at line 85 of file CFluxScore.cpp.

References DESTRUCTOR_TRACE.

#define DESTRUCTOR_TRACE
Definition: copasi.h:206

Member Function Documentation

bool CFluxScore::operator< ( const CFluxScore rhs) const

Comparison operator deciding whether lhs has a smaller flux score than rhs

Parameters
const CFluxScore &lhs
const CFluxScore &rhs
Returns
"bool"

Definition at line 87 of file CFluxScore.cpp.

References CVectorCore< CType >::array(), mScore, and CVectorCore< CType >::size().

88 {
89  const unsigned char * pScoreLhs = mScore.array();
90  const unsigned char * pScoreRhs = rhs.mScore.array();
91  const unsigned char * pScoreEnd = pScoreLhs + mScore.size();
92 
93  for (; pScoreLhs != pScoreEnd; ++pScoreLhs, ++pScoreRhs)
94  if (*pScoreLhs != (*pScoreLhs & *pScoreRhs))
95  return false;
96 
97  return true;
98 }
CVector< unsigned char > mScore
Definition: CFluxScore.h:36
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const CFluxScore A 
)
friend

Definition at line 100 of file CFluxScore.cpp.

101 {
102  const unsigned char * pScore = A.mScore.array();
103  const unsigned char * pScoreEnd = pScore + A.mScore.size();
104  unsigned char k, kmax = CHAR_BIT * sizeof(unsigned char);
105 
106  for (k = kmax; pScore != pScoreEnd; ++pScore)
107  {
108  k = kmax;
109 
110  while (k > 0)
111  {
112  k--;
113  os << ((*pScore & (0x01 << k)) >> k);
114  }
115  }
116 
117  os << std::endl;
118 
119  return os;
120 }
CVector< unsigned char > mScore
Definition: CFluxScore.h:36
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139

Member Data Documentation

CVector< unsigned char > CFluxScore::mScore
private

The score of a flux mode

Definition at line 36 of file CFluxScore.h.

Referenced by CFluxScore(), operator<(), and operator<<().


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