Last active
February 28, 2020 04:36
-
-
Save SteveBronder/fa043590262bff4457acc3257353b5ea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code generated by stanc acfb4612 | |
| #include <stan/model/model_header.hpp> | |
| namespace example_model_namespace { | |
| template <typename T, typename S> | |
| std::vector<T> resize_to_match__(std::vector<T> &dst, | |
| const std::vector<S> &src) { | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, -1, -1> | |
| resize_to_match__(Eigen::Matrix<T, -1, -1> &dst, | |
| const Eigen::Matrix<T, -1, -1> &src) { | |
| dst.resize(src.rows(), src.cols()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, 1, -1> resize_to_match__(Eigen::Matrix<T, 1, -1> &dst, | |
| const Eigen::Matrix<T, 1, -1> &src) { | |
| // Code generated by stanc acfb4612 | |
| #include <stan/model/model_header.hpp> | |
| namespace example_model_namespace { | |
| template <typename T, typename S> | |
| std::vector<T> resize_to_match__(std::vector<T>& dst, const std::vector<S>& src) { | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, -1, -1> | |
| resize_to_match__(Eigen::Matrix<T, -1, -1>& dst, const Eigen::Matrix<T, -1, -1>& src) { | |
| dst.resize(src.rows(), src.cols()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, 1, -1> | |
| resize_to_match__(Eigen::Matrix<T, 1, -1>& dst, const Eigen::Matrix<T, 1, -1>& src) { | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, -1, 1> | |
| resize_to_match__(Eigen::Matrix<T, -1, 1>& dst, const Eigen::Matrix<T, -1, 1>& src) { | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| std::vector<double> to_doubles__(std::initializer_list<double> x) { | |
| return x; | |
| } | |
| std::vector<stan::math::var> to_vars__(std::initializer_list<stan::math::var> x) { | |
| return x; | |
| } | |
| inline void validate_positive_index(const char* var_name, const char* expr, | |
| int val) { | |
| if (val < 1) { | |
| std::stringstream msg; | |
| msg << "Found dimension size less than one in simplex declaration" | |
| << "; variable=" << var_name << "; dimension size expression=" << expr | |
| << "; expression value=" << val; | |
| std::string msg_str(msg.str()); | |
| throw std::invalid_argument(msg_str.c_str()); | |
| } | |
| } | |
| inline void validate_unit_vector_index(const char* var_name, const char* expr, | |
| int val) { | |
| if (val <= 1) { | |
| std::stringstream msg; | |
| if (val == 1) { | |
| msg << "Found dimension size one in unit vector declaration." | |
| << " One-dimensional unit vector is discrete" | |
| << " but the target distribution must be continuous." | |
| << " variable=" << var_name << "; dimension size expression=" << expr; | |
| } else { | |
| msg << "Found dimension size less than one in unit vector declaration" | |
| << "; variable=" << var_name << "; dimension size expression=" << expr | |
| << "; expression value=" << val; | |
| } | |
| std::string msg_str(msg.str()); | |
| throw std::invalid_argument(msg_str.c_str()); | |
| } | |
| } | |
| using std::istream; | |
| using std::string; | |
| using std::stringstream; | |
| using std::vector; | |
| using stan::io::dump; | |
| using stan::math::lgamma; | |
| using stan::model::model_base_crtp; | |
| using stan::model::rvalue; | |
| using stan::model::cons_list; | |
| using stan::model::index_uni; | |
| using stan::model::index_max; | |
| using stan::model::index_min; | |
| using stan::model::index_min_max; | |
| using stan::model::index_multi; | |
| using stan::model::index_omni; | |
| using stan::model::nil_index_list; | |
| using namespace stan::math; | |
| static int current_statement__ = 0; | |
| static const std::vector<string> locations_array__ = {" (found before start of program)", | |
| " (in 'examples/example.stan', line 2, column 2 to column 29)", | |
| " (in 'examples/example.stan', line 3, column 2 to line 5, column 3)", | |
| " (in 'examples/example.stan', line 4, column 4 to column 13)"}; | |
| class example_model : public model_base_crtp<example_model> { | |
| private: | |
| int pos__; | |
| std::vector<int> indices; | |
| public: | |
| ~example_model() { } | |
| std::string model_name() const { return "example_model"; } | |
| example_model(stan::io::var_context& context__, | |
| unsigned int random_seed__ = 0, | |
| std::ostream* pstream__ = nullptr) : model_base_crtp(0) { | |
| typedef double local_scalar_t__; | |
| boost::ecuyer1988 base_rng__ = | |
| stan::services::util::create_rng(random_seed__, 0); | |
| (void) base_rng__; // suppress unused var warning | |
| static const char* function__ = "example_model_namespace::example_model"; | |
| (void) function__; // suppress unused var warning | |
| try { | |
| pos__ = 1; | |
| current_statement__ = 1; | |
| validate_non_negative_index("indices", "4", 4); | |
| indices = std::vector<int>(4, 0); | |
| current_statement__ = 1; | |
| indices = stan::math::array_builder<int>().add(1).add(2).add(3).add(4) | |
| .array(); | |
| current_statement__ = 2; | |
| for (size_t sym1__ = 1; | |
| sym1__ <= stan::math::size( | |
| rvalue(indices, | |
| cons_list(index_min_max(1, 3), nil_index_list()), | |
| "indices")); ++sym1__) { | |
| { | |
| int i; | |
| current_statement__ = 2; | |
| i = rvalue(indices, | |
| cons_list(index_min_max(1, 3), | |
| cons_list(index_uni(sym1__), nil_index_list())), "indices"); | |
| current_statement__ = 3; | |
| if (pstream__) { | |
| stan_print(pstream__, i); | |
| stan_print(pstream__, "\n"); | |
| } | |
| }} | |
| } catch (const std::exception& e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| num_params_r__ = 0U; | |
| try { | |
| } catch (const std::exception& e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } | |
| template <bool propto__, bool jacobian__, typename T__> | |
| T__ log_prob(std::vector<T__>& params_r__, std::vector<int>& params_i__, | |
| std::ostream* pstream__ = 0) const { | |
| typedef T__ local_scalar_t__; | |
| T__ lp__(0.0); | |
| stan::math::accumulator<T__> lp_accum__; | |
| static const char* function__ = "example_model_namespace::log_prob"; | |
| (void) function__; // suppress unused var warning | |
| stan::io::reader<local_scalar_t__> in__(params_r__, params_i__); | |
| try { | |
| } catch (const std::exception& e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| lp_accum__.add(lp__); | |
| return lp_accum__.sum(); | |
| } // log_prob() | |
| template <typename RNG> | |
| void write_array(RNG& base_rng__, std::vector<double>& params_r__, | |
| std::vector<int>& params_i__, std::vector<double>& vars__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true, | |
| std::ostream* pstream__ = 0) const { | |
| typedef double local_scalar_t__; | |
| vars__.resize(0); | |
| stan::io::reader<local_scalar_t__> in__(params_r__, params_i__); | |
| static const char* function__ = "example_model_namespace::write_array"; | |
| (void) function__; // suppress unused var warning | |
| (void) function__; // suppress unused var warning | |
| double lp__ = 0.0; | |
| (void) lp__; // dummy to suppress unused var warning | |
| stan::math::accumulator<double> lp_accum__; | |
| try { | |
| if (logical_negation((primitive_value(emit_transformed_parameters__) || | |
| primitive_value(emit_generated_quantities__)))) { | |
| return ; | |
| } | |
| if (logical_negation(emit_generated_quantities__)) { | |
| return ; | |
| } | |
| } catch (const std::exception& e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } // write_array() | |
| void transform_inits(const stan::io::var_context& context__, | |
| std::vector<int>& params_i__, | |
| std::vector<double>& vars__, std::ostream* pstream__) const { | |
| typedef double local_scalar_t__; | |
| vars__.resize(0); | |
| vars__.reserve(num_params_r__); | |
| try { | |
| int pos__; | |
| pos__ = 1; | |
| } catch (const std::exception& e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } // transform_inits() | |
| void get_param_names(std::vector<std::string>& names__) const { | |
| names__.resize(0); | |
| } // get_param_names() | |
| void get_dims(std::vector<std::vector<size_t>>& dimss__) const { | |
| dimss__.resize(0); | |
| std::vector<size_t> dims__; | |
| dimss__.push_back(dims__); | |
| dims__.resize(0); | |
| } // get_dims() | |
| void constrained_param_names(std::vector<std::string>& param_names__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true) const { | |
| if (emit_transformed_parameters__) { | |
| } | |
| if (emit_generated_quantities__) { | |
| } | |
| } // constrained_param_names() | |
| void unconstrained_param_names(std::vector<std::string>& param_names__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true) const { | |
| if (emit_transformed_parameters__) { | |
| } | |
| if (emit_generated_quantities__) { | |
| } | |
| } // unconstrained_param_names() | |
| std::string get_constrained_sizedtypes() const { | |
| stringstream s__; | |
| s__ << "[]"; | |
| return s__.str(); | |
| } // get_constrained_sizedtypes() | |
| std::string get_unconstrained_sizedtypes() const { | |
| stringstream s__; | |
| s__ << "[]"; | |
| return s__.str(); | |
| } // get_unconstrained_sizedtypes() | |
| // Begin method overload boilerplate | |
| template <typename RNG> | |
| void write_array(RNG& base_rng__, | |
| Eigen::Matrix<double,Eigen::Dynamic,1>& params_r, | |
| Eigen::Matrix<double,Eigen::Dynamic,1>& vars, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true, | |
| std::ostream* pstream = 0) const { | |
| std::vector<double> params_r_vec(params_r.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| params_r_vec[i] = params_r(i); | |
| std::vector<double> vars_vec; | |
| std::vector<int> params_i_vec; | |
| write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, | |
| emit_transformed_parameters__, emit_generated_quantities__, pstream); | |
| vars.resize(vars_vec.size()); | |
| for (int i = 0; i < vars.size(); ++i) | |
| vars(i) = vars_vec[i]; | |
| } | |
| template <bool propto__, bool jacobian__, typename T_> | |
| T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r, | |
| std::ostream* pstream = 0) const { | |
| std::vector<T_> vec_params_r; | |
| vec_params_r.reserve(params_r.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| vec_params_r.push_back(params_r(i)); | |
| std::vector<int> vec_params_i; | |
| return log_prob<propto__,jacobian__,T_>(vec_params_r, vec_params_i, pstream); | |
| } | |
| void transform_inits(const stan::io::var_context& context, | |
| Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r, | |
| std::ostream* pstream__) const { | |
| std::vector<double> params_r_vec; | |
| std::vector<int> params_i_vec; | |
| transform_inits(context, params_i_vec, params_r_vec, pstream__); | |
| params_r.resize(params_r_vec.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| params_r(i) = params_r_vec[i]; | |
| } | |
| }; | |
| } | |
| typedef example_model_namespace::example_model stan_model; | |
| #ifndef USING_R | |
| // Boilerplate | |
| stan::model::model_base& new_model( | |
| stan::io::var_context& data_context, | |
| unsigned int seed, | |
| std::ostream* msg_stream) { | |
| stan_model* m = new stan_model(data_context, seed, msg_stream); | |
| return *m; | |
| } | |
| #endif | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| template <typename T> | |
| Eigen::Matrix<T, -1, 1> resize_to_match__(Eigen::Matrix<T, -1, 1> &dst, | |
| const Eigen::Matrix<T, -1, 1> &src) { | |
| dst.resize(src.size()); | |
| return dst; | |
| } | |
| std::vector<double> to_doubles__(std::initializer_list<double> x) { return x; } | |
| std::vector<stan::math::var> | |
| to_vars__(std::initializer_list<stan::math::var> x) { | |
| return x; | |
| } | |
| inline void validate_positive_index(const char *var_name, const char *expr, | |
| int val) { | |
| if (val < 1) { | |
| std::stringstream msg; | |
| msg << "Found dimension size less than one in simplex declaration" | |
| << "; variable=" << var_name << "; dimension size expression=" << expr | |
| << "; expression value=" << val; | |
| std::string msg_str(msg.str()); | |
| throw std::invalid_argument(msg_str.c_str()); | |
| } | |
| } | |
| inline void validate_unit_vector_index(const char *var_name, const char *expr, | |
| int val) { | |
| if (val <= 1) { | |
| std::stringstream msg; | |
| if (val == 1) { | |
| msg << "Found dimension size one in unit vector declaration." | |
| << " One-dimensional unit vector is discrete" | |
| << " but the target distribution must be continuous." | |
| << " variable=" << var_name << "; dimension size expression=" << expr; | |
| } else { | |
| msg << "Found dimension size less than one in unit vector declaration" | |
| << "; variable=" << var_name << "; dimension size expression=" << expr | |
| << "; expression value=" << val; | |
| } | |
| std::string msg_str(msg.str()); | |
| throw std::invalid_argument(msg_str.c_str()); | |
| } | |
| } | |
| using stan::io::dump; | |
| using stan::math::lgamma; | |
| using stan::model::cons_list; | |
| using stan::model::index_max; | |
| using stan::model::index_min; | |
| using stan::model::index_min_max; | |
| using stan::model::index_multi; | |
| using stan::model::index_omni; | |
| using stan::model::index_uni; | |
| using stan::model::model_base_crtp; | |
| using stan::model::nil_index_list; | |
| using stan::model::rvalue; | |
| using std::istream; | |
| using std::string; | |
| using std::stringstream; | |
| using std::vector; | |
| using namespace stan::math; | |
| static int current_statement__ = 0; | |
| static const std::vector<string> locations_array__ = { | |
| " (found before start of program)", | |
| " (in 'examples/example.stan', line 2, column 2 to column 29)", | |
| " (in 'examples/example.stan', line 4, column 2 to column 28)", | |
| " (in 'examples/example.stan', line 5, column 2 to line 7, column 3)", | |
| " (in 'examples/example.stan', line 6, column 4 to column 13)"}; | |
| class example_model : public model_base_crtp<example_model> { | |
| private: | |
| int pos__; | |
| std::vector<int> indices; | |
| int ind; | |
| public: | |
| ~example_model() {} | |
| std::string model_name() const { return "example_model"; } | |
| example_model(stan::io::var_context &context__, | |
| unsigned int random_seed__ = 0, | |
| std::ostream *pstream__ = nullptr) | |
| : model_base_crtp(0) { | |
| typedef double local_scalar_t__; | |
| boost::ecuyer1988 base_rng__ = | |
| stan::services::util::create_rng(random_seed__, 0); | |
| (void)base_rng__; // suppress unused var warning | |
| static const char *function__ = "example_model_namespace::example_model"; | |
| (void)function__; // suppress unused var warning | |
| try { | |
| pos__ = 1; | |
| current_statement__ = 1; | |
| validate_non_negative_index("indices", "4", 4); | |
| indices = std::vector<int>(4, 0); | |
| current_statement__ = 1; | |
| indices = | |
| stan::math::array_builder<int>().add(1).add(2).add(3).add(4).array(); | |
| current_statement__ = 2; | |
| ind = rvalue(indices, cons_list(index_min_max(1, 3), nil_index_list()), | |
| "indices")[(1 - 1)]; | |
| current_statement__ = 3; | |
| for (size_t sym1__ = 1; | |
| sym1__ <= | |
| stan::math::size( | |
| rvalue(indices, cons_list(index_min_max(1, 3), nil_index_list()), | |
| "indices")); | |
| ++sym1__) { | |
| { | |
| int i; | |
| current_statement__ = 3; | |
| i = rvalue(rvalue(indices, | |
| cons_list(index_min_max(1, 3), nil_index_list()), | |
| "indices"), cons_list(index_uni(sym1__), nil_index_list())); | |
| current_statement__ = 4; | |
| if (pstream__) { | |
| stan_print(pstream__, i); | |
| stan_print(pstream__, "\n"); | |
| } | |
| } | |
| } | |
| } catch (const std::exception &e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| num_params_r__ = 0U; | |
| try { | |
| } catch (const std::exception &e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } | |
| template <bool propto__, bool jacobian__, typename T__> | |
| T__ log_prob(std::vector<T__> ¶ms_r__, std::vector<int> ¶ms_i__, | |
| std::ostream *pstream__ = 0) const { | |
| typedef T__ local_scalar_t__; | |
| T__ lp__(0.0); | |
| stan::math::accumulator<T__> lp_accum__; | |
| static const char *function__ = "example_model_namespace::log_prob"; | |
| (void)function__; // suppress unused var warning | |
| stan::io::reader<local_scalar_t__> in__(params_r__, params_i__); | |
| try { | |
| } catch (const std::exception &e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| lp_accum__.add(lp__); | |
| return lp_accum__.sum(); | |
| } // log_prob() | |
| template <typename RNG> | |
| void write_array(RNG &base_rng__, std::vector<double> ¶ms_r__, | |
| std::vector<int> ¶ms_i__, std::vector<double> &vars__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true, | |
| std::ostream *pstream__ = 0) const { | |
| typedef double local_scalar_t__; | |
| vars__.resize(0); | |
| stan::io::reader<local_scalar_t__> in__(params_r__, params_i__); | |
| static const char *function__ = "example_model_namespace::write_array"; | |
| (void)function__; // suppress unused var warning | |
| (void)function__; // suppress unused var warning | |
| double lp__ = 0.0; | |
| (void)lp__; // dummy to suppress unused var warning | |
| stan::math::accumulator<double> lp_accum__; | |
| try { | |
| if (logical_negation((primitive_value(emit_transformed_parameters__) || | |
| primitive_value(emit_generated_quantities__)))) { | |
| return; | |
| } | |
| if (logical_negation(emit_generated_quantities__)) { | |
| return; | |
| } | |
| } catch (const std::exception &e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } // write_array() | |
| void transform_inits(const stan::io::var_context &context__, | |
| std::vector<int> ¶ms_i__, | |
| std::vector<double> &vars__, | |
| std::ostream *pstream__) const { | |
| typedef double local_scalar_t__; | |
| vars__.resize(0); | |
| vars__.reserve(num_params_r__); | |
| try { | |
| int pos__; | |
| pos__ = 1; | |
| } catch (const std::exception &e) { | |
| stan::lang::rethrow_located(e, locations_array__[current_statement__]); | |
| // Next line prevents compiler griping about no return | |
| throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ***"); | |
| } | |
| } // transform_inits() | |
| void get_param_names(std::vector<std::string> &names__) const { | |
| names__.resize(0); | |
| } // get_param_names() | |
| void get_dims(std::vector<std::vector<size_t>> &dimss__) const { | |
| dimss__.resize(0); | |
| std::vector<size_t> dims__; | |
| dimss__.push_back(dims__); | |
| dims__.resize(0); | |
| } // get_dims() | |
| void constrained_param_names(std::vector<std::string> ¶m_names__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true) const { | |
| if (emit_transformed_parameters__) { | |
| } | |
| if (emit_generated_quantities__) { | |
| } | |
| } // constrained_param_names() | |
| void | |
| unconstrained_param_names(std::vector<std::string> ¶m_names__, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true) const { | |
| if (emit_transformed_parameters__) { | |
| } | |
| if (emit_generated_quantities__) { | |
| } | |
| } // unconstrained_param_names() | |
| std::string get_constrained_sizedtypes() const { | |
| stringstream s__; | |
| s__ << "[]"; | |
| return s__.str(); | |
| } // get_constrained_sizedtypes() | |
| std::string get_unconstrained_sizedtypes() const { | |
| stringstream s__; | |
| s__ << "[]"; | |
| return s__.str(); | |
| } // get_unconstrained_sizedtypes() | |
| // Begin method overload boilerplate | |
| template <typename RNG> | |
| void write_array(RNG &base_rng__, | |
| Eigen::Matrix<double, Eigen::Dynamic, 1> ¶ms_r, | |
| Eigen::Matrix<double, Eigen::Dynamic, 1> &vars, | |
| bool emit_transformed_parameters__ = true, | |
| bool emit_generated_quantities__ = true, | |
| std::ostream *pstream = 0) const { | |
| std::vector<double> params_r_vec(params_r.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| params_r_vec[i] = params_r(i); | |
| std::vector<double> vars_vec; | |
| std::vector<int> params_i_vec; | |
| write_array(base_rng__, params_r_vec, params_i_vec, vars_vec, | |
| emit_transformed_parameters__, emit_generated_quantities__, | |
| pstream); | |
| vars.resize(vars_vec.size()); | |
| for (int i = 0; i < vars.size(); ++i) | |
| vars(i) = vars_vec[i]; | |
| } | |
| template <bool propto__, bool jacobian__, typename T_> | |
| T_ log_prob(Eigen::Matrix<T_, Eigen::Dynamic, 1> ¶ms_r, | |
| std::ostream *pstream = 0) const { | |
| std::vector<T_> vec_params_r; | |
| vec_params_r.reserve(params_r.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| vec_params_r.push_back(params_r(i)); | |
| std::vector<int> vec_params_i; | |
| return log_prob<propto__, jacobian__, T_>(vec_params_r, vec_params_i, | |
| pstream); | |
| } | |
| void transform_inits(const stan::io::var_context &context, | |
| Eigen::Matrix<double, Eigen::Dynamic, 1> ¶ms_r, | |
| std::ostream *pstream__) const { | |
| std::vector<double> params_r_vec; | |
| std::vector<int> params_i_vec; | |
| transform_inits(context, params_i_vec, params_r_vec, pstream__); | |
| params_r.resize(params_r_vec.size()); | |
| for (int i = 0; i < params_r.size(); ++i) | |
| params_r(i) = params_r_vec[i]; | |
| } | |
| }; | |
| } // namespace example_model_namespace | |
| typedef example_model_namespace::example_model stan_model; | |
| #ifndef USING_R | |
| // Boilerplate | |
| stan::model::model_base &new_model(stan::io::var_context &data_context, | |
| unsigned int seed, | |
| std::ostream *msg_stream) { | |
| stan_model *m = new stan_model(data_context, seed, msg_stream); | |
| return *m; | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment