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

#include <CState.h>

Public Member Functions

C_FLOAT64beginDependent ()
 
const C_FLOAT64beginDependent () const
 
C_FLOAT64beginFixed ()
 
const C_FLOAT64beginFixed () const
 
C_FLOAT64beginIndependent ()
 
const C_FLOAT64beginIndependent () const
 
 CState ()
 
 CState (const CState &src)
 
C_FLOAT64endDependent ()
 
const C_FLOAT64endDependent () const
 
C_FLOAT64endFixed ()
 
const C_FLOAT64endFixed () const
 
C_FLOAT64endIndependent ()
 
const C_FLOAT64endIndependent () const
 
size_t getNumDependent () const
 
size_t getNumFixed () const
 
size_t getNumIndependent () const
 
size_t getNumVariable () const
 
const C_FLOAT64getTime () const
 
bool isValid () const
 
CStateoperator= (const CState &rhs)
 
void setTime (const C_FLOAT64 &time)
 
 ~CState ()
 

Protected Member Functions

C_FLOAT64resize (const size_t &size)
 
void updateIterator (const size_t &numIndependent, const size_t &numDependent, const size_t &numFixed)
 

Private Attributes

C_FLOAT64mpBeginDependent
 
C_FLOAT64mpBeginFixed
 
C_FLOAT64mpBeginIndependent
 
C_FLOAT64mpEnd
 
C_FLOAT64mpValues
 
size_t mSize
 
bool mUpdateDependentRequired
 

Friends

class CStateTemplate
 
std::ostream & operator<< (std::ostream &os, const CState &s)
 

Detailed Description

Definition at line 305 of file CState.h.

Constructor & Destructor Documentation

CState::CState ( )

Constructor

Definition at line 279 of file CState.cpp.

279  :
280  mpValues(NULL),
281  mSize(0),
282  mpBeginIndependent(NULL),
283  mpBeginDependent(NULL),
284  mpBeginFixed(NULL),
285  mpEnd(NULL),
287 {}
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
bool mUpdateDependentRequired
Definition: CState.h:500
size_t mSize
Definition: CState.h:475
C_FLOAT64 * mpValues
Definition: CState.h:470
CState::CState ( const CState src)

Copy constructor

Parameters
constCState & src

Definition at line 289 of file CState.cpp.

References C_FLOAT64, mpValues, and mSize.

289  :
290  mpValues(new C_FLOAT64[src.mSize]),
291  mSize(src.mSize),
295  mpEnd(mpValues + (src.mpEnd - src.mpValues)),
297 {
298  memcpy(mpValues, src.mpValues, sizeof(C_FLOAT64) * mSize);
299 }
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
bool mUpdateDependentRequired
Definition: CState.h:500
size_t mSize
Definition: CState.h:475
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpValues
Definition: CState.h:470
CState::~CState ( )

Destructor

Definition at line 301 of file CState.cpp.

References mpValues, and pdeletev.

301 {pdeletev(mpValues);}
#define pdeletev(p)
Definition: copasi.h:216
C_FLOAT64 * mpValues
Definition: CState.h:470

Member Function Documentation

C_FLOAT64 * CState::beginDependent ( )

Retrieve the array of pointers of values of all dependent entities, which are only dependent species for a reduced model.

Returns
C_FLOAT64 * dependentValues

Definition at line 330 of file CState.cpp.

References mpBeginDependent.

Referenced by CHybridMethodODE45::outputState(), and CModel::updateSimulatedValues().

330 {return mpBeginDependent;}
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
const C_FLOAT64 * CState::beginDependent ( ) const

Retrieve the array of pointers of values of all dependent entities, which are only dependent species for a reduced model.

Returns
const C_FLOAT64 * dependentValues

Definition at line 337 of file CState.cpp.

References mpBeginDependent.

337 {return mpBeginDependent;}
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
C_FLOAT64 * CState::beginFixed ( )

Retrieve the array of pointers of values of all fixed entities.

Returns
C_FLOAT64 * fixedValues

Definition at line 332 of file CState.cpp.

References mpBeginFixed.

Referenced by CHybridMethodODE45::outputState(), and CLsodaMethod::stateChanged().

332 {return mpBeginFixed;}
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
const C_FLOAT64 * CState::beginFixed ( ) const

Retrieve the array of pointers of values of all fixed entities.

Returns
const C_FLOAT64 * fixedValues

Definition at line 339 of file CState.cpp.

References mpBeginFixed.

339 {return mpBeginFixed;}
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * CState::beginIndependent ( )
const C_FLOAT64 * CState::beginIndependent ( ) const

Retrieve the array of pointers of values of all independent entities.

Returns
const C_FLOAT64 * independentValues

Definition at line 335 of file CState.cpp.

References mpBeginIndependent.

335 {return mpBeginIndependent;}
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * CState::endDependent ( )

Retrieve pointer just beyond the values of all dependent entities.

Returns
C_FLOAT64 * endDependentValues

Definition at line 331 of file CState.cpp.

References mpBeginFixed.

Referenced by CSteadyStateMethod::allPositive(), and CHybridMethodODE45::outputState().

331 {return mpBeginFixed;}
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
const C_FLOAT64 * CState::endDependent ( ) const

Retrieve pointer just beyond the values of all dependent entities.

Returns
const C_FLOAT64 * endDependentValues

Definition at line 338 of file CState.cpp.

References mpBeginFixed.

338 {return mpBeginFixed;}
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * CState::endFixed ( )

Retrieve pointer just beyond the values of all fixed entities.

Returns
C_FLOAT64 * endFixedValues

Definition at line 333 of file CState.cpp.

References mpEnd.

Referenced by CHybridMethodODE45::outputState(), and CLsodaMethod::stateChanged().

333 {return mpEnd;}
C_FLOAT64 * mpEnd
Definition: CState.h:495
const C_FLOAT64 * CState::endFixed ( ) const

Retrieve pointer just beyond the values of all fixed entities.

Returns
const C_FLOAT64 * endFixedValues

Definition at line 340 of file CState.cpp.

References mpEnd.

340 {return mpEnd;}
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * CState::endIndependent ( )

Retrieve pointer just beyond the values of all independent entities.

Returns
C_FLOAT64 * endIndependentValues

Definition at line 329 of file CState.cpp.

References mpBeginDependent.

Referenced by CNewtonMethod::containsNaN(), CHybridMethodODE45::outputState(), and CCrossSectionTask::relativeDifferenceOfStates().

329 {return mpBeginDependent;}
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
const C_FLOAT64 * CState::endIndependent ( ) const

Retrieve pointer just beyond the values of all independent entities.

Returns
const C_FLOAT64 * endIndependentValues

Definition at line 336 of file CState.cpp.

References mpBeginDependent.

336 {return mpBeginDependent;}
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
size_t CState::getNumDependent ( ) const

Retrieve the number of dependent entities.

Returns
size_t numDependent

Definition at line 344 of file CState.cpp.

References mpBeginDependent, and mpBeginFixed.

Referenced by CSteadyStateTask::initialize(), CHybridMethodODE45::outputState(), and resize().

345 {return mpBeginFixed - mpBeginDependent;}
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
size_t CState::getNumFixed ( ) const

Retrieve the number of fixed entities.

Returns
size_t numFixed

Definition at line 348 of file CState.cpp.

References mpBeginFixed, and mpEnd.

Referenced by resize().

349 {return mpEnd - mpBeginFixed;}
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
size_t CState::getNumIndependent ( ) const
size_t CState::getNumVariable ( ) const

Retrieve the number of variable entities, i.e., the sum of independent and dependent variables.

Returns
size_t numVariable

Definition at line 346 of file CState.cpp.

References mpBeginFixed, and mpBeginIndependent.

C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
const C_FLOAT64 & CState::getTime ( ) const
bool CState::isValid ( ) const

Check whether the current state is valid (contains no NaN)

Returns
bool isValid

Definition at line 351 of file CState.cpp.

References C_FLOAT64, mpBeginDependent, and mpBeginIndependent.

Referenced by CSteadyStateTask::process(), and CLsodaMethod::step().

352 {
353  const C_FLOAT64 * pIt = mpBeginIndependent;
354  const C_FLOAT64 * pEnd = mpBeginDependent;
355 
356  for (; pIt != pEnd; ++pIt)
357  {
358  if (isnan(*pIt))
359  return false;
360  }
361 
362  return true;
363 }
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
#define C_FLOAT64
Definition: copasi.h:92
CState & CState::operator= ( const CState rhs)

Assignment operator

Parameters
constCState & rhs
Returns
CState & lhs

Definition at line 303 of file CState.cpp.

References C_FLOAT64, mpBeginDependent, mpBeginFixed, mpBeginIndependent, mpEnd, mpValues, mSize, mUpdateDependentRequired, and pdeletev.

304 {
305  if (this != &rhs)
306  {
307  if (mSize != rhs.mSize)
308  {
310  mpValues = new C_FLOAT64[rhs.mSize];
311  mSize = rhs.mSize;
312  }
313 
314  memcpy(mpValues, rhs.mpValues, sizeof(C_FLOAT64) * mSize);
317  mpBeginFixed = mpValues + (rhs.mpBeginFixed - rhs.mpValues);
318  mpEnd = mpValues + (rhs.mpEnd - rhs.mpValues);
320  }
321 
322  return *this;
323 }
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
#define pdeletev(p)
Definition: copasi.h:216
bool mUpdateDependentRequired
Definition: CState.h:500
size_t mSize
Definition: CState.h:475
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpValues
Definition: CState.h:470
C_FLOAT64 * CState::resize ( const size_t &  size)
protected

Definition at line 365 of file CState.cpp.

References C_FLOAT64, getNumDependent(), getNumFixed(), getNumIndependent(), min, mpValues, mSize, pdeletev, and updateIterator().

Referenced by CStateTemplate::resize().

366 {
367  if (mSize != size)
368  {
369  C_FLOAT64 * pTmp = mpValues;
370 
371  if (size > 0)
372  {
373  mpValues = new C_FLOAT64[size];
374  memcpy(mpValues, pTmp, sizeof(C_FLOAT64) * std::min(mSize, size));
375  }
376  else
377  mpValues = NULL;
378 
379  pdeletev(pTmp);
380  mSize = size;
381  }
382 
384 
385  return mpValues;
386 }
#define pdeletev(p)
Definition: copasi.h:216
size_t getNumDependent() const
Definition: CState.cpp:344
size_t getNumFixed() const
Definition: CState.cpp:348
size_t getNumIndependent() const
Definition: CState.cpp:342
size_t mSize
Definition: CState.h:475
#define C_FLOAT64
Definition: copasi.h:92
void updateIterator(const size_t &numIndependent, const size_t &numDependent, const size_t &numFixed)
Definition: CState.cpp:388
C_FLOAT64 * mpValues
Definition: CState.h:470
#define min(a, b)
Definition: f2c.h:175
void CState::setTime ( const C_FLOAT64 time)
void CState::updateIterator ( const size_t &  numIndependent,
const size_t &  numDependent,
const size_t &  numFixed 
)
protected

Update the pointers to the different types of entities

Parameters
constsize_t & numIndependent
constsize_t & numDependent
constsize_t & numFixed

Definition at line 388 of file CState.cpp.

References mpBeginDependent, mpBeginFixed, mpBeginIndependent, mpEnd, and mpValues.

Referenced by CStateTemplate::reorder(), and resize().

391 {
392  mpBeginIndependent = mpValues + 1; // One for Time
393  mpBeginDependent = mpBeginIndependent + numIndependent;
394  mpBeginFixed = mpBeginDependent + numDependent;
395  mpEnd = mpBeginFixed + numFixed;
396 }
C_FLOAT64 * mpEnd
Definition: CState.h:495
C_FLOAT64 * mpBeginFixed
Definition: CState.h:490
C_FLOAT64 * mpBeginIndependent
Definition: CState.h:480
C_FLOAT64 * mpBeginDependent
Definition: CState.h:485
C_FLOAT64 * mpValues
Definition: CState.h:470

Friends And Related Function Documentation

friend class CStateTemplate
friend

Definition at line 453 of file CState.h.

std::ostream& operator<< ( std::ostream &  os,
const CState s 
)
friend

Definition at line 398 of file CState.cpp.

399 {
400  os << "(";
401 
402  const C_FLOAT64 * pValue = s.mpValues;
403 
404  for (; pValue != s.mpEnd; ++pValue)
405  {
406  os << "\t" << *pValue;
407  }
408 
409  os << "\t)";
410 
411  return os;
412 }
C_FLOAT64 * mpEnd
Definition: CState.h:495
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpValues
Definition: CState.h:470

Member Data Documentation

C_FLOAT64* CState::mpBeginDependent
private

Pointer to the beginning of values of dependent entities.

Definition at line 485 of file CState.h.

Referenced by beginDependent(), endIndependent(), getNumDependent(), getNumIndependent(), isValid(), operator=(), and updateIterator().

C_FLOAT64* CState::mpBeginFixed
private

Pointer to the beginning of values of fixed entities.

Definition at line 490 of file CState.h.

Referenced by beginFixed(), endDependent(), getNumDependent(), getNumFixed(), getNumVariable(), operator=(), and updateIterator().

C_FLOAT64* CState::mpBeginIndependent
private

Pointer to the beginning of values of independent entities.

Definition at line 480 of file CState.h.

Referenced by beginIndependent(), getNumIndependent(), getNumVariable(), isValid(), operator=(), and updateIterator().

C_FLOAT64* CState::mpEnd
private

Pointer just beyond the values of fixed entities.

Definition at line 495 of file CState.h.

Referenced by endFixed(), getNumFixed(), operator<<(), operator=(), and updateIterator().

C_FLOAT64* CState::mpValues
private

Array of entity values

Definition at line 470 of file CState.h.

Referenced by CState(), getTime(), operator<<(), operator=(), resize(), setTime(), updateIterator(), and ~CState().

size_t CState::mSize
private

Size of the state

Definition at line 475 of file CState.h.

Referenced by CState(), operator=(), and resize().

bool CState::mUpdateDependentRequired
private

Indicates whether the state is of a reduced or complete model

Definition at line 500 of file CState.h.

Referenced by operator=().


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