Skip to content

Commit

Permalink
test headers and cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveBronder committed Aug 6, 2024
1 parent 1f05474 commit a78d42c
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 302 deletions.
169 changes: 67 additions & 102 deletions stan/math/mix/functor/laplace_marginal_density.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stan/math/mix/prob/laplace_bernoulli_logit_rng.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ laplace_marginal_tol_bernoulli_logit_rng(
const std::vector<int>& y, const std::vector<int>& n_samples,
const ThetaMatrix& theta_0, CovarFun&& covariance_function,
TrainTuple&& train_tuple, PredTuple&& pred_tuple, const double tolerance,
const long int max_num_steps, const int hessian_block_size,
const int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, RNG& rng,
std::ostream* msgs, Args&&... args) {
laplace_options ops{hessian_block_size, solver, max_steps_line_search,
Expand Down
4 changes: 1 addition & 3 deletions stan/math/mix/prob/laplace_marginal_bernoulli_logit_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ template <typename CovarF, typename ThetaMatrix, typename... Args,
inline auto laplace_marginal_tol_bernoulli_logit_lpmf(
const std::vector<int>& y, const std::vector<int>& n_samples,
const ThetaMatrix& theta_0, CovarF&& covariance_function, double tolerance,
long int max_num_steps, const int hessian_block_size, const int solver,
int64_t max_num_steps, const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
laplace_options ops{hessian_block_size, solver, max_steps_line_search,
tolerance, max_num_steps};
Expand All @@ -61,7 +60,6 @@ inline auto laplace_marginal_bernoulli_logit_lpmf(
const std::vector<int>& y, const std::vector<int>& n_samples,
const ThetaMatrix& theta_0, CovarF&& covariance_function,
std::ostream* msgs, Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
constexpr laplace_options ops{1, 1, 0, 1e-6, 100};
return laplace_marginal_density(
Expand Down
10 changes: 5 additions & 5 deletions stan/math/mix/prob/laplace_marginal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ template <bool propto = false, typename LFun, typename LArgs, typename EtaVec,
require_all_eigen_vector_t<EtaVec, Theta0>* = nullptr>
inline auto laplace_marginal_tol_lpdf(
LFun&& L_f, LArgs&& l_args, const EtaVec& eta, const Theta0& theta_0,
CovarFun&& K_f, double tolerance, long int max_num_steps,
CovarFun&& K_f, double tolerance, int64_t max_num_steps,
const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
// TEST: provisional signature to agree with parser.
Expand All @@ -64,7 +64,7 @@ template <bool propto = false, typename LArgs, typename LFun, typename CovarFun,
require_all_eigen_vector_t<Theta0>* = nullptr>
inline auto laplace_marginal_tol_lpdf(LFun&& L_f, LArgs&& l_args,
const Theta0& theta_0, CovarFun&& K_f,
double tolerance, long int max_num_steps,
double tolerance, int64_t max_num_steps,
const int hessian_block_size,
const int solver,
const int max_steps_line_search,
Expand All @@ -87,7 +87,7 @@ template <bool propto = false, typename LFun, typename LArgs, typename EtaVec,
typename CovarFun, typename Theta0, typename... Args>
inline auto laplace_marginal_tol_lpmf(
LFun&& L_f, LArgs&& l_args, const EtaVec& eta, const Theta0& theta_0,
CovarFun&& K_f, const double tolerance, const long int max_num_steps,
CovarFun&& K_f, const double tolerance, const int64_t max_num_steps,
const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
return laplace_marginal_tol_lpdf<propto>(
Expand All @@ -100,7 +100,7 @@ template <bool propto = false, typename LFun, typename LArgs, typename EtaVec,
typename CovarFun, typename Theta0, typename... Args>
inline auto laplace_marginal_tol_lpmf(
LFun&& L_f, LArgs&& l_args, const Theta0& theta_0, CovarFun&& K_f,
const double tolerance, const long int max_num_steps,
const double tolerance, const int64_t max_num_steps,
const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
return laplace_marginal_tol_lpdf<propto>(
Expand All @@ -118,7 +118,7 @@ template <bool propto = false, typename LFun, typename LArgs, typename CovarFun,
typename Theta0, typename... Args>
inline auto laplace_marginal_tol_lpmf(
LFun&& L_f, LArgs&& l_args, const Theta0& theta_0, CovarFun&& K_f,
const double tolerance, const long int max_num_steps,
const double tolerance, const int64_t max_num_steps,
const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
return laplace_marginal_tol_lpdf<propto>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ inline auto laplace_marginal_tol_neg_binomial_2_log_lpmf(
const std::vector<int>& y, const std::vector<int>& y_index,
const Eigen::VectorXd& n_samples, const Eigen::VectorXd& sums,
const Eta& eta, const Theta0& theta_0, CovarFun&& covariance_function,
double tolerance, long int max_num_steps, const int hessian_block_size,
double tolerance, int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, std::ostream* msgs,
Args&&... args) {
laplace_options ops{hessian_block_size, solver, max_steps_line_search,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ template <typename CovarFun, typename YeVec, typename ThetaVec,
inline auto laplace_marginal_tol_poisson_2_log_lpmf(
const std::vector<int>& y, const std::vector<int>& n_samples,
const YeVec& ye, const ThetaVec& theta_0, CovarFun&& covariance_function,
double tolerance, long int max_num_steps, const int hessian_block_size,
double tolerance, int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, std::ostream* msgs,
Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
Eigen::VectorXd y_vec = to_vector(y);
Eigen::VectorXd y_and_ye(y_vec.size() + ye.size());
Expand All @@ -91,7 +90,6 @@ inline auto laplace_marginal_poisson_2_log_lpmf(
const std::vector<int>& y, const std::vector<int>& n_samples,
const YeVec& ye, const ThetaVec& theta_0, CovarFun&& covariance_function,
std::ostream* msgs, Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
constexpr laplace_options ops{1, 1, 0, 1e-6, 100};
return laplace_marginal_density(
Expand Down
4 changes: 1 addition & 3 deletions stan/math/mix/prob/laplace_marginal_poisson_log_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ template <typename CovarFun, typename ThetaVec, typename... Args,
inline auto laplace_marginal_tol_poisson_log_lpmf(
const std::vector<int>& y, const std::vector<int>& n_samples,
const ThetaVec& theta_0, CovarFun&& covariance_function, double tolerance,
long int max_num_steps, const int hessian_block_size, const int solver,
int64_t max_num_steps, const int hessian_block_size, const int solver,
const int max_steps_line_search, std::ostream* msgs, Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
laplace_options ops{hessian_block_size, solver, max_steps_line_search,
tolerance, max_num_steps};
Expand All @@ -80,7 +79,6 @@ inline auto laplace_marginal_poisson_log_lpmf(const std::vector<int>& y,
CovarFun&& covariance_function,
std::ostream* msgs,
Args&&... args) {
// TODO: change this to a VectorXd once we have operands & partials.
Eigen::Matrix<double, 0, 0> eta_dummy;
constexpr laplace_options ops{1, 1, 0, 1e-6, 100};
return laplace_marginal_density(
Expand Down
6 changes: 3 additions & 3 deletions stan/math/mix/prob/laplace_poisson_log_exposure_rng.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace math {
template <typename CovarFun, typename ThetaMatrix, class RNG,
typename TrainTuple, typename PredTuple, typename... Args,
require_eigen_t<ThetaMatrix>* = nullptr>
inline Eigen::VectorXd // CHECK -- right return type
inline auto // CHECK -- right return type
laplace_marginal_tol_poisson_2_log_rng(
const std::vector<int>& y, const std::vector<int>& n_samples,
const Eigen::VectorXd& ye, const ThetaMatrix& theta_0,
CovarFun&& covariance_function, RNG& rng, TrainTuple&& train_tuple,
PredTuple&& pred_tuple, const double tolerance,
const long int max_num_steps, const int hessian_block_size,
const int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, std::ostream* msgs,
Args&&... args) {
Eigen::Matrix<double, 0, 0> eta_dummy;
Expand All @@ -40,7 +40,7 @@ laplace_marginal_tol_poisson_2_log_rng(
template <typename CovarFun, typename ThetaMatrix, class RNG,
typename TrainTuple, typename PredTuple, typename... Args,
require_eigen_t<ThetaMatrix>* = nullptr>
inline Eigen::VectorXd // CHECK -- right return type
inline auto // TODO(Steve): Allow scalar or std vector return
laplace_marginal_poisson_2_log_rng(
const std::vector<int>& y, const std::vector<int>& n_samples,
const Eigen::VectorXd& ye, const ThetaMatrix& theta_0,
Expand Down
2 changes: 1 addition & 1 deletion stan/math/mix/prob/laplace_poisson_log_rng.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ inline Eigen::VectorXd laplace_marginal_tol_poisson_log_rng(
const std::vector<int>& y, const std::vector<int>& n_samples,
const ThetaMatrix& theta_0, CovarFun&& covariance_function,
TrainTuple&& train_tuple, PredTuple&& pred_tuple, const double tolerance,
const long int max_num_steps, const int hessian_block_size,
const int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, RNG& rng,
std::ostream* msgs, Args&&... args) {
Eigen::VectorXd eta_dummy;
Expand Down
4 changes: 2 additions & 2 deletions stan/math/mix/prob/laplace_rng.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <typename LFun, typename LArgs, typename EtaVec, typename DeltaVec,
typename TrainTuple, typename PredTuple, typename... Args>
inline Eigen::VectorXd laplace_marginal_tol_rng(
LFun&& L_f, LArgs&& l_args, const EtaVec& eta, const double tolerance,
const long int max_num_steps, const int hessian_block_size,
const int64_t max_num_steps, const int hessian_block_size,
const int solver, const int max_steps_line_search, const ThetaVec& theta_0,
CovarFun&& K_f, RNG& rng, std::ostream* msgs, TrainTuple&& train_tuple,
PredTuple&& pred_tuple, Args&&... args) {
Expand All @@ -39,7 +39,7 @@ template <typename LFun, typename LArgs, typename CovarFun, typename ThetaVec,
typename... Args>
inline Eigen::VectorXd laplace_marginal_tol_rng(
LFun&& L_f, LArgs&& l_args, const ThetaVec& theta_0, CovarFun&& K_f,
const double tolerance, const long int max_num_steps,
const double tolerance, const int64_t max_num_steps,
const int hessian_block_size, const int solver,
const int max_steps_line_search, TrainTuple&& train_tuple,
PredTuple&& pred_tuple, RNG& rng, std::ostream* msgs, Args&&... args) {
Expand Down
30 changes: 15 additions & 15 deletions stan/math/prim/fun/gp_exp_quad_cov.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ namespace internal {
* @param neg_half_inv_l_sq The half negative inverse of the length scale
* @return squared distance
*/
template <typename T_x, typename T_sigma, typename T_l>
template <typename T_x, typename T_x_alloc, typename T_sigma, typename T_l>
inline typename Eigen::Matrix<return_type_t<T_x, T_sigma, T_l>, Eigen::Dynamic,
Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<T_x> &x, const T_sigma &sigma_sq,
gp_exp_quad_cov(const std::vector<T_x, T_x_alloc> &x, const T_sigma &sigma_sq,
const T_l &neg_half_inv_l_sq) {
using std::exp;
const size_t x_size = x.size();
Expand Down Expand Up @@ -77,10 +77,10 @@ gp_exp_quad_cov(const std::vector<T_x> &x, const T_sigma &sigma_sq,
* @param neg_half_inv_l_sq The half negative inverse of the length scale
* @return squared distance
*/
template <typename T_x1, typename T_x2, typename T_sigma, typename T_l>
template <typename T_x1, typename T_x1_alloc, typename T_x2, typename T_sigma, typename T_l>
inline typename Eigen::Matrix<return_type_t<T_x1, T_x2, T_sigma, T_l>,
Eigen::Dynamic, Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<T_x1> &x1, const std::vector<T_x2> &x2,
gp_exp_quad_cov(const std::vector<T_x1, T_x1_alloc> &x1, const std::vector<T_x2> &x2,
const T_sigma &sigma_sq, const T_l &neg_half_inv_l_sq) {
using std::exp;
Eigen::Matrix<return_type_t<T_x1, T_x2, T_sigma, T_l>, Eigen::Dynamic,
Expand Down Expand Up @@ -120,10 +120,10 @@ gp_exp_quad_cov(const std::vector<T_x1> &x1, const std::vector<T_x2> &x2,
* @throw std::domain_error if sigma <= 0, l <= 0, or
* x is nan or infinite
*/
template <typename T_x, typename T_sigma, typename T_l>
template <typename T_x, typename T_x_alloc, typename T_sigma, typename T_l>
inline typename Eigen::Matrix<return_type_t<T_x, T_sigma, T_l>, Eigen::Dynamic,
Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<T_x> &x, const T_sigma &sigma,
gp_exp_quad_cov(const std::vector<T_x, T_x_alloc> &x, const T_sigma &sigma,
const T_l &length_scale) {
check_positive("gp_exp_quad_cov", "magnitude", sigma);
check_positive("gp_exp_quad_cov", "length scale", length_scale);
Expand Down Expand Up @@ -160,11 +160,11 @@ gp_exp_quad_cov(const std::vector<T_x> &x, const T_sigma &sigma,
* @throw std::domain_error if sigma <= 0, l <= 0, or
* x is nan or infinite
*/
template <typename T_x, typename T_sigma, typename T_l>
template <typename T_x, typename T_x_alloc, typename T_sigma, typename T_l, typename T_l_alloc>
inline typename Eigen::Matrix<return_type_t<T_x, T_sigma, T_l>, Eigen::Dynamic,
Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<Eigen::Matrix<T_x, -1, 1>> &x,
const T_sigma &sigma, const std::vector<T_l> &length_scale) {
gp_exp_quad_cov(const std::vector<Eigen::Matrix<T_x, -1, 1>, T_x_alloc> &x,
const T_sigma &sigma, const std::vector<T_l, T_l_alloc> &length_scale) {
check_positive_finite("gp_exp_quad_cov", "magnitude", sigma);
check_positive_finite("gp_exp_quad_cov", "length scale", length_scale);

Expand Down Expand Up @@ -203,10 +203,10 @@ gp_exp_quad_cov(const std::vector<Eigen::Matrix<T_x, -1, 1>> &x,
* @throw std::domain_error if sigma <= 0, l <= 0, or
* x is nan or infinite
*/
template <typename T_x1, typename T_x2, typename T_sigma, typename T_l>
template <typename T_x1, typename T_x1_alloc, typename T_x2, typename T_x2_alloc, typename T_sigma, typename T_l>
inline typename Eigen::Matrix<return_type_t<T_x1, T_x2, T_sigma, T_l>,
Eigen::Dynamic, Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<T_x1> &x1, const std::vector<T_x2> &x2,
gp_exp_quad_cov(const std::vector<T_x1, T_x1_alloc> &x1, const std::vector<T_x2, T_x2_alloc> &x2,
const T_sigma &sigma, const T_l &length_scale) {
const char *function_name = "gp_exp_quad_cov";
check_positive(function_name, "magnitude", sigma);
Expand Down Expand Up @@ -252,12 +252,12 @@ gp_exp_quad_cov(const std::vector<T_x1> &x1, const std::vector<T_x2> &x2,
* @throw std::domain_error if sigma <= 0, l <= 0, or
* x is nan or infinite
*/
template <typename T_x1, typename T_x2, typename T_s, typename T_l>
template <typename T_x1, typename T_x1_alloc, typename T_x2, typename T_x2_alloc, typename T_s, typename T_l, typename T_l_alloc>
inline typename Eigen::Matrix<return_type_t<T_x1, T_x2, T_s, T_l>,
Eigen::Dynamic, Eigen::Dynamic>
gp_exp_quad_cov(const std::vector<Eigen::Matrix<T_x1, -1, 1>> &x1,
const std::vector<Eigen::Matrix<T_x2, -1, 1>> &x2,
const T_s &sigma, const std::vector<T_l> &length_scale) {
gp_exp_quad_cov(const std::vector<Eigen::Matrix<T_x1, -1, 1>, T_x1_alloc> &x1,
const std::vector<Eigen::Matrix<T_x2, -1, 1>, T_x2_alloc> &x2,
const T_s &sigma, const std::vector<T_l, T_l_alloc> &length_scale) {
size_t x1_size = x1.size();
size_t x2_size = x2.size();
size_t l_size = length_scale.size();
Expand Down
Loading

0 comments on commit a78d42c

Please sign in to comment.