36 #ifndef VECTORHELPERFUNCTIONS_HPP_
37 #define VECTORHELPERFUNCTIONS_HPP_
52 #include <nvector/nvector_serial.h>
65 template<
typename VECTOR>
78 template<
typename VECTOR>
90 template<
typename VECTOR>
101 template<
typename VECTOR>
114 template<
typename VECTOR>
122 template<
typename VECTOR>
131 template<
typename VECTOR>
142 template<
typename VECTOR>
154 template<
typename VECTOR>
166 template<
typename VECTOR>
167 inline void CopyToStdVector(
const VECTOR& rSrc, std::vector<double>& rDest);
178 template<
typename VECTOR>
192 assert(index < rVec.size());
205 assert(index < rVec.size());
250 return std::vector<double>();
279 inline std::vector<double>
CopyVector(std::vector<double>& rVec)
290 inline void CopyToStdVector(
const std::vector<double>& rSrc, std::vector<double>& rDest)
319 assert(rVec != NULL);
320 return NV_Ith_S(rVec, index);
332 assert(rVec != NULL);
333 NV_Ith_S(rVec, index) = value;
344 assert(rVec != NULL);
345 return NV_LENGTH_S(rVec);
368 rVec = N_VNew_Serial(size);
402 rVec->ops->nvdestroy(rVec);
418 copy = N_VClone(rVec);
419 unsigned size = NV_LENGTH_S(rVec);
420 for (
unsigned i=0; i<size; i++)
422 NV_Ith_S(copy, i) = NV_Ith_S(rVec, i);
438 realtype* p_src = NV_DATA_S(rSrc);
439 if (!rDest.empty() && p_src == &(rDest[0]))
return;
441 long size = NV_LENGTH_S(rSrc);
444 for (
long i=0; i<size; i++)
460 realtype* p_dest = NV_DATA_S(rDest);
461 if (p_dest == &(rSrc[0]))
return;
464 long size = NV_LENGTH_S(rDest);
465 assert(size == (
long)rSrc.size());
468 for (
long i=0; i<size; i++)
482 std::vector<double> sv;
501 #endif // CHASTE_CVODE
std::vector< double > MakeStdVec(N_Vector v)
VECTOR CreateEmptyVector()
VECTOR CopyVector(VECTOR &rVec)
N_Vector MakeNVector(const std::vector< double > &rSrc)
void InitialiseEmptyVector(VECTOR &rVec)
void CreateVectorIfEmpty(VECTOR &rVec, unsigned size)
void SetVectorComponent(VECTOR &rVec, unsigned index, double value)
void CopyFromStdVector(const std::vector< double > &rSrc, VECTOR &rDest)
void CopyToStdVector(const VECTOR &rSrc, std::vector< double > &rDest)
double GetVectorComponent(const VECTOR &rVec, unsigned index)
void DeleteVector(VECTOR &rVec)
unsigned GetVectorSize(const VECTOR &rVec)
bool IsEmptyVector(VECTOR &rVec)