1717#include < vector>
1818#include < limits>
1919
20+ static sundials::Context sundials_context;
21+
2022struct chemical_kinetics {
2123 template <typename T0 , typename TYY , typename TYP , typename TPAR >
2224 inline std::vector<stan::return_type_t <TYY , TYP , TPAR >> operator ()(
@@ -108,9 +110,9 @@ void idas_forward_sen_test(chemical_kinetics& f, std::vector<int> eq_id,
108110
109111 if (dae.need_sens ) {
110112 auto sensitivity_residual = dae.sensitivity_residual ();
111- auto temp1 = N_VNew_Serial (n);
112- auto temp2 = N_VNew_Serial (n);
113- auto temp3 = N_VNew_Serial (n);
113+ auto temp1 = N_VNew_Serial (n, sundials_context );
114+ auto temp2 = N_VNew_Serial (n, sundials_context );
115+ auto temp3 = N_VNew_Serial (n, sundials_context );
114116 EXPECT_EQ (sensitivity_residual (ns, t, yy, yp, res, yys, yps, ress,
115117 user_data, temp1, temp2, temp3),
116118 0 );
@@ -131,19 +133,19 @@ TEST(IDAS_DAE_SYSTEM, idas_system_io) {
131133 auto theta_var = stan::math::to_var (theta);
132134
133135 {
134- N_Vector res = N_VNew_Serial (yy0.size ());
136+ N_Vector res = N_VNew_Serial (yy0.size (), sundials_context );
135137 idas_system_test (f, eq_id, yy0, yp0, theta, res);
136138 N_VDestroy_Serial (res);
137139 }
138140
139141 {
140- N_Vector res = N_VNew_Serial (yy0.size ());
142+ N_Vector res = N_VNew_Serial (yy0.size (), sundials_context );
141143 idas_system_test (f, eq_id, yy0_var, yp0_var, theta_var, res);
142144 N_VDestroy_Serial (res);
143145 }
144146
145147 {
146- N_Vector res = N_VNew_Serial (yy0.size ());
148+ N_Vector res = N_VNew_Serial (yy0.size (), sundials_context );
147149 idas_system_test (f, eq_id, yy0, yp0_var, theta_var, res);
148150 N_VDestroy_Serial (res);
149151 }
@@ -161,15 +163,15 @@ TEST(IDAS_DAE_SYSTEM, idas_forward_system_io) {
161163 const size_t n = yy0.size ();
162164
163165 {
164- N_Vector res = N_VNew_Serial (n);
166+ N_Vector res = N_VNew_Serial (n, sundials_context );
165167 N_Vector* ress = N_VCloneVectorArray (theta.size (), res);
166168 idas_forward_sen_test (f, eq_id, yy0, yp0, theta, res, ress);
167169 N_VDestroy_Serial (res);
168170 N_VDestroyVectorArray (ress, theta.size ());
169171 }
170172
171173 {
172- N_Vector res = N_VNew_Serial (n);
174+ N_Vector res = N_VNew_Serial (n, sundials_context );
173175 N_Vector* ress = N_VCloneVectorArray (theta.size (), res);
174176 idas_forward_sen_test (f, eq_id, yy0, yp0, theta_var, res, ress);
175177 EXPECT_EQ (NV_Ith_S (ress[0 ], 0 ), yy0[0 ]);
@@ -181,7 +183,7 @@ TEST(IDAS_DAE_SYSTEM, idas_forward_system_io) {
181183
182184 {
183185 size_t ns = n + n + theta.size ();
184- N_Vector res = N_VNew_Serial (n);
186+ N_Vector res = N_VNew_Serial (n, sundials_context );
185187 N_Vector* ress = N_VCloneVectorArray (ns, res);
186188 idas_forward_sen_test (f, eq_id, yy0_var, yp0_var, theta_var, res, ress);
187189 EXPECT_EQ (NV_Ith_S (ress[n + n], 0 ), yy0[0 ]);
@@ -219,7 +221,7 @@ TEST(IDAS_DAE_SYSTEM, idas_forward_system_general) {
219221 auto p2 = theta[1 ];
220222 auto p3 = theta[2 ];
221223
222- N_Vector res = N_VNew_Serial (n);
224+ N_Vector res = N_VNew_Serial (n, sundials_context );
223225 N_Vector* ress = N_VCloneVectorArray (ns, res);
224226 for (size_t is = 0 ; is < ns; is++) {
225227 N_VConst (RCONST (1.0 ), yys[is]);
@@ -235,9 +237,9 @@ TEST(IDAS_DAE_SYSTEM, idas_forward_system_general) {
235237 EXPECT_EQ (NV_Ith_S (res, i), fval[i]);
236238
237239 auto sensitivity_residual = dae.sensitivity_residual ();
238- auto temp1 = N_VNew_Serial (n);
239- auto temp2 = N_VNew_Serial (n);
240- auto temp3 = N_VNew_Serial (n);
240+ auto temp1 = N_VNew_Serial (n, sundials_context );
241+ auto temp2 = N_VNew_Serial (n, sundials_context );
242+ auto temp3 = N_VNew_Serial (n, sundials_context );
241243 EXPECT_EQ (sensitivity_residual (ns, t, yy, yp, res, yys, yps, ress, user_data,
242244 temp1, temp2, temp3),
243245 0 );
0 commit comments