MUQ  0.4.3
SundialsAlgebra.cpp
Go to the documentation of this file.
2 
3 using namespace muq::Modeling;
4 
6 
8 
9 #if MUQ_HAS_SUNDIALS==1
10 bool SundialsAlgebra::IsSundialsVector(std::type_info const& obj_type) {
11  return typeid(N_Vector)==obj_type;
12 }
13 #endif
14 
15 #if MUQ_HAS_SUNDIALS==1
16 unsigned int SundialsAlgebra::Size(boost::any const& vec) {
17  const N_Vector& sun = boost::any_cast<N_Vector const&>(vec);
18 
19  return NV_LENGTH_S(sun);
20 }
21 #endif
22 
23 #if MUQ_HAS_SUNDIALS==1
24 boost::any SundialsAlgebra::AccessElement(N_Vector const& vec, unsigned int const i) {
25  // check the size
26  assert(i<NV_LENGTH_S(vec));
27 
28  // return the ith element
29  return NV_Ith_S(vec, i);
30 }
31 #endif
static bool IsSundialsVector(std::type_info const &obj)
Is a boost::any an N_Vector type?
static unsigned int Size(boost::any const &vec)
The size of an N_Vector.
static boost::any AccessElement(N_Vector const &obj, unsigned int const i)
Access an element of a Sundials vector.