// Code generated by stanc v2.31.0 #include namespace minimalODEExampleExternal_model_namespace { struct odefunc_functor__ { template, stan::is_col_vector, stan::is_vt_not_complex, stan::is_stan_scalar>* = nullptr> Eigen::Matrix, T2__>, -1, 1> operator()( const T0__& t, const T1__& y, const T2__& theta, std::ostream* pstream__) const; }; // Specialization for var types template, stan::is_vt_not_complex, stan::is_var>>* = nullptr> Eigen::Matrix odefunc(const double& t, const T1__& y, const double& theta, std::ostream* pstream__) { // All matrices used in reverse pass callback must be arena allocated stan::arena_t> dydt(2); dydt[0] = y[1].val(); dydt[1] = -theta * y[0].val(); stan::arena_t> jacobianT = Eigen::MatrixXd::Zero(2, 2); jacobianT(1, 0) = 1.0; jacobianT(0, 1) = -theta; stan::arena_t y_arena = y; // Use reverse_pass_callback since our return type is an Eigen matrix // This adds the reverse pass to our callback stack when we call grad() after building the autodiff tree stan::math::reverse_pass_callback([y_arena, jacobianT, dydt]() mutable { y_arena.adj() += jacobianT * dydt.adj(); }); // Make a hard copy of dydt to avoid overwriting values used in reverse pass return Eigen::Matrix(dydt); } /** * Only doing the forward pass of above. Supports double and fvar types */ template, stan::is_vt_not_complex>* = nullptr, stan::require_not_vt_var* = nullptr> Eigen::Matrix, -1, 1> odefunc(const double& t, const T1__& y, const double& theta, std::ostream* pstream__) { using scalar_t = stan::scalar_type_t; Eigen::Matrix dydt = Eigen::Matrix::Zero(2); dydt[0] = y[1]; dydt[1] = -theta * y[0]; return dydt; } template< typename T0__, typename T1__, typename T2__, stan::require_all_t, stan::is_col_vector, stan::is_vt_not_complex, stan::is_stan_scalar>*> Eigen::Matrix, T2__>, -1, 1> odefunc_functor__:: operator()(const T0__& t, const T1__& y, const T2__& theta, std::ostream* pstream__) const { return odefunc(t, y, theta, pstream__); } } //namespace