36 #ifndef VECTORHELPERFUNCTIONS_HPP_
37 #define VECTORHELPERFUNCTIONS_HPP_
52 #include <nvector/nvector_serial.h>
66 template <
typename VECTOR>
79 template <
typename VECTOR>
91 template <
typename VECTOR>
102 template <
typename VECTOR>
115 template <
typename VECTOR>
123 template <
typename VECTOR>
132 template <
typename VECTOR>
143 template <
typename VECTOR>
155 template <
typename VECTOR>
167 template <
typename VECTOR>
168 inline void CopyToStdVector(
const VECTOR& rSrc, std::vector<double>& rDest);
179 template <
typename VECTOR>
193 assert(index < rVec.size());
206 assert(index < rVec.size());
251 return std::vector<double>();
280 inline std::vector<double>
CopyVector(std::vector<double>& rVec)
291 inline void CopyToStdVector(
const std::vector<double>& rSrc, std::vector<double>& rDest)
320 assert(rVec !=
nullptr);
321 return NV_Ith_S(rVec, index);
333 assert(rVec !=
nullptr);
334 NV_Ith_S(rVec, index) = value;
345 assert(rVec !=
nullptr);
346 return NV_LENGTH_S(rVec);
369 rVec = N_VNew_Serial(size);
391 return rVec ==
nullptr;
403 rVec->ops->nvdestroy(rVec);
419 copy = N_VClone(rVec);
420 unsigned size = NV_LENGTH_S(rVec);
421 for (
unsigned i = 0; i < size; i++)
423 NV_Ith_S(copy, i) = NV_Ith_S(rVec, i);
439 realtype* p_src = NV_DATA_S(rSrc);
440 if (!rDest.empty() && p_src == &(rDest[0]))
443 long size = NV_LENGTH_S(rSrc);
446 for (
long i = 0; i < size; i++)
462 realtype* p_dest = NV_DATA_S(rDest);
463 if (p_dest == &(rSrc[0]))
return;
466 long size = NV_LENGTH_S(rDest);
467 assert(size == (
long)rSrc.size());
470 for (
long i = 0; i < size; i++)
484 std::vector<double> sv;
503 #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)