From 93ad3e0f38d55b048f08b321d860dd19bb237900 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Mon, 24 Jun 2024 12:06:50 -0400 Subject: [PATCH] Rearrange includes so fwd is included first if STAN_MODEL_FVAR_VAR is defined --- src/stan/model/model_base.hpp | 96 +++++++++++++++++++----------- src/stan/model/model_base_crtp.hpp | 2 +- src/stan/model/model_header.hpp | 4 +- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/src/stan/model/model_base.hpp b/src/stan/model/model_base.hpp index 1f6de972f9..a8196d93d7 100644 --- a/src/stan/model/model_base.hpp +++ b/src/stan/model/model_base.hpp @@ -1,11 +1,11 @@ #ifndef STAN_MODEL_MODEL_BASE_HPP #define STAN_MODEL_MODEL_BASE_HPP -#include -#include #ifdef STAN_MODEL_FVAR_VAR #include #endif +#include +#include #include #include #include @@ -78,7 +78,8 @@ class model_base : public prob_grad { */ virtual void get_param_names(std::vector& names, bool include_tparams = true, - bool include_gqs = true) const = 0; + bool include_gqs = true) const + = 0; /** * WARNING: This function bakes in the assumption that the * parameter values are rectangular. This is already not true @@ -107,7 +108,8 @@ class model_base : public prob_grad { */ virtual void get_dims(std::vector >& dimss, bool include_tparams = true, - bool include_gqs = true) const = 0; + bool include_gqs = true) const + = 0; /** * Set the specified sequence to the indexed, scalar, constrained * parameter names. Each variable is output with a @@ -148,7 +150,8 @@ class model_base : public prob_grad { */ virtual void constrained_param_names(std::vector& param_names, bool include_tparams = true, - bool include_gqs = true) const = 0; + bool include_gqs = true) const + = 0; /** * Set the specified sequence of parameter names to the @@ -177,7 +180,8 @@ class model_base : public prob_grad { */ virtual void unconstrained_param_names(std::vector& param_names, bool include_tparams = true, - bool include_gqs = true) const = 0; + bool include_gqs = true) const + = 0; /** * Return the log density for the specified unconstrained @@ -188,8 +192,8 @@ class model_base : public prob_grad { * @param[in,out] msgs message stream * @return log density for specified parameters */ - virtual double log_prob(Eigen::VectorXd& params_r, - std::ostream* msgs) const = 0; + virtual double log_prob(Eigen::VectorXd& params_r, std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -201,7 +205,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual math::var log_prob(Eigen::Matrix& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -217,7 +222,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual double log_prob_jacobian(Eigen::VectorXd& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -233,7 +239,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual math::var log_prob_jacobian(Eigen::Matrix& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -250,7 +257,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual double log_prob_propto(Eigen::VectorXd& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -262,7 +270,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual math::var log_prob_propto(Eigen::Matrix& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -283,7 +292,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual double log_prob_propto_jacobian(Eigen::VectorXd& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -299,7 +309,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual math::var log_prob_propto_jacobian( - Eigen::Matrix& params_r, std::ostream* msgs) const = 0; + Eigen::Matrix& params_r, std::ostream* msgs) const + = 0; /** * Convenience template function returning the log density for the @@ -347,7 +358,8 @@ class model_base : public prob_grad { */ virtual void transform_inits(const io::var_context& context, Eigen::VectorXd& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Convert the specified sequence of unconstrained parameters to a @@ -370,7 +382,8 @@ class model_base : public prob_grad { virtual void write_array(stan::rng_t& base_rng, Eigen::VectorXd& params_r, Eigen::VectorXd& params_constrained_r, bool include_tparams = true, bool include_gqs = true, - std::ostream* msgs = 0) const = 0; + std::ostream* msgs = 0) const + = 0; /** * Convert the specified sequence of constrained parameters to a @@ -385,7 +398,8 @@ class model_base : public prob_grad { */ virtual void unconstrain_array(const Eigen::VectorXd& params_r_constrained, Eigen::VectorXd& params_r, - std::ostream* msgs = nullptr) const = 0; + std::ostream* msgs = nullptr) const + = 0; // TODO(carpenter): cut redundant std::vector versions from here === @@ -402,8 +416,8 @@ class model_base : public prob_grad { * @return log density for specified parameters */ virtual double log_prob(std::vector& params_r, - std::vector& params_i, - std::ostream* msgs) const = 0; + std::vector& params_i, std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -419,7 +433,8 @@ class model_base : public prob_grad { */ virtual math::var log_prob(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -439,7 +454,8 @@ class model_base : public prob_grad { */ virtual double log_prob_jacobian(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -459,7 +475,8 @@ class model_base : public prob_grad { */ virtual math::var log_prob_jacobian(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -480,7 +497,8 @@ class model_base : public prob_grad { */ virtual double log_prob_propto(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -496,7 +514,8 @@ class model_base : public prob_grad { */ virtual math::var log_prob_propto(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -521,7 +540,8 @@ class model_base : public prob_grad { */ virtual double log_prob_propto_jacobian(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -541,7 +561,8 @@ class model_base : public prob_grad { */ virtual math::var log_prob_propto_jacobian(std::vector& params_r, std::vector& params_i, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Convenience template function returning the log density for the @@ -596,7 +617,8 @@ class model_base : public prob_grad { virtual void transform_inits(const io::var_context& context, std::vector& params_i, std::vector& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Convert the specified sequence of unconstrained parameters to a @@ -621,7 +643,8 @@ class model_base : public prob_grad { std::vector& params_i, std::vector& params_r_constrained, bool include_tparams = true, bool include_gqs = true, - std::ostream* msgs = 0) const = 0; + std::ostream* msgs = 0) const + = 0; /** * Convert the specified sequence of constrained parameters to a @@ -636,7 +659,8 @@ class model_base : public prob_grad { */ virtual void unconstrain_array( const std::vector& params_r_constrained, - std::vector& params_r, std::ostream* msgs = nullptr) const = 0; + std::vector& params_r, std::ostream* msgs = nullptr) const + = 0; #ifdef STAN_MODEL_FVAR_VAR @@ -651,7 +675,8 @@ class model_base : public prob_grad { */ virtual math::fvar log_prob( Eigen::Matrix, -1, 1>& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -668,7 +693,8 @@ class model_base : public prob_grad { */ virtual math::fvar log_prob_jacobian( Eigen::Matrix, -1, 1>& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -681,7 +707,8 @@ class model_base : public prob_grad { */ virtual math::fvar log_prob_propto( Eigen::Matrix, -1, 1>& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; /** * Return the log density for the specified unconstrained @@ -698,7 +725,8 @@ class model_base : public prob_grad { */ virtual math::fvar log_prob_propto_jacobian( Eigen::Matrix, -1, 1>& params_r, - std::ostream* msgs) const = 0; + std::ostream* msgs) const + = 0; #endif }; diff --git a/src/stan/model/model_base_crtp.hpp b/src/stan/model/model_base_crtp.hpp index 1868b3e056..cfb54a91ad 100644 --- a/src/stan/model/model_base_crtp.hpp +++ b/src/stan/model/model_base_crtp.hpp @@ -1,10 +1,10 @@ #ifndef STAN_MODEL_MODEL_BASE_CRTP_HPP #define STAN_MODEL_MODEL_BASE_CRTP_HPP -#include #ifdef STAN_MODEL_FVAR_VAR #include #endif +#include #include #include #include diff --git a/src/stan/model/model_header.hpp b/src/stan/model/model_header.hpp index 34948377f7..a3896ecc6c 100644 --- a/src/stan/model/model_header.hpp +++ b/src/stan/model/model_header.hpp @@ -1,14 +1,14 @@ #ifndef STAN_MODEL_MODEL_HEADER_HPP #define STAN_MODEL_MODEL_HEADER_HPP +#include +#include #include #include #include #include -#include -#include #include #include #include