// Code generated by stanc v2.32.1
#include <stan/model/model_header.hpp>
namespace simple_model_model_namespace {
using stan::model::model_base_crtp;
using namespace stan::math;
stan::math::profile_map profiles__;
static constexpr std::array<const char*, 24> locations_array__ =
  {" (found before start of program)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 14, column 4 to column 28)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 15, column 4 to column 37)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 16, column 4 to column 27)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 22, column 4 to column 39)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 25, column 4 to column 33)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 29, column 4 to column 54)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 27, column 24 to line 30, column 5)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 27, column 4 to line 30, column 5)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 3, column 6 to column 27)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 4, column 6 to column 27)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 5, column 6 to column 17)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 6, column 13 to column 20)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 6, column 6 to column 30)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 7, column 13 to column 20)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 7, column 21 to column 28)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 7, column 6 to column 39)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 8, column 13 to column 20)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 8, column 6 to column 29)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 9, column 6 to column 22)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 14, column 12 to column 19)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 15, column 28 to column 35)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 15, column 12 to column 19)",
  " (in '/Users/davidcatalan/Desktop/TFM/models/simple_model.stan', line 16, column 12 to column 19)"};
class simple_model_model final : public model_base_crtp<simple_model_model> {
 private:
  int yStates;
  int xStates;
  int Ntotal;
  Eigen::Matrix<double,-1,1> yCounts_data__;
  Eigen::Matrix<double,-1,-1> xyCounts_data__;
  Eigen::Matrix<double,-1,1> alpha0_data__;
  double s;
  Eigen::Map<Eigen::Matrix<double,-1,1>> yCounts{nullptr, 0};
  Eigen::Map<Eigen::Matrix<double,-1,-1>> xyCounts{nullptr, 0, 0};
  Eigen::Map<Eigen::Matrix<double,-1,1>> alpha0{nullptr, 0};
 public:
  ~simple_model_model() {}
  simple_model_model(stan::io::var_context& context__, unsigned int
                     random_seed__ = 0, std::ostream* pstream__ = nullptr)
      : model_base_crtp(0) {
    int current_statement__ = 0;
    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__ =
      "simple_model_model_namespace::simple_model_model";
    // suppress unused var warning
    (void) function__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      current_statement__ = 9;
      context__.validate_dims("data initialization", "yStates", "int",
        std::vector<size_t>{});
      yStates = std::numeric_limits<int>::min();
      current_statement__ = 9;
      yStates = context__.vals_i("yStates")[(1 - 1)];
      current_statement__ = 9;
      stan::math::check_greater_or_equal(function__, "yStates", yStates, 2);
      current_statement__ = 10;
      context__.validate_dims("data initialization", "xStates", "int",
        std::vector<size_t>{});
      xStates = std::numeric_limits<int>::min();
      current_statement__ = 10;
      xStates = context__.vals_i("xStates")[(1 - 1)];
      current_statement__ = 10;
      stan::math::check_greater_or_equal(function__, "xStates", xStates, 2);
      current_statement__ = 11;
      context__.validate_dims("data initialization", "Ntotal", "int",
        std::vector<size_t>{});
      Ntotal = std::numeric_limits<int>::min();
      current_statement__ = 11;
      Ntotal = context__.vals_i("Ntotal")[(1 - 1)];
      current_statement__ = 12;
      stan::math::validate_non_negative_index("yCounts", "yStates", yStates);
      current_statement__ = 13;
      context__.validate_dims("data initialization", "yCounts", "double",
        std::vector<size_t>{static_cast<size_t>(yStates)});
      yCounts_data__ = Eigen::Matrix<double,-1,1>::Constant(yStates,
                         std::numeric_limits<double>::quiet_NaN());
      new (&yCounts)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(yCounts_data__.data(),
        yStates);
      {
        std::vector<local_scalar_t__> yCounts_flat__;
        current_statement__ = 13;
        yCounts_flat__ = context__.vals_r("yCounts");
        current_statement__ = 13;
        pos__ = 1;
        current_statement__ = 13;
        for (int sym1__ = 1; sym1__ <= yStates; ++sym1__) {
          current_statement__ = 13;
          stan::model::assign(yCounts, yCounts_flat__[(pos__ - 1)],
            "assigning variable yCounts", stan::model::index_uni(sym1__));
          current_statement__ = 13;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 14;
      stan::math::validate_non_negative_index("xyCounts", "xStates", xStates);
      current_statement__ = 15;
      stan::math::validate_non_negative_index("xyCounts", "yStates", yStates);
      current_statement__ = 16;
      context__.validate_dims("data initialization", "xyCounts", "double",
        std::vector<size_t>{static_cast<size_t>(xStates),
          static_cast<size_t>(yStates)});
      xyCounts_data__ = Eigen::Matrix<double,-1,-1>::Constant(xStates,
                          yStates, std::numeric_limits<double>::quiet_NaN());
      new (&xyCounts)
        Eigen::Map<Eigen::Matrix<double,-1,-1>>(xyCounts_data__.data(),
        xStates, yStates);
      {
        std::vector<local_scalar_t__> xyCounts_flat__;
        current_statement__ = 16;
        xyCounts_flat__ = context__.vals_r("xyCounts");
        current_statement__ = 16;
        pos__ = 1;
        current_statement__ = 16;
        for (int sym1__ = 1; sym1__ <= yStates; ++sym1__) {
          current_statement__ = 16;
          for (int sym2__ = 1; sym2__ <= xStates; ++sym2__) {
            current_statement__ = 16;
            stan::model::assign(xyCounts, xyCounts_flat__[(pos__ - 1)],
              "assigning variable xyCounts", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 16;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 17;
      stan::math::validate_non_negative_index("alpha0", "xStates", xStates);
      current_statement__ = 18;
      context__.validate_dims("data initialization", "alpha0", "double",
        std::vector<size_t>{static_cast<size_t>(xStates)});
      alpha0_data__ = Eigen::Matrix<double,-1,1>::Constant(xStates,
                        std::numeric_limits<double>::quiet_NaN());
      new (&alpha0)
        Eigen::Map<Eigen::Matrix<double,-1,1>>(alpha0_data__.data(), xStates);
      {
        std::vector<local_scalar_t__> alpha0_flat__;
        current_statement__ = 18;
        alpha0_flat__ = context__.vals_r("alpha0");
        current_statement__ = 18;
        pos__ = 1;
        current_statement__ = 18;
        for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
          current_statement__ = 18;
          stan::model::assign(alpha0, alpha0_flat__[(pos__ - 1)],
            "assigning variable alpha0", stan::model::index_uni(sym1__));
          current_statement__ = 18;
          pos__ = (pos__ + 1);
        }
      }
      current_statement__ = 19;
      context__.validate_dims("data initialization", "s", "double",
        std::vector<size_t>{});
      s = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 19;
      s = context__.vals_r("s")[(1 - 1)];
      current_statement__ = 19;
      stan::math::check_greater_or_equal(function__, "s", s, 0);
      current_statement__ = 20;
      stan::math::validate_positive_index("thetaY", "yStates", yStates);
      current_statement__ = 21;
      stan::math::validate_non_negative_index("thetaX", "yStates", yStates);
      current_statement__ = 22;
      stan::math::validate_positive_index("thetaX", "xStates", xStates);
      current_statement__ = 23;
      stan::math::validate_positive_index("alpha", "xStates", xStates);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    num_params_r__ = (yStates - 1) + (yStates * (xStates - 1)) + (xStates -
      1);
  }
  inline std::string model_name() const final {
    return "simple_model_model";
  }
  inline std::vector<std::string> model_compile_info() const noexcept {
    return std::vector<std::string>{"stanc_version = stanc3 v2.32.1",
             "stancflags = "};
  }
  template <bool propto__, bool jacobian__, typename VecR, typename VecI,
            stan::require_vector_like_t<VecR>* = nullptr,
            stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline stan::scalar_type_t<VecR>
  log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*
                pstream__ = nullptr) const {
    using T__ = stan::scalar_type_t<VecR>;
    using local_scalar_t__ = T__;
    T__ lp__(0.0);
    stan::math::accumulator<T__> lp_accum__;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    static constexpr const char* function__ =
      "simple_model_model_namespace::log_prob";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<local_scalar_t__,-1,1> thetaY =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(yStates, DUMMY_VAR__);
      current_statement__ = 1;
      thetaY = in__.template read_constrain_simplex<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(lp__,
                 yStates);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> thetaX =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(yStates,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates,
            DUMMY_VAR__));
      current_statement__ = 2;
      thetaX = in__.template read_constrain_simplex<
                 std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
                 jacobian__>(lp__, yStates, xStates);
      Eigen::Matrix<local_scalar_t__,-1,1> alpha =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates, DUMMY_VAR__);
      current_statement__ = 3;
      alpha = in__.template read_constrain_simplex<
                Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(lp__,
                xStates);
      {
        current_statement__ = 4;
        lp_accum__.add(stan::math::dirichlet_lpdf<propto__>(thetaY,
                         stan::math::add(1.0, yCounts)));
        current_statement__ = 5;
        lp_accum__.add(stan::math::dirichlet_lpdf<propto__>(alpha, alpha0));
        current_statement__ = 8;
        for (int y = 1; y <= yStates; ++y) {
          current_statement__ = 6;
          lp_accum__.add(stan::math::dirichlet_lpdf<propto__>(
                           stan::model::rvalue(thetaX, "thetaX",
                             stan::model::index_uni(y)),
                           stan::math::add(stan::math::multiply(s, alpha),
                             stan::math::col(xyCounts, y))));
        }
      }
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    lp_accum__.add(lp__);
    return lp_accum__.sum();
  }
  template <typename RNG, typename VecR, typename VecI, typename VecVar,
            stan::require_vector_like_vt<std::is_floating_point,
            VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral,
            VecI>* = nullptr, stan::require_vector_vt<std::is_floating_point,
            VecVar>* = 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<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> 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;
    stan::math::accumulator<double> lp_accum__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    constexpr bool jacobian__ = false;
    static constexpr const char* function__ =
      "simple_model_model_namespace::write_array";
    // suppress unused var warning
    (void) function__;
    try {
      Eigen::Matrix<double,-1,1> thetaY =
        Eigen::Matrix<double,-1,1>::Constant(yStates,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 1;
      thetaY = in__.template read_constrain_simplex<
                 Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(lp__,
                 yStates);
      std::vector<Eigen::Matrix<double,-1,1>> thetaX =
        std::vector<Eigen::Matrix<double,-1,1>>(yStates,
          Eigen::Matrix<double,-1,1>::Constant(xStates,
            std::numeric_limits<double>::quiet_NaN()));
      current_statement__ = 2;
      thetaX = in__.template read_constrain_simplex<
                 std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>,
                 jacobian__>(lp__, yStates, xStates);
      Eigen::Matrix<double,-1,1> alpha =
        Eigen::Matrix<double,-1,1>::Constant(xStates,
          std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 3;
      alpha = in__.template read_constrain_simplex<
                Eigen::Matrix<local_scalar_t__,-1,1>, jacobian__>(lp__,
                xStates);
      out__.write(thetaY);
      for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= yStates; ++sym2__) {
          out__.write(thetaX[(sym2__ - 1)][(sym1__ - 1)]);
        }
      }
      out__.write(alpha);
      if (stan::math::logical_negation(
            (stan::math::primitive_value(emit_transformed_parameters__) ||
            stan::math::primitive_value(emit_generated_quantities__)))) {
        return ;
      }
      if (stan::math::logical_negation(emit_generated_quantities__)) {
        return ;
      }
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, typename VecI,
            stan::require_vector_t<VecVar>* = nullptr,
            stan::require_vector_like_vt<std::is_integral, VecI>* = 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<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      Eigen::Matrix<local_scalar_t__,-1,1> thetaY =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(yStates, DUMMY_VAR__);
      current_statement__ = 1;
      stan::model::assign(thetaY,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(yStates),
        "assigning variable thetaY");
      out__.write_free_simplex(thetaY);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> thetaX =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(yStates,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates,
            DUMMY_VAR__));
      current_statement__ = 2;
      for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
        current_statement__ = 2;
        for (int sym2__ = 1; sym2__ <= yStates; ++sym2__) {
          current_statement__ = 2;
          stan::model::assign(thetaX, in__.read<local_scalar_t__>(),
            "assigning variable thetaX", stan::model::index_uni(sym2__),
            stan::model::index_uni(sym1__));
        }
      }
      out__.write_free_simplex(thetaX);
      Eigen::Matrix<local_scalar_t__,-1,1> alpha =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates, DUMMY_VAR__);
      current_statement__ = 3;
      stan::model::assign(alpha,
        in__.read<Eigen::Matrix<local_scalar_t__,-1,1>>(xStates),
        "assigning variable alpha");
      out__.write_free_simplex(alpha);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, stan::require_vector_t<VecVar>* = 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<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      current_statement__ = 1;
      context__.validate_dims("parameter initialization", "thetaY", "double",
        std::vector<size_t>{static_cast<size_t>(yStates)});
      current_statement__ = 2;
      context__.validate_dims("parameter initialization", "thetaX", "double",
        std::vector<size_t>{static_cast<size_t>(yStates),
          static_cast<size_t>(xStates)});
      current_statement__ = 3;
      context__.validate_dims("parameter initialization", "alpha", "double",
        std::vector<size_t>{static_cast<size_t>(xStates)});
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      Eigen::Matrix<local_scalar_t__,-1,1> thetaY =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(yStates, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> thetaY_flat__;
        current_statement__ = 1;
        thetaY_flat__ = context__.vals_r("thetaY");
        current_statement__ = 1;
        pos__ = 1;
        current_statement__ = 1;
        for (int sym1__ = 1; sym1__ <= yStates; ++sym1__) {
          current_statement__ = 1;
          stan::model::assign(thetaY, thetaY_flat__[(pos__ - 1)],
            "assigning variable thetaY", stan::model::index_uni(sym1__));
          current_statement__ = 1;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_simplex(thetaY);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> thetaX =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(yStates,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates,
            DUMMY_VAR__));
      {
        std::vector<local_scalar_t__> thetaX_flat__;
        current_statement__ = 2;
        thetaX_flat__ = context__.vals_r("thetaX");
        current_statement__ = 2;
        pos__ = 1;
        current_statement__ = 2;
        for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
          current_statement__ = 2;
          for (int sym2__ = 1; sym2__ <= yStates; ++sym2__) {
            current_statement__ = 2;
            stan::model::assign(thetaX, thetaX_flat__[(pos__ - 1)],
              "assigning variable thetaX", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 2;
            pos__ = (pos__ + 1);
          }
        }
      }
      out__.write_free_simplex(thetaX);
      Eigen::Matrix<local_scalar_t__,-1,1> alpha =
        Eigen::Matrix<local_scalar_t__,-1,1>::Constant(xStates, DUMMY_VAR__);
      {
        std::vector<local_scalar_t__> alpha_flat__;
        current_statement__ = 3;
        alpha_flat__ = context__.vals_r("alpha");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
          current_statement__ = 3;
          stan::model::assign(alpha, alpha_flat__[(pos__ - 1)],
            "assigning variable alpha", stan::model::index_uni(sym1__));
          current_statement__ = 3;
          pos__ = (pos__ + 1);
        }
      }
      out__.write_free_simplex(alpha);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  inline void
  get_param_names(std::vector<std::string>& names__, const bool
                  emit_transformed_parameters__ = true, const bool
                  emit_generated_quantities__ = true) const {
    names__ = std::vector<std::string>{"thetaY", "thetaX", "alpha"};
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {}
  }
  inline void
  get_dims(std::vector<std::vector<size_t>>& dimss__, const bool
           emit_transformed_parameters__ = true, const bool
           emit_generated_quantities__ = true) const {
    dimss__ = std::vector<std::vector<size_t>>{std::vector<size_t>{static_cast<
                                                                    size_t>(
                                                                    yStates)},
                std::vector<size_t>{static_cast<size_t>(yStates),
                  static_cast<size_t>(xStates)},
                std::vector<size_t>{static_cast<size_t>(xStates)}};
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {}
  }
  inline void
  constrained_param_names(std::vector<std::string>& param_names__, bool
                          emit_transformed_parameters__ = true, bool
                          emit_generated_quantities__ = true) const final {
    for (int sym1__ = 1; sym1__ <= yStates; ++sym1__) {
      param_names__.emplace_back(std::string() + "thetaY" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= yStates; ++sym2__) {
        param_names__.emplace_back(std::string() + "thetaX" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= xStates; ++sym1__) {
      param_names__.emplace_back(std::string() + "alpha" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {}
  }
  inline void
  unconstrained_param_names(std::vector<std::string>& param_names__, bool
                            emit_transformed_parameters__ = true, bool
                            emit_generated_quantities__ = true) const final {
    for (int sym1__ = 1; sym1__ <= (yStates - 1); ++sym1__) {
      param_names__.emplace_back(std::string() + "thetaY" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= (xStates - 1); ++sym1__) {
      for (int sym2__ = 1; sym2__ <= yStates; ++sym2__) {
        param_names__.emplace_back(std::string() + "thetaX" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    for (int sym1__ = 1; sym1__ <= (xStates - 1); ++sym1__) {
      param_names__.emplace_back(std::string() + "alpha" + '.' +
        std::to_string(sym1__));
    }
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {}
  }
  inline std::string get_constrained_sizedtypes() const {
    return std::string("[{\"name\":\"thetaY\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(yStates) + "},\"block\":\"parameters\"},{\"name\":\"thetaX\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(yStates) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(xStates) + "}},\"block\":\"parameters\"},{\"name\":\"alpha\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string(xStates) + "},\"block\":\"parameters\"}]");
  }
  inline std::string get_unconstrained_sizedtypes() const {
    return std::string("[{\"name\":\"thetaY\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string((yStates -1)) + "},\"block\":\"parameters\"},{\"name\":\"thetaX\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(yStates) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string((xStates -1)) + "}},\"block\":\"parameters\"},{\"name\":\"alpha\",\"type\":{\"name\":\"vector\",\"length\":" + std::to_string((xStates -1)) + "},\"block\":\"parameters\"}]");
  }
  // Begin method overload boilerplate
  template <typename RNG> inline void
  write_array(RNG& base_rng, Eigen::Matrix<double,-1,1>& params_r,
              Eigen::Matrix<double,-1,1>& vars, const bool
              emit_transformed_parameters = true, const bool
              emit_generated_quantities = true, std::ostream*
              pstream = nullptr) const {
    const size_t num_params__ = ((yStates + (yStates * xStates)) + xStates);
    const size_t num_transformed = emit_transformed_parameters * (0);
    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<int> params_i;
    vars = Eigen::Matrix<double,-1,1>::Constant(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    write_array_impl(base_rng, params_r, params_i, vars,
      emit_transformed_parameters, emit_generated_quantities, pstream);
  }
  template <typename RNG> inline 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 = nullptr) const {
    const size_t num_params__ = ((yStates + (yStates * xStates)) + xStates);
    const size_t num_transformed = emit_transformed_parameters * (0);
    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<double>(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    write_array_impl(base_rng, params_r, params_i, vars,
      emit_transformed_parameters, emit_generated_quantities, pstream);
  }
  template <bool propto__, bool jacobian__, typename T_> inline T_
  log_prob(Eigen::Matrix<T_,-1,1>& params_r, std::ostream* pstream = nullptr) const {
    Eigen::Matrix<int,-1,1> params_i;
    return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
  }
  template <bool propto__, bool jacobian__, typename T_> inline T_
  log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,
           std::ostream* pstream = nullptr) const {
    return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
  }
  inline void
  transform_inits(const stan::io::var_context& context,
                  Eigen::Matrix<double,-1,1>& params_r, std::ostream*
                  pstream = nullptr) const final {
    std::vector<double> params_r_vec(params_r.size());
    std::vector<int> params_i;
    transform_inits(context, params_i, params_r_vec, pstream);
    params_r = Eigen::Map<Eigen::Matrix<double,-1,1>>(params_r_vec.data(),
                 params_r_vec.size());
  }
  inline void
  transform_inits(const stan::io::var_context& context, std::vector<int>&
                  params_i, std::vector<double>& vars, std::ostream*
                  pstream__ = nullptr) const {
    vars.resize(num_params_r__);
    transform_inits_impl(context, vars, pstream__);
  }
  inline void
  unconstrain_array(const std::vector<double>& params_constrained,
                    std::vector<double>& params_unconstrained, std::ostream*
                    pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = std::vector<double>(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
  inline void
  unconstrain_array(const Eigen::Matrix<double,-1,1>& params_constrained,
                    Eigen::Matrix<double,-1,1>& params_unconstrained,
                    std::ostream* pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = Eigen::Matrix<double,-1,1>::Constant(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
};
}
using stan_model = simple_model_model_namespace::simple_model_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 simple_model_model_namespace::profiles__;
}
#endif