COPASI API  4.16.103
Public Member Functions | Protected Member Functions | List of all members
CVector< CType > Class Template Reference

#include <COptMethod.h>

Inheritance diagram for CVector< CType >:
Inheritance graph
[legend]
Collaboration diagram for CVector< CType >:
Collaboration graph
[legend]

Public Member Functions

 CVector (size_t size=0)
 
 CVector (const CVector< CType > &src)
 
CVector< CType > & operator= (const CVectorCore< CType > &rhs)
 
CVector< CType > & operator= (const CVector< CType > &rhs)
 
CVector< CType > & operator= (const CType &value)
 
void resize (size_t size, const bool &copy=false)
 
 ~CVector ()
 
- Public Member Functions inherited from CVectorCore< CType >
bool applyPivot (const CVectorCore< size_t > &pivot)
 
CType * array ()
 
const CType * array () const
 
 CVectorCore (const size_t &size=0, CType *vector=NULL)
 
 CVectorCore (const CVectorCore< CType > &src)
 
CType & operator() (const size_t &row)
 
const CType & operator() (const size_t &row) const
 
CVectorCore< CType > & operator= (const CType &value)
 
CType & operator[] (const size_t &row)
 
const CType & operator[] (const size_t &row) const
 
size_t size () const
 
 ~CVectorCore ()
 

Protected Member Functions

void copy (const CVectorCore< CType > &rhs)
 

Additional Inherited Members

- Public Types inherited from CVectorCore< CType >
typedef CType elementType
 
- Protected Attributes inherited from CVectorCore< CType >
size_t mSize
 
CType * mVector
 

Detailed Description

template<class CType>
class CVector< CType >

Template class CVector < class CType > This template class is a simple vector class allowing standard C-style and fortran style access to the elements. It also supplies an ostream operator.

Definition at line 41 of file COptMethod.h.

Constructor & Destructor Documentation

template<class CType>
CVector< CType >::CVector ( size_t  size = 0)
inline

Default constructor

Parameters
size_tsize (default = 0)

Definition at line 231 of file CVector.h.

231  :
232  CVectorCore< CType >(0, NULL)
233  {
234  resize(size);
235  }
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
size_t size() const
Definition: CVector.h:100
template<class CType>
CVector< CType >::CVector ( const CVector< CType > &  src)
inline

Copy constructor

Parameters
constCVector <CType> & src

Definition at line 241 of file CVector.h.

241  :
242  CVectorCore< CType >(0, NULL)
243  {
244  copy(src);
245  }
void copy(const CVectorCore< CType > &rhs)
Definition: CVector.h:360
template<class CType>
CVector< CType >::~CVector ( )
inline

Destructor.

Definition at line 250 of file CVector.h.

251  {
252  if (CVectorCore< CType >::mVector != NULL)
254  }

Member Function Documentation

template<class CType>
void CVector< CType >::copy ( const CVectorCore< CType > &  rhs)
inlineprotected

Definition at line 360 of file CVector.h.

Referenced by CVector< CProcessReportItem * >::CVector(), CVector< CProcessReportItem * >::operator=(), and CVector< CProcessReportItem * >::resize().

361  {
362  if (this != &rhs)
363  {
364  if (CVectorCore< CType >::mSize != rhs.size())
365  {
366  resize(rhs.size());
367  }
368 
370  {
371  memcpy((void *) CVectorCore< CType >::mVector,
372  (void *) rhs.array(),
373  CVectorCore< CType >::mSize * sizeof(CType));
374  }
375  }
376  }
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
size_t size() const
Definition: CVector.h:100
CType * array()
Definition: CVector.h:139
template<class CType>
CVector< CType >& CVector< CType >::operator= ( const CVectorCore< CType > &  rhs)
inline

Assignment operator

Parameters
constCVectorCore <CType> & rhs
Returns
CVector <CType> & lhs

Definition at line 261 of file CVector.h.

262  {
263  copy(rhs);
264 
265  return * this;
266  }
void copy(const CVectorCore< CType > &rhs)
Definition: CVector.h:360
template<class CType>
CVector< CType >& CVector< CType >::operator= ( const CVector< CType > &  rhs)
inline

Assignment operator

Parameters
constCVector <CType> & rhs
Returns
CVector <CType> & lhs

Definition at line 273 of file CVector.h.

274  {
275  copy(rhs);
276 
277  return * this;
278  }
void copy(const CVectorCore< CType > &rhs)
Definition: CVector.h:360
template<class CType>
CVector< CType>& CVector< CType >::operator= ( const CType &  value)
inline

Assignment operator

Parameters
constCType & value

Definition at line 284 of file CVector.h.

285  {
286  size_t i;
287  CType * tmp = CVectorCore< CType >::mVector;
288 
289  for (i = 0; i < CVectorCore< CType >::mSize; i++, tmp++)
290  {
291  *tmp = value;
292  }
293 
294  return *this;
295  }
template<class CType>
void CVector< CType >::resize ( size_t  size,
const bool &  copy = false 
)
inline

Resize the vector. The previous content is lost

Parameters
size_tsize

Definition at line 301 of file CVector.h.

Referenced by CProcessReport::addItem(), CMathContainer::allocate(), CHistoCurveData::boundingRect(), CLinkMatrix::build(), CSSAMethod::buildExtremeCurrents(), CModel::buildStoi(), CModel::buildUserOrder(), CEigen::calcEigenValues(), CLNAMethod::calculateCovarianceMatrixReduced(), CTSSAMethod::calculateDerivatives(), CTSSAMethod::calculateDerivativesX(), CBitPatternMethod::CalculateKernel(), CBitPatternTreeMethod::CalculateKernel(), CMathModel::calculateRootDerivatives(), CExperimentSet::calculateStatistics(), CFitProblem::calculateStatistics(), COptProblem::calculateStatistics(), CExperiment::calculateStatistics(), CMCAMethod::calculateUnscaledConcentrationCC(), CFluxScore::CFluxScore(), CMCAMethod::checkSummationTheorems(), CTimeSeries::clear(), COptMethodSS::combination(), CMathModel::compile(), CTimeSeries::compile(), CExperimentSet::compile(), CExperiment::compile(), CExperimentObjectMap::compile(), CLinkMatrix::completePivotInformation(), CMathReaction::copy(), CVector< CProcessReportItem * >::copy(), CLsodaMethod::createRootMask(), CCSPMethod::CSPImportanceIndex(), CCSPMethod::CSPParticipationIndex(), CCSPMethod::cspstep(), CVector< CProcessReportItem * >::CVector(), CLsodaMethod::destroyRootMask(), CMathModel::determineInitialRoots(), CILDMMethod::deuflhard(), CILDMModifiedMethod::deuflhard_metab(), CStepMatrixColumn::getAllUnsetBitIndexes(), CStepMatrix::getUnsetBitIndexes(), CMathContainer::init(), CExperiment::initExtendedTimeSeries(), CopasiPlot::initFromSpec(), CMathReaction::initialize(), COptMethodEP::initialize(), COptMethodSteepestDescent::initialize(), COptMethodStatistics::initialize(), CRandomSearch::initialize(), COptMethodDE::initialize(), COptMethodSRES::initialize(), COptMethodPS::initialize(), COptMethodGA::initialize(), COptMethodGASR::initialize(), COptMethodHookeJeeves::initialize(), COptMethodLevenbergMarquardt::initialize(), COptMethodNelderMead::initialize(), COptMethodSA::initialize(), COptMethodCoranaWalk::initialize(), COptMethodPraxis::initialize(), COptMethodTruncatedNewton::initialize(), CFitProblem::initialize(), COptProblem::initialize(), CLyapTask::initialize(), COptMethodSS::initialize(), CNewtonMethod::initialize(), CProcessQueue::initialize(), CEigen::initialize(), CTSSAMethod::initializeAtol(), CModel::initializeAtolVector(), CHybridMethodODE45::initMethod(), CHybridMethodLSODA::initMethod(), CLyapTask::initObjects(), CTSSAMethod::integrationMethodStart(), LUfactor(), CTSSAMethod::mat_anal_fast_space_thomas(), CTSSAMethod::mat_anal_metab(), CTSSAMethod::mat_anal_mod(), CILDMMethod::newton(), CILDMModifiedMethod::newton_for_timestep(), CILDMModifiedMethod::newton_new(), COptMethodLevenbergMarquardt::optimise(), COptMethodEP2::optimise(), partialSortWithPivot(), CExperiment::read(), CTSSAMethod::schur(), CTSSAMethod::schur_desc(), CFitProblem::setResidualsRequired(), CHybridMethodODE45::setupReactionFlags(), CStateTemplate::setUserOrder(), CProgressBar::slotAddItem(), CNewtonMethod::solveJacobianXeqB(), sortWithPivot(), CILDMMethod::start(), CILDMModifiedMethod::start(), CTauLeapMethod::start(), CStochDirectMethod::start(), CCSPMethod::start(), CLyapWolfMethod::start(), CTrajAdaptiveSA::start(), CLsodaMethod::start(), CTrajectoryMethodDsaLsodar::start(), CILDMMethod::step(), CILDMModifiedMethod::step(), CTSSAMethod::sylvester(), and CCSPMethod::yCorrection().

302  {
303  //TODO: maybe we should only resize if the vector gets bigger
304  //or much smaller?
305  if (size == CVectorCore< CType >::mSize) return;
306 
307  size_t OldSize = CVectorCore< CType >::mSize;
308  CType * OldVector = CVectorCore< CType >::mVector;
309 
310  //TODO: maybe we should only resize if the vector gets bigger
311  //or much smaller?
314 
316  {
317  try
318  {
319  // We need to detect size_t overflow
321  {
323  }
324  else
325  {
327  }
328  }
329 
330  catch (...)
331  {
334  }
335  }
336 
337  if (copy &&
339  OldVector != NULL)
340  {
341  memcpy((void *) CVectorCore< CType >::mVector,
342  (void *) OldVector,
343  std::min(CVectorCore< CType >::mSize, OldSize) * sizeof(CType));
344  }
345 
346  if (OldVector != NULL)
347  {
348  delete [] OldVector;
349  }
350 
351  // Check if allocation failed
352  if (CVectorCore< CType >::mVector == NULL &&
353  size > 0)
354  {
356  }
357  }
#define MCopasiBase
size_t size() const
Definition: CVector.h:100
#define C_FLOAT64
Definition: copasi.h:92
void copy(const CVectorCore< CType > &rhs)
Definition: CVector.h:360
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176

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