// Code generated by stanc v2.33.1 #include namespace prophet_model_namespace { using stan::model::model_base_crtp; using namespace stan::math; stan::math::profile_map profiles__; static constexpr std::array locations_array__ = {" (found before start of program)", " (in 'prophet.stan', line 110, column 2 to column 9)", " (in 'prophet.stan', line 111, column 2 to column 9)", " (in 'prophet.stan', line 112, column 2 to column 18)", " (in 'prophet.stan', line 113, column 2 to column 26)", " (in 'prophet.stan', line 114, column 2 to column 17)", " (in 'prophet.stan', line 118, column 2 to column 18)", " (in 'prophet.stan', line 124, column 4 to column 29)", " (in 'prophet.stan', line 123, column 35 to line 125, column 3)", " (in 'prophet.stan', line 123, column 9 to line 125, column 3)", " (in 'prophet.stan', line 122, column 4 to column 64)", " (in 'prophet.stan', line 121, column 35 to line 123, column 3)", " (in 'prophet.stan', line 121, column 9 to line 125, column 3)", " (in 'prophet.stan', line 120, column 4 to column 54)", " (in 'prophet.stan', line 119, column 28 to line 121, column 3)", " (in 'prophet.stan', line 119, column 2 to line 125, column 3)", " (in 'prophet.stan', line 130, column 2 to column 19)", " (in 'prophet.stan', line 131, column 2 to column 19)", " (in 'prophet.stan', line 132, column 2 to column 37)", " (in 'prophet.stan', line 133, column 2 to column 29)", " (in 'prophet.stan', line 134, column 2 to column 27)", " (in 'prophet.stan', line 137, column 2 to line 142, column 4)", " (in 'prophet.stan', line 88, column 2 to column 8)", " (in 'prophet.stan', line 89, column 2 to column 17)", " (in 'prophet.stan', line 90, column 9 to column 10)", " (in 'prophet.stan', line 90, column 2 to column 14)", " (in 'prophet.stan', line 91, column 9 to column 10)", " (in 'prophet.stan', line 91, column 2 to column 16)", " (in 'prophet.stan', line 92, column 9 to column 10)", " (in 'prophet.stan', line 92, column 2 to column 14)", " (in 'prophet.stan', line 93, column 2 to column 8)", " (in 'prophet.stan', line 94, column 9 to column 10)", " (in 'prophet.stan', line 94, column 2 to column 21)", " (in 'prophet.stan', line 95, column 9 to column 10)", " (in 'prophet.stan', line 95, column 11 to column 12)", " (in 'prophet.stan', line 95, column 2 to column 16)", " (in 'prophet.stan', line 96, column 9 to column 10)", " (in 'prophet.stan', line 96, column 2 to column 19)", " (in 'prophet.stan', line 97, column 2 to column 20)", " (in 'prophet.stan', line 98, column 2 to column 22)", " (in 'prophet.stan', line 99, column 9 to column 10)", " (in 'prophet.stan', line 99, column 2 to column 16)", " (in 'prophet.stan', line 100, column 9 to column 10)", " (in 'prophet.stan', line 100, column 2 to column 16)", " (in 'prophet.stan', line 104, column 9 to column 10)", " (in 'prophet.stan', line 104, column 12 to column 13)", " (in 'prophet.stan', line 104, column 2 to column 61)", " (in 'prophet.stan', line 105, column 9 to column 10)", " (in 'prophet.stan', line 105, column 12 to column 13)", " (in 'prophet.stan', line 105, column 2 to column 47)", " (in 'prophet.stan', line 106, column 9 to column 10)", " (in 'prophet.stan', line 106, column 12 to column 13)", " (in 'prophet.stan', line 106, column 2 to column 47)", " (in 'prophet.stan', line 112, column 9 to column 10)", " (in 'prophet.stan', line 114, column 9 to column 10)", " (in 'prophet.stan', line 118, column 9 to column 10)", " (in 'prophet.stan', line 9, column 11 to column 12)", " (in 'prophet.stan', line 9, column 14 to column 15)", " (in 'prophet.stan', line 9, column 4 to column 19)", " (in 'prophet.stan', line 10, column 15 to column 16)", " (in 'prophet.stan', line 10, column 4 to column 24)", " (in 'prophet.stan', line 11, column 4 to column 15)", " (in 'prophet.stan', line 14, column 4 to column 28)", " (in 'prophet.stan', line 15, column 4 to column 33)", " (in 'prophet.stan', line 16, column 4 to column 15)", " (in 'prophet.stan', line 21, column 8 to column 26)", " (in 'prophet.stan', line 22, column 8 to column 28)", " (in 'prophet.stan', line 20, column 58 to line 23, column 7)", " (in 'prophet.stan', line 20, column 6 to line 23, column 7)", " (in 'prophet.stan', line 24, column 6 to column 19)", " (in 'prophet.stan', line 19, column 19 to line 25, column 5)", " (in 'prophet.stan', line 19, column 4 to line 25, column 5)", " (in 'prophet.stan', line 26, column 4 to column 13)", " (in 'prophet.stan', line 7, column 73 to line 27, column 3)", " (in 'prophet.stan', line 32, column 11 to column 12)", " (in 'prophet.stan', line 32, column 4 to column 20)", " (in 'prophet.stan', line 33, column 11 to column 16)", " (in 'prophet.stan', line 33, column 4 to column 22)", " (in 'prophet.stan', line 34, column 4 to column 14)", " (in 'prophet.stan', line 37, column 4 to column 51)", " (in 'prophet.stan', line 40, column 4 to column 13)", " (in 'prophet.stan', line 42, column 6 to column 66)", " (in 'prophet.stan', line 43, column 6 to column 29)", " (in 'prophet.stan', line 41, column 19 to line 44, column 5)", " (in 'prophet.stan', line 41, column 4 to line 44, column 5)", " (in 'prophet.stan', line 45, column 4 to column 17)", " (in 'prophet.stan', line 31, column 78 to line 46, column 3)", " (in 'prophet.stan', line 58, column 11 to column 12)", " (in 'prophet.stan', line 58, column 4 to column 20)", " (in 'prophet.stan', line 60, column 4 to column 53)", " (in 'prophet.stan', line 61, column 4 to column 70)", " (in 'prophet.stan', line 57, column 4 to line 62, column 3)", " (in 'prophet.stan', line 74, column 4 to column 65)", " (in 'prophet.stan', line 73, column 4 to line 75, column 3)", " (in 'prophet.stan', line 83, column 4 to column 28)", " (in 'prophet.stan', line 82, column 4 to line 84, column 3)"}; template , stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral, std::is_integral>* = nullptr> Eigen::Matrix, stan::base_type_t>,-1,-1> get_changepoint_matrix(const T0__& t_arg__, const T1__& t_change_arg__, const T2__& T, const T3__& S, std::ostream* pstream__); template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral>* = nullptr> Eigen::Matrix, stan::base_type_t>,-1,1> logistic_gamma(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_change_arg__, const T4__& S, std::ostream* pstream__); template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_eigen_matrix_dynamic, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral>* = nullptr> Eigen::Matrix, stan::base_type_t, stan::base_type_t, stan::promote_args_t, stan::base_type_t>>,-1,1> logistic_trend(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_arg__, const T4__& cap_arg__, const T5__& A_arg__, const T6__& t_change_arg__, const T7__& S, std::ostream* pstream__); template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_eigen_matrix_dynamic, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex>* = nullptr> Eigen::Matrix, stan::base_type_t, stan::base_type_t, stan::promote_args_t>>,-1,1> linear_trend(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_arg__, const T4__& A_arg__, const T5__& t_change_arg__, std::ostream* pstream__); template , std::is_floating_point>, std::is_integral>* = nullptr> Eigen::Matrix,-1,1> flat_trend(const T0__& m, const T1__& T, std::ostream* pstream__); // matrix get_changepoint_matrix(vector, vector, int, int) template , stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral, std::is_integral>*> Eigen::Matrix, stan::base_type_t>,-1,-1> get_changepoint_matrix(const T0__& t_arg__, const T1__& t_change_arg__, const T2__& T, const T3__& S, std::ostream* pstream__) { using local_scalar_t__ = stan::promote_args_t, stan::base_type_t>; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; const auto& t = stan::math::to_ref(t_arg__); const auto& t_change = stan::math::to_ref(t_change_arg__); static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 56; stan::math::validate_non_negative_index("A", "T", T); current_statement__ = 57; stan::math::validate_non_negative_index("A", "S", S); Eigen::Matrix A = Eigen::Matrix::Constant(T, S, DUMMY_VAR__); current_statement__ = 59; stan::math::validate_non_negative_index("a_row", "S", S); Eigen::Matrix a_row = Eigen::Matrix::Constant(S, DUMMY_VAR__); int cp_idx = std::numeric_limits::min(); current_statement__ = 62; stan::model::assign(A, stan::math::rep_matrix(0, T, S), "assigning variable A"); current_statement__ = 63; stan::model::assign(a_row, stan::math::rep_row_vector(0, S), "assigning variable a_row"); current_statement__ = 64; cp_idx = 1; current_statement__ = 71; for (int i = 1; i <= T; ++i) { current_statement__ = 68; while ((stan::math::primitive_value(stan::math::logical_lte(cp_idx, S)) && stan::math::primitive_value( stan::math::logical_gte( stan::model::rvalue(t, "t", stan::model::index_uni(i)), stan::model::rvalue(t_change, "t_change", stan::model::index_uni(cp_idx)))))) { current_statement__ = 65; stan::model::assign(a_row, 1, "assigning variable a_row", stan::model::index_uni(cp_idx)); current_statement__ = 66; cp_idx = (cp_idx + 1); } current_statement__ = 69; stan::model::assign(A, a_row, "assigning variable A", stan::model::index_uni(i)); } current_statement__ = 72; return A; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } // vector logistic_gamma(real, real, vector, vector, int) template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral>*> Eigen::Matrix, stan::base_type_t>,-1,1> logistic_gamma(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_change_arg__, const T4__& S, std::ostream* pstream__) { using local_scalar_t__ = stan::promote_args_t, stan::base_type_t>; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; const auto& delta = stan::math::to_ref(delta_arg__); const auto& t_change = stan::math::to_ref(t_change_arg__); static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 74; stan::math::validate_non_negative_index("gamma", "S", S); Eigen::Matrix gamma = Eigen::Matrix::Constant(S, DUMMY_VAR__); current_statement__ = 76; stan::math::validate_non_negative_index("k_s", "S + 1", (S + 1)); Eigen::Matrix k_s = Eigen::Matrix::Constant((S + 1), DUMMY_VAR__); local_scalar_t__ m_pr = DUMMY_VAR__; current_statement__ = 79; stan::model::assign(k_s, stan::math::append_row(k, stan::math::add(k, stan::math::cumulative_sum(delta))), "assigning variable k_s"); current_statement__ = 80; m_pr = m; current_statement__ = 84; for (int i = 1; i <= S; ++i) { current_statement__ = 81; stan::model::assign(gamma, ((stan::model::rvalue(t_change, "t_change", stan::model::index_uni(i)) - m_pr) * (1 - (stan::model::rvalue(k_s, "k_s", stan::model::index_uni(i)) / stan::model::rvalue(k_s, "k_s", stan::model::index_uni((i + 1)))))), "assigning variable gamma", stan::model::index_uni(i)); current_statement__ = 82; m_pr = (m_pr + stan::model::rvalue(gamma, "gamma", stan::model::index_uni(i))); } current_statement__ = 85; return gamma; } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } /* vector logistic_trend(real, real, vector, vector, vector, matrix, vector, int) */ template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_eigen_matrix_dynamic, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, std::is_integral>*> Eigen::Matrix, stan::base_type_t, stan::base_type_t, stan::promote_args_t, stan::base_type_t>>,-1,1> logistic_trend(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_arg__, const T4__& cap_arg__, const T5__& A_arg__, const T6__& t_change_arg__, const T7__& S, std::ostream* pstream__) { using local_scalar_t__ = stan::promote_args_t, stan::base_type_t, stan::base_type_t, stan::promote_args_t, stan::base_type_t>>; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; const auto& delta = stan::math::to_ref(delta_arg__); const auto& t = stan::math::to_ref(t_arg__); const auto& cap = stan::math::to_ref(cap_arg__); const auto& A = stan::math::to_ref(A_arg__); const auto& t_change = stan::math::to_ref(t_change_arg__); static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 87; stan::math::validate_non_negative_index("gamma", "S", S); Eigen::Matrix gamma = Eigen::Matrix::Constant(S, DUMMY_VAR__); current_statement__ = 89; stan::model::assign(gamma, logistic_gamma(k, m, delta, t_change, S, pstream__), "assigning variable gamma"); current_statement__ = 90; return stan::math::elt_multiply(cap, stan::math::inv_logit( stan::math::elt_multiply( stan::math::add(k, stan::math::multiply(A, delta)), stan::math::subtract(t, stan::math::add(m, stan::math::multiply(A, gamma)))))); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } // vector linear_trend(real, real, vector, vector, matrix, vector) template , std::is_floating_point>, stan::math::disjunction, std::is_floating_point>, stan::is_col_vector, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex, stan::is_eigen_matrix_dynamic, stan::is_vt_not_complex, stan::is_col_vector, stan::is_vt_not_complex>*> Eigen::Matrix, stan::base_type_t, stan::base_type_t, stan::promote_args_t>>,-1,1> linear_trend(const T0__& k, const T1__& m, const T2__& delta_arg__, const T3__& t_arg__, const T4__& A_arg__, const T5__& t_change_arg__, std::ostream* pstream__) { using local_scalar_t__ = stan::promote_args_t, stan::base_type_t, stan::base_type_t, stan::promote_args_t>>; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; const auto& delta = stan::math::to_ref(delta_arg__); const auto& t = stan::math::to_ref(t_arg__); const auto& A = stan::math::to_ref(A_arg__); const auto& t_change = stan::math::to_ref(t_change_arg__); static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 92; return stan::math::add( stan::math::elt_multiply( stan::math::add(k, stan::math::multiply(A, delta)), t), stan::math::add(m, stan::math::multiply(A, stan::math::elt_multiply(stan::math::minus(t_change), delta)))); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } // vector flat_trend(real, int) template , std::is_floating_point>, std::is_integral>*> Eigen::Matrix,-1,1> flat_trend(const T0__& m, const T1__& T, std::ostream* pstream__) { using local_scalar_t__ = stan::promote_args_t; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 94; return stan::math::rep_vector(m, T); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } class prophet_model final : public model_base_crtp { private: int T; int K; Eigen::Matrix t_data__; Eigen::Matrix cap_data__; Eigen::Matrix y_data__; int S; Eigen::Matrix t_change_data__; Eigen::Matrix X_data__; Eigen::Matrix sigmas_data__; double tau; int trend_indicator; Eigen::Matrix s_a_data__; Eigen::Matrix s_m_data__; Eigen::Matrix A_data__; Eigen::Matrix X_sa_data__; Eigen::Matrix X_sm_data__; Eigen::Map> t{nullptr, 0}; Eigen::Map> cap{nullptr, 0}; Eigen::Map> y{nullptr, 0}; Eigen::Map> t_change{nullptr, 0}; Eigen::Map> X{nullptr, 0, 0}; Eigen::Map> sigmas{nullptr, 0}; Eigen::Map> s_a{nullptr, 0}; Eigen::Map> s_m{nullptr, 0}; Eigen::Map> A{nullptr, 0, 0}; Eigen::Map> X_sa{nullptr, 0, 0}; Eigen::Map> X_sm{nullptr, 0, 0}; public: ~prophet_model() {} prophet_model(stan::io::var_context& context__, unsigned int random_seed__ = 0, std::ostream* pstream__ = nullptr) : model_base_crtp(0) { int current_statement__ = 0; // suppress unused var warning (void) current_statement__; using local_scalar_t__ = double; boost::ecuyer1988 base_rng__ = stan::services::util::create_rng(random_seed__, 0); // suppress unused var warning (void) base_rng__; static constexpr const char* function__ = "prophet_model_namespace::prophet_model"; // suppress unused var warning (void) function__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { int pos__ = std::numeric_limits::min(); pos__ = 1; current_statement__ = 22; context__.validate_dims("data initialization", "T", "int", std::vector{}); T = std::numeric_limits::min(); current_statement__ = 22; T = context__.vals_i("T")[(1 - 1)]; current_statement__ = 23; context__.validate_dims("data initialization", "K", "int", std::vector{}); K = std::numeric_limits::min(); current_statement__ = 23; K = context__.vals_i("K")[(1 - 1)]; current_statement__ = 23; stan::math::check_greater_or_equal(function__, "K", K, 1); current_statement__ = 24; stan::math::validate_non_negative_index("t", "T", T); current_statement__ = 25; context__.validate_dims("data initialization", "t", "double", std::vector{static_cast(T)}); t_data__ = Eigen::Matrix::Constant(T, std::numeric_limits::quiet_NaN()); new (&t) Eigen::Map>(t_data__.data(), T); { std::vector t_flat__; current_statement__ = 25; t_flat__ = context__.vals_r("t"); pos__ = 1; for (int sym1__ = 1; sym1__ <= T; ++sym1__) { stan::model::assign(t, t_flat__[(pos__ - 1)], "assigning variable t", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 26; stan::math::validate_non_negative_index("cap", "T", T); current_statement__ = 27; context__.validate_dims("data initialization", "cap", "double", std::vector{static_cast(T)}); cap_data__ = Eigen::Matrix::Constant(T, std::numeric_limits::quiet_NaN()); new (&cap) Eigen::Map>(cap_data__.data(), T); { std::vector cap_flat__; current_statement__ = 27; cap_flat__ = context__.vals_r("cap"); pos__ = 1; for (int sym1__ = 1; sym1__ <= T; ++sym1__) { stan::model::assign(cap, cap_flat__[(pos__ - 1)], "assigning variable cap", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 28; stan::math::validate_non_negative_index("y", "T", T); current_statement__ = 29; context__.validate_dims("data initialization", "y", "double", std::vector{static_cast(T)}); y_data__ = Eigen::Matrix::Constant(T, std::numeric_limits::quiet_NaN()); new (&y) Eigen::Map>(y_data__.data(), T); { std::vector y_flat__; current_statement__ = 29; y_flat__ = context__.vals_r("y"); pos__ = 1; for (int sym1__ = 1; sym1__ <= T; ++sym1__) { stan::model::assign(y, y_flat__[(pos__ - 1)], "assigning variable y", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 30; context__.validate_dims("data initialization", "S", "int", std::vector{}); S = std::numeric_limits::min(); current_statement__ = 30; S = context__.vals_i("S")[(1 - 1)]; current_statement__ = 31; stan::math::validate_non_negative_index("t_change", "S", S); current_statement__ = 32; context__.validate_dims("data initialization", "t_change", "double", std::vector{static_cast(S)}); t_change_data__ = Eigen::Matrix::Constant(S, std::numeric_limits::quiet_NaN()); new (&t_change) Eigen::Map>(t_change_data__.data(), S); { std::vector t_change_flat__; current_statement__ = 32; t_change_flat__ = context__.vals_r("t_change"); pos__ = 1; for (int sym1__ = 1; sym1__ <= S; ++sym1__) { stan::model::assign(t_change, t_change_flat__[(pos__ - 1)], "assigning variable t_change", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 33; stan::math::validate_non_negative_index("X", "T", T); current_statement__ = 34; stan::math::validate_non_negative_index("X", "K", K); current_statement__ = 35; context__.validate_dims("data initialization", "X", "double", std::vector{static_cast(T), static_cast(K)}); X_data__ = Eigen::Matrix::Constant(T, K, std::numeric_limits::quiet_NaN()); new (&X) Eigen::Map>(X_data__.data(), T, K); { std::vector X_flat__; current_statement__ = 35; X_flat__ = context__.vals_r("X"); pos__ = 1; for (int sym1__ = 1; sym1__ <= K; ++sym1__) { for (int sym2__ = 1; sym2__ <= T; ++sym2__) { stan::model::assign(X, X_flat__[(pos__ - 1)], "assigning variable X", stan::model::index_uni(sym2__), stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } } current_statement__ = 36; stan::math::validate_non_negative_index("sigmas", "K", K); current_statement__ = 37; context__.validate_dims("data initialization", "sigmas", "double", std::vector{static_cast(K)}); sigmas_data__ = Eigen::Matrix::Constant(K, std::numeric_limits::quiet_NaN()); new (&sigmas) Eigen::Map>(sigmas_data__.data(), K); { std::vector sigmas_flat__; current_statement__ = 37; sigmas_flat__ = context__.vals_r("sigmas"); pos__ = 1; for (int sym1__ = 1; sym1__ <= K; ++sym1__) { stan::model::assign(sigmas, sigmas_flat__[(pos__ - 1)], "assigning variable sigmas", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 38; context__.validate_dims("data initialization", "tau", "double", std::vector{}); tau = std::numeric_limits::quiet_NaN(); current_statement__ = 38; tau = context__.vals_r("tau")[(1 - 1)]; current_statement__ = 38; stan::math::check_greater_or_equal(function__, "tau", tau, 0); current_statement__ = 39; context__.validate_dims("data initialization", "trend_indicator", "int", std::vector{}); trend_indicator = std::numeric_limits::min(); current_statement__ = 39; trend_indicator = context__.vals_i("trend_indicator")[(1 - 1)]; current_statement__ = 40; stan::math::validate_non_negative_index("s_a", "K", K); current_statement__ = 41; context__.validate_dims("data initialization", "s_a", "double", std::vector{static_cast(K)}); s_a_data__ = Eigen::Matrix::Constant(K, std::numeric_limits::quiet_NaN()); new (&s_a) Eigen::Map>(s_a_data__.data(), K); { std::vector s_a_flat__; current_statement__ = 41; s_a_flat__ = context__.vals_r("s_a"); pos__ = 1; for (int sym1__ = 1; sym1__ <= K; ++sym1__) { stan::model::assign(s_a, s_a_flat__[(pos__ - 1)], "assigning variable s_a", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 42; stan::math::validate_non_negative_index("s_m", "K", K); current_statement__ = 43; context__.validate_dims("data initialization", "s_m", "double", std::vector{static_cast(K)}); s_m_data__ = Eigen::Matrix::Constant(K, std::numeric_limits::quiet_NaN()); new (&s_m) Eigen::Map>(s_m_data__.data(), K); { std::vector s_m_flat__; current_statement__ = 43; s_m_flat__ = context__.vals_r("s_m"); pos__ = 1; for (int sym1__ = 1; sym1__ <= K; ++sym1__) { stan::model::assign(s_m, s_m_flat__[(pos__ - 1)], "assigning variable s_m", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } current_statement__ = 44; stan::math::validate_non_negative_index("A", "T", T); current_statement__ = 45; stan::math::validate_non_negative_index("A", "S", S); current_statement__ = 46; A_data__ = Eigen::Matrix::Constant(T, S, std::numeric_limits::quiet_NaN()); new (&A) Eigen::Map>(A_data__.data(), T, S); current_statement__ = 46; stan::model::assign(A, get_changepoint_matrix(t, t_change, T, S, pstream__), "assigning variable A"); current_statement__ = 47; stan::math::validate_non_negative_index("X_sa", "T", T); current_statement__ = 48; stan::math::validate_non_negative_index("X_sa", "K", K); current_statement__ = 49; X_sa_data__ = Eigen::Matrix::Constant(T, K, std::numeric_limits::quiet_NaN()); new (&X_sa) Eigen::Map>(X_sa_data__.data(), T, K); current_statement__ = 49; stan::model::assign(X_sa, stan::math::elt_multiply(X, stan::math::rep_matrix(stan::math::transpose(s_a), T)), "assigning variable X_sa"); current_statement__ = 50; stan::math::validate_non_negative_index("X_sm", "T", T); current_statement__ = 51; stan::math::validate_non_negative_index("X_sm", "K", K); current_statement__ = 52; X_sm_data__ = Eigen::Matrix::Constant(T, K, std::numeric_limits::quiet_NaN()); new (&X_sm) Eigen::Map>(X_sm_data__.data(), T, K); current_statement__ = 52; stan::model::assign(X_sm, stan::math::elt_multiply(X, stan::math::rep_matrix(stan::math::transpose(s_m), T)), "assigning variable X_sm"); current_statement__ = 53; stan::math::validate_non_negative_index("delta", "S", S); current_statement__ = 54; stan::math::validate_non_negative_index("beta", "K", K); current_statement__ = 55; stan::math::validate_non_negative_index("trend", "T", T); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } num_params_r__ = 1 + 1 + S + 1 + K; } inline std::string model_name() const final { return "prophet_model"; } inline std::vector model_compile_info() const noexcept { return std::vector{"stanc_version = stanc3 v2.33.1", "stancflags = --filename-in-msg=prophet.stan"}; } // Base log prob template * = nullptr, stan::require_vector_like_vt* = nullptr, stan::require_not_st_var* = nullptr> inline stan::scalar_type_t log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream* pstream__ = nullptr) const { using T__ = stan::scalar_type_t; using local_scalar_t__ = T__; T__ lp__(0.0); stan::math::accumulator lp_accum__; stan::io::deserializer in__(params_r__, params_i__); int current_statement__ = 0; // suppress unused var warning (void) current_statement__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; static constexpr const char* function__ = "prophet_model_namespace::log_prob"; // suppress unused var warning (void) function__; try { local_scalar_t__ k = DUMMY_VAR__; current_statement__ = 1; k = in__.template read(); local_scalar_t__ m = DUMMY_VAR__; current_statement__ = 2; m = in__.template read(); Eigen::Matrix delta = Eigen::Matrix::Constant(S, DUMMY_VAR__); current_statement__ = 3; delta = in__.template read>(S); local_scalar_t__ sigma_obs = DUMMY_VAR__; current_statement__ = 4; sigma_obs = in__.template read_constrain_lb(0, lp__); Eigen::Matrix beta = Eigen::Matrix::Constant(K, DUMMY_VAR__); current_statement__ = 5; beta = in__.template read>(K); Eigen::Matrix trend = Eigen::Matrix::Constant(T, DUMMY_VAR__); current_statement__ = 15; if (stan::math::logical_eq(trend_indicator, 0)) { current_statement__ = 13; stan::model::assign(trend, linear_trend(k, m, delta, t, A, t_change, pstream__), "assigning variable trend"); } else { current_statement__ = 12; if (stan::math::logical_eq(trend_indicator, 1)) { current_statement__ = 10; stan::model::assign(trend, logistic_trend(k, m, delta, t, cap, A, t_change, S, pstream__), "assigning variable trend"); } else { current_statement__ = 9; if (stan::math::logical_eq(trend_indicator, 2)) { current_statement__ = 7; stan::model::assign(trend, flat_trend(m, T, pstream__), "assigning variable trend"); } } } { current_statement__ = 16; lp_accum__.add(stan::math::normal_lpdf(k, 0, 5)); current_statement__ = 17; lp_accum__.add(stan::math::normal_lpdf(m, 0, 5)); current_statement__ = 18; lp_accum__.add(stan::math::double_exponential_lpdf(delta, 0, tau)); current_statement__ = 19; lp_accum__.add(stan::math::normal_lpdf(sigma_obs, 0, 0.5)); current_statement__ = 20; lp_accum__.add(stan::math::normal_lpdf(beta, 0, sigmas)); current_statement__ = 21; lp_accum__.add(stan::math::normal_id_glm_lpdf(y, X_sa, stan::math::elt_multiply(trend, stan::math::add(1, stan::math::multiply(X_sm, beta))), beta, sigma_obs)); } } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } lp_accum__.add(lp__); return lp_accum__.sum(); } // Reverse mode autodiff log prob template * = nullptr, stan::require_vector_like_vt* = nullptr, stan::require_st_var* = nullptr> inline stan::scalar_type_t log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream* pstream__ = nullptr) const { using T__ = stan::scalar_type_t; using local_scalar_t__ = T__; T__ lp__(0.0); stan::math::accumulator lp_accum__; stan::io::deserializer in__(params_r__, params_i__); int current_statement__ = 0; // suppress unused var warning (void) current_statement__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; static constexpr const char* function__ = "prophet_model_namespace::log_prob"; // suppress unused var warning (void) function__; try { local_scalar_t__ k = DUMMY_VAR__; current_statement__ = 1; k = in__.template read(); local_scalar_t__ m = DUMMY_VAR__; current_statement__ = 2; m = in__.template read(); Eigen::Matrix delta = Eigen::Matrix::Constant(S, DUMMY_VAR__); current_statement__ = 3; delta = in__.template read>(S); local_scalar_t__ sigma_obs = DUMMY_VAR__; current_statement__ = 4; sigma_obs = in__.template read_constrain_lb(0, lp__); Eigen::Matrix beta = Eigen::Matrix::Constant(K, DUMMY_VAR__); current_statement__ = 5; beta = in__.template read>(K); Eigen::Matrix trend = Eigen::Matrix::Constant(T, DUMMY_VAR__); current_statement__ = 15; if (stan::math::logical_eq(trend_indicator, 0)) { current_statement__ = 13; stan::model::assign(trend, linear_trend(k, m, delta, t, A, t_change, pstream__), "assigning variable trend"); } else { current_statement__ = 12; if (stan::math::logical_eq(trend_indicator, 1)) { current_statement__ = 10; stan::model::assign(trend, logistic_trend(k, m, delta, t, cap, A, t_change, S, pstream__), "assigning variable trend"); } else { current_statement__ = 9; if (stan::math::logical_eq(trend_indicator, 2)) { current_statement__ = 7; stan::model::assign(trend, flat_trend(m, T, pstream__), "assigning variable trend"); } } } { current_statement__ = 16; lp_accum__.add(stan::math::normal_lpdf(k, 0, 5)); current_statement__ = 17; lp_accum__.add(stan::math::normal_lpdf(m, 0, 5)); current_statement__ = 18; lp_accum__.add(stan::math::double_exponential_lpdf(delta, 0, tau)); current_statement__ = 19; lp_accum__.add(stan::math::normal_lpdf(sigma_obs, 0, 0.5)); current_statement__ = 20; lp_accum__.add(stan::math::normal_lpdf(beta, 0, sigmas)); current_statement__ = 21; lp_accum__.add(stan::math::normal_id_glm_lpdf(y, X_sa, stan::math::elt_multiply(trend, stan::math::add(1, stan::math::multiply(X_sm, beta))), beta, sigma_obs)); } } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } lp_accum__.add(lp__); return lp_accum__.sum(); } template * = nullptr, stan::require_vector_like_vt* = nullptr, stan::require_vector_vt* = nullptr> inline void write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__, VecVar& vars__, const bool emit_transformed_parameters__ = true, const bool emit_generated_quantities__ = true, std::ostream* pstream__ = nullptr) const { using local_scalar_t__ = double; stan::io::deserializer in__(params_r__, params_i__); stan::io::serializer out__(vars__); static constexpr bool propto__ = true; // suppress unused var warning (void) propto__; double lp__ = 0.0; // suppress unused var warning (void) lp__; int current_statement__ = 0; // suppress unused var warning (void) current_statement__; stan::math::accumulator lp_accum__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; constexpr bool jacobian__ = false; // suppress unused var warning (void) jacobian__; static constexpr const char* function__ = "prophet_model_namespace::write_array"; // suppress unused var warning (void) function__; try { double k = std::numeric_limits::quiet_NaN(); current_statement__ = 1; k = in__.template read(); double m = std::numeric_limits::quiet_NaN(); current_statement__ = 2; m = in__.template read(); Eigen::Matrix delta = Eigen::Matrix::Constant(S, std::numeric_limits::quiet_NaN()); current_statement__ = 3; delta = in__.template read>(S); double sigma_obs = std::numeric_limits::quiet_NaN(); current_statement__ = 4; sigma_obs = in__.template read_constrain_lb(0, lp__); Eigen::Matrix beta = Eigen::Matrix::Constant(K, std::numeric_limits::quiet_NaN()); current_statement__ = 5; beta = in__.template read>(K); Eigen::Matrix trend = Eigen::Matrix::Constant(T, std::numeric_limits::quiet_NaN()); out__.write(k); out__.write(m); out__.write(delta); out__.write(sigma_obs); out__.write(beta); if (stan::math::logical_negation( (stan::math::primitive_value(emit_transformed_parameters__) || stan::math::primitive_value(emit_generated_quantities__)))) { return ; } current_statement__ = 15; if (stan::math::logical_eq(trend_indicator, 0)) { current_statement__ = 13; stan::model::assign(trend, linear_trend(k, m, delta, t, A, t_change, pstream__), "assigning variable trend"); } else { current_statement__ = 12; if (stan::math::logical_eq(trend_indicator, 1)) { current_statement__ = 10; stan::model::assign(trend, logistic_trend(k, m, delta, t, cap, A, t_change, S, pstream__), "assigning variable trend"); } else { current_statement__ = 9; if (stan::math::logical_eq(trend_indicator, 2)) { current_statement__ = 7; stan::model::assign(trend, flat_trend(m, T, pstream__), "assigning variable trend"); } } } if (emit_transformed_parameters__) { out__.write(trend); } if (stan::math::logical_negation(emit_generated_quantities__)) { return ; } } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } template * = nullptr, stan::require_vector_like_vt* = nullptr> inline void unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__, VecVar& vars__, std::ostream* pstream__ = nullptr) const { using local_scalar_t__ = double; stan::io::deserializer in__(params_r__, params_i__); stan::io::serializer out__(vars__); int current_statement__ = 0; // suppress unused var warning (void) current_statement__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { local_scalar_t__ k = DUMMY_VAR__; current_statement__ = 1; k = in__.read(); out__.write(k); local_scalar_t__ m = DUMMY_VAR__; current_statement__ = 2; m = in__.read(); out__.write(m); Eigen::Matrix delta = Eigen::Matrix::Constant(S, DUMMY_VAR__); current_statement__ = 3; stan::model::assign(delta, in__.read>(S), "assigning variable delta"); out__.write(delta); local_scalar_t__ sigma_obs = DUMMY_VAR__; current_statement__ = 4; sigma_obs = in__.read(); out__.write_free_lb(0, sigma_obs); Eigen::Matrix beta = Eigen::Matrix::Constant(K, DUMMY_VAR__); current_statement__ = 5; stan::model::assign(beta, in__.read>(K), "assigning variable beta"); out__.write(beta); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } template * = nullptr> inline void transform_inits_impl(const stan::io::var_context& context__, VecVar& vars__, std::ostream* pstream__ = nullptr) const { using local_scalar_t__ = double; stan::io::serializer out__(vars__); int current_statement__ = 0; // suppress unused var warning (void) current_statement__; local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN()); // suppress unused var warning (void) DUMMY_VAR__; try { current_statement__ = 1; context__.validate_dims("parameter initialization", "k", "double", std::vector{}); current_statement__ = 2; context__.validate_dims("parameter initialization", "m", "double", std::vector{}); current_statement__ = 3; context__.validate_dims("parameter initialization", "delta", "double", std::vector{static_cast(S)}); current_statement__ = 4; context__.validate_dims("parameter initialization", "sigma_obs", "double", std::vector{}); current_statement__ = 5; context__.validate_dims("parameter initialization", "beta", "double", std::vector{static_cast(K)}); int pos__ = std::numeric_limits::min(); pos__ = 1; local_scalar_t__ k = DUMMY_VAR__; current_statement__ = 1; k = context__.vals_r("k")[(1 - 1)]; out__.write(k); local_scalar_t__ m = DUMMY_VAR__; current_statement__ = 2; m = context__.vals_r("m")[(1 - 1)]; out__.write(m); Eigen::Matrix delta = Eigen::Matrix::Constant(S, DUMMY_VAR__); { std::vector delta_flat__; current_statement__ = 3; delta_flat__ = context__.vals_r("delta"); pos__ = 1; for (int sym1__ = 1; sym1__ <= S; ++sym1__) { stan::model::assign(delta, delta_flat__[(pos__ - 1)], "assigning variable delta", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } out__.write(delta); local_scalar_t__ sigma_obs = DUMMY_VAR__; current_statement__ = 4; sigma_obs = context__.vals_r("sigma_obs")[(1 - 1)]; out__.write_free_lb(0, sigma_obs); Eigen::Matrix beta = Eigen::Matrix::Constant(K, DUMMY_VAR__); { std::vector beta_flat__; current_statement__ = 5; beta_flat__ = context__.vals_r("beta"); pos__ = 1; for (int sym1__ = 1; sym1__ <= K; ++sym1__) { stan::model::assign(beta, beta_flat__[(pos__ - 1)], "assigning variable beta", stan::model::index_uni(sym1__)); pos__ = (pos__ + 1); } } out__.write(beta); } catch (const std::exception& e) { stan::lang::rethrow_located(e, locations_array__[current_statement__]); } } inline void get_param_names(std::vector& names__, const bool emit_transformed_parameters__ = true, const bool emit_generated_quantities__ = true) const { names__ = std::vector{"k", "m", "delta", "sigma_obs", "beta"}; if (emit_transformed_parameters__) { std::vector temp{"trend"}; names__.reserve(names__.size() + temp.size()); names__.insert(names__.end(), temp.begin(), temp.end()); } if (emit_generated_quantities__) {} } inline void get_dims(std::vector>& dimss__, const bool emit_transformed_parameters__ = true, const bool emit_generated_quantities__ = true) const { dimss__ = std::vector>{std::vector{}, std::vector{}, std::vector{static_cast(S)}, std::vector{}, std::vector{static_cast(K)}}; if (emit_transformed_parameters__) { std::vector> temp{std::vector{static_cast(T)}}; dimss__.reserve(dimss__.size() + temp.size()); dimss__.insert(dimss__.end(), temp.begin(), temp.end()); } if (emit_generated_quantities__) {} } inline void constrained_param_names(std::vector& param_names__, bool emit_transformed_parameters__ = true, bool emit_generated_quantities__ = true) const final { param_names__.emplace_back(std::string() + "k"); param_names__.emplace_back(std::string() + "m"); for (int sym1__ = 1; sym1__ <= S; ++sym1__) { param_names__.emplace_back(std::string() + "delta" + '.' + std::to_string(sym1__)); } param_names__.emplace_back(std::string() + "sigma_obs"); for (int sym1__ = 1; sym1__ <= K; ++sym1__) { param_names__.emplace_back(std::string() + "beta" + '.' + std::to_string(sym1__)); } if (emit_transformed_parameters__) { for (int sym1__ = 1; sym1__ <= T; ++sym1__) { param_names__.emplace_back(std::string() + "trend" + '.' + std::to_string(sym1__)); } } if (emit_generated_quantities__) {} } inline void unconstrained_param_names(std::vector& param_names__, bool emit_transformed_parameters__ = true, bool emit_generated_quantities__ = true) const final { param_names__.emplace_back(std::string() + "k"); param_names__.emplace_back(std::string() + "m"); for (int sym1__ = 1; sym1__ <= S; ++sym1__) { param_names__.emplace_back(std::string() + "delta" + '.' + std::to_string(sym1__)); } param_names__.emplace_back(std::string() + "sigma_obs"); for (int sym1__ = 1; sym1__ <= K; ++sym1__) { param_names__.emplace_back(std::string() + "beta" + '.' + std::to_string(sym1__)); } if (emit_transformed_parameters__) { for (int sym1__ = 1; sym1__ <= T; ++sym1__) { param_names__.emplace_back(std::string() + "trend" + '.' + std::to_string(sym1__)); } } if (emit_generated_quantities__) {} } inline std::string get_constrained_sizedtypes() const { return std::string("[{\"name\":\"k\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"m\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(S) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(T) + "},\"block\":\"transformed_parameters\"}]"); } inline std::string get_unconstrained_sizedtypes() const { return std::string("[{\"name\":\"k\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"m\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"delta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(S) + "},\"block\":\"parameters\"},{\"name\":\"sigma_obs\",\"type\":{\"name\":\"real\"},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(K) + "},\"block\":\"parameters\"},{\"name\":\"trend\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(T) + "},\"block\":\"transformed_parameters\"}]"); } // Begin method overload boilerplate template inline void write_array(RNG& base_rng, Eigen::Matrix& params_r, Eigen::Matrix& vars, const bool emit_transformed_parameters = true, const bool emit_generated_quantities = true, std::ostream* pstream = nullptr) const { const size_t num_params__ = ((((1 + 1) + S) + 1) + K); const size_t num_transformed = emit_transformed_parameters * (T); const size_t num_gen_quantities = emit_generated_quantities * (0); const size_t num_to_write = num_params__ + num_transformed + num_gen_quantities; std::vector params_i; vars = Eigen::Matrix::Constant(num_to_write, std::numeric_limits::quiet_NaN()); write_array_impl(base_rng, params_r, params_i, vars, emit_transformed_parameters, emit_generated_quantities, pstream); } template inline void write_array(RNG& base_rng, std::vector& params_r, std::vector& params_i, std::vector& vars, bool emit_transformed_parameters = true, bool emit_generated_quantities = true, std::ostream* pstream = nullptr) const { const size_t num_params__ = ((((1 + 1) + S) + 1) + K); const size_t num_transformed = emit_transformed_parameters * (T); const size_t num_gen_quantities = emit_generated_quantities * (0); const size_t num_to_write = num_params__ + num_transformed + num_gen_quantities; vars = std::vector(num_to_write, std::numeric_limits::quiet_NaN()); write_array_impl(base_rng, params_r, params_i, vars, emit_transformed_parameters, emit_generated_quantities, pstream); } template inline T_ log_prob(Eigen::Matrix& params_r, std::ostream* pstream = nullptr) const { Eigen::Matrix params_i; return log_prob_impl(params_r, params_i, pstream); } template inline T_ log_prob(std::vector& params_r, std::vector& params_i, std::ostream* pstream = nullptr) const { return log_prob_impl(params_r, params_i, pstream); } inline void transform_inits(const stan::io::var_context& context, Eigen::Matrix& params_r, std::ostream* pstream = nullptr) const final { std::vector params_r_vec(params_r.size()); std::vector params_i; transform_inits(context, params_i, params_r_vec, pstream); params_r = Eigen::Map>(params_r_vec.data(), params_r_vec.size()); } inline void transform_inits(const stan::io::var_context& context, std::vector& params_i, std::vector& vars, std::ostream* pstream__ = nullptr) const { vars.resize(num_params_r__); transform_inits_impl(context, vars, pstream__); } inline void unconstrain_array(const std::vector& params_constrained, std::vector& params_unconstrained, std::ostream* pstream = nullptr) const { const std::vector params_i; params_unconstrained = std::vector(num_params_r__, std::numeric_limits::quiet_NaN()); unconstrain_array_impl(params_constrained, params_i, params_unconstrained, pstream); } inline void unconstrain_array(const Eigen::Matrix& params_constrained, Eigen::Matrix& params_unconstrained, std::ostream* pstream = nullptr) const { const std::vector params_i; params_unconstrained = Eigen::Matrix::Constant(num_params_r__, std::numeric_limits::quiet_NaN()); unconstrain_array_impl(params_constrained, params_i, params_unconstrained, pstream); } }; } using stan_model = prophet_model_namespace::prophet_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; } stan::math::profile_map& get_stan_profile_data() { return prophet_model_namespace::profiles__; } #endif