From 35e3127ef9651b4f7f33f28464e693cf3e71d28f Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 12:03:34 -0400 Subject: [PATCH 01/35] set all static const values to static constexpr so that -O0 level optimization still treats them as known as compile time --- stan/math/opencl/double_d.hpp | 2 +- .../kernel_generator/colwise_reduction.hpp | 2 +- .../kernel_generator/multi_result_kernel.hpp | 11 ++++------- .../opencl/kernel_generator/operation_cl.hpp | 2 +- .../opencl/kernel_generator/reduction_2d.hpp | 2 +- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/batch_identity.hpp | 2 +- .../kernels/categorical_logit_glm_lpmf.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cholesky_decompose.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- .../opencl/kernels/device_functions/Phi.hpp | 2 +- .../kernels/device_functions/Phi_approx.hpp | 2 +- .../device_functions/atomic_add_double.hpp | 2 +- .../opencl/kernels/device_functions/beta.hpp | 2 +- .../binomial_coefficient_log.hpp | 2 +- .../opencl/kernels/device_functions/digamma.hpp | 2 +- .../opencl/kernels/device_functions/inv_Phi.hpp | 2 +- .../kernels/device_functions/inv_logit.hpp | 2 +- .../kernels/device_functions/inv_square.hpp | 2 +- .../opencl/kernels/device_functions/lbeta.hpp | 2 +- .../device_functions/lgamma_stirling.hpp | 2 +- .../device_functions/lgamma_stirling_diff.hpp | 2 +- .../kernels/device_functions/lmultiply.hpp | 2 +- .../opencl/kernels/device_functions/log1m.hpp | 2 +- .../kernels/device_functions/log1m_exp.hpp | 2 +- .../device_functions/log1m_inv_logit.hpp | 2 +- .../kernels/device_functions/log1p_exp.hpp | 2 +- .../kernels/device_functions/log_diff_exp.hpp | 2 +- .../kernels/device_functions/log_inv_logit.hpp | 2 +- .../device_functions/log_inv_logit_diff.hpp | 2 +- .../opencl/kernels/device_functions/logit.hpp | 2 +- .../kernels/device_functions/multiply_log.hpp | 2 +- .../kernels/device_functions/trigamma.hpp | 2 +- stan/math/opencl/kernels/diag_inv.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/opencl/kernels/fill_strict_tri.hpp | 2 +- stan/math/opencl/kernels/gp_exp_quad_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_exponential_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_matern32_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_matern52_cov.hpp | 4 ++-- stan/math/opencl/kernels/indexing_rev.hpp | 6 +++--- .../opencl/kernels/inv_lower_tri_multiply.hpp | 2 +- stan/math/opencl/kernels/matrix_multiply.hpp | 4 ++-- stan/math/opencl/kernels/mergesort.hpp | 2 +- stan/math/opencl/kernels/mrrr.hpp | 4 ++-- stan/math/opencl/kernels/multiply_transpose.hpp | 2 +- .../kernels/neg_binomial_2_log_glm_lpmf.hpp | 2 +- .../kernels/neg_rect_lower_tri_multiply.hpp | 2 +- .../kernels/ordered_logistic_glm_lpmf.hpp | 2 +- .../opencl/kernels/ordered_logistic_lpmf.hpp | 2 +- stan/math/opencl/kernels/pack.hpp | 2 +- stan/math/opencl/kernels/rep_matrix.hpp | 2 +- stan/math/opencl/kernels/tridiagonalization.hpp | 8 ++++---- stan/math/opencl/kernels/unpack.hpp | 2 +- stan/math/opencl/matrix_cl_view.hpp | 2 +- stan/math/opencl/mrrr.hpp | 6 +++--- stan/math/opencl/prim/bernoulli_cdf.hpp | 2 +- stan/math/opencl/prim/bernoulli_lccdf.hpp | 2 +- stan/math/opencl/prim/bernoulli_lcdf.hpp | 2 +- .../opencl/prim/bernoulli_logit_glm_lpmf.hpp | 2 +- stan/math/opencl/prim/bernoulli_logit_lpmf.hpp | 4 ++-- stan/math/opencl/prim/bernoulli_lpmf.hpp | 2 +- stan/math/opencl/prim/beta_binomial_lpmf.hpp | 2 +- stan/math/opencl/prim/beta_lpdf.hpp | 2 +- stan/math/opencl/prim/beta_proportion_lpdf.hpp | 2 +- stan/math/opencl/prim/binomial_logit_lpmf.hpp | 2 +- stan/math/opencl/prim/binomial_lpmf.hpp | 2 +- .../opencl/prim/categorical_logit_glm_lpmf.hpp | 2 +- stan/math/opencl/prim/cauchy_cdf.hpp | 2 +- stan/math/opencl/prim/cauchy_lccdf.hpp | 2 +- stan/math/opencl/prim/cauchy_lcdf.hpp | 2 +- stan/math/opencl/prim/cauchy_lpdf.hpp | 2 +- stan/math/opencl/prim/chi_square_lpdf.hpp | 2 +- stan/math/opencl/prim/dirichlet_lpdf.hpp | 2 +- .../math/opencl/prim/double_exponential_cdf.hpp | 2 +- .../opencl/prim/double_exponential_lccdf.hpp | 2 +- .../opencl/prim/double_exponential_lcdf.hpp | 2 +- .../opencl/prim/double_exponential_lpdf.hpp | 2 +- stan/math/opencl/prim/exp_mod_normal_cdf.hpp | 2 +- stan/math/opencl/prim/exp_mod_normal_lccdf.hpp | 2 +- stan/math/opencl/prim/exp_mod_normal_lcdf.hpp | 2 +- stan/math/opencl/prim/exp_mod_normal_lpdf.hpp | 2 +- stan/math/opencl/prim/exponential_cdf.hpp | 2 +- stan/math/opencl/prim/exponential_lccdf.hpp | 2 +- stan/math/opencl/prim/exponential_lcdf.hpp | 2 +- stan/math/opencl/prim/exponential_lpdf.hpp | 2 +- stan/math/opencl/prim/frechet_cdf.hpp | 2 +- stan/math/opencl/prim/frechet_lccdf.hpp | 2 +- stan/math/opencl/prim/frechet_lcdf.hpp | 2 +- stan/math/opencl/prim/frechet_lpdf.hpp | 2 +- stan/math/opencl/prim/gamma_lpdf.hpp | 2 +- stan/math/opencl/prim/gumbel_cdf.hpp | 2 +- stan/math/opencl/prim/gumbel_lccdf.hpp | 2 +- stan/math/opencl/prim/gumbel_lcdf.hpp | 2 +- stan/math/opencl/prim/gumbel_lpdf.hpp | 2 +- stan/math/opencl/prim/inv_chi_square_lpdf.hpp | 2 +- stan/math/opencl/prim/inv_gamma_lpdf.hpp | 2 +- stan/math/opencl/prim/log_mix.hpp | 2 +- stan/math/opencl/prim/logistic_cdf.hpp | 2 +- stan/math/opencl/prim/logistic_lccdf.hpp | 2 +- stan/math/opencl/prim/logistic_lcdf.hpp | 2 +- stan/math/opencl/prim/logistic_lpdf.hpp | 2 +- stan/math/opencl/prim/lognormal_cdf.hpp | 2 +- stan/math/opencl/prim/lognormal_lccdf.hpp | 2 +- stan/math/opencl/prim/lognormal_lcdf.hpp | 2 +- stan/math/opencl/prim/lognormal_lpdf.hpp | 2 +- .../opencl/prim/multi_normal_cholesky_lpdf.hpp | 2 +- .../opencl/prim/neg_binomial_2_log_glm_lpmf.hpp | 2 +- .../opencl/prim/neg_binomial_2_log_lpmf.hpp | 2 +- stan/math/opencl/prim/neg_binomial_2_lpmf.hpp | 2 +- stan/math/opencl/prim/neg_binomial_lpmf.hpp | 2 +- stan/math/opencl/prim/normal_cdf.hpp | 2 +- stan/math/opencl/prim/normal_id_glm_lpdf.hpp | 2 +- stan/math/opencl/prim/normal_lccdf.hpp | 2 +- stan/math/opencl/prim/normal_lcdf.hpp | 2 +- stan/math/opencl/prim/normal_lpdf.hpp | 2 +- .../opencl/prim/ordered_logistic_glm_lpmf.hpp | 2 +- stan/math/opencl/prim/ordered_logistic_lpmf.hpp | 2 +- stan/math/opencl/prim/pareto_cdf.hpp | 2 +- stan/math/opencl/prim/pareto_lccdf.hpp | 2 +- stan/math/opencl/prim/pareto_lcdf.hpp | 2 +- stan/math/opencl/prim/pareto_lpdf.hpp | 2 +- stan/math/opencl/prim/pareto_type_2_cdf.hpp | 2 +- stan/math/opencl/prim/pareto_type_2_lccdf.hpp | 2 +- stan/math/opencl/prim/pareto_type_2_lcdf.hpp | 2 +- stan/math/opencl/prim/pareto_type_2_lpdf.hpp | 2 +- stan/math/opencl/prim/poisson_log_glm_lpmf.hpp | 2 +- stan/math/opencl/prim/poisson_log_lpmf.hpp | 2 +- stan/math/opencl/prim/poisson_lpmf.hpp | 2 +- stan/math/opencl/prim/rayleigh_cdf.hpp | 2 +- stan/math/opencl/prim/rayleigh_lccdf.hpp | 2 +- stan/math/opencl/prim/rayleigh_lcdf.hpp | 2 +- stan/math/opencl/prim/rayleigh_lpdf.hpp | 2 +- .../opencl/prim/scaled_inv_chi_square_lpdf.hpp | 2 +- .../opencl/prim/skew_double_exponential_cdf.hpp | 2 +- .../prim/skew_double_exponential_lccdf.hpp | 2 +- .../prim/skew_double_exponential_lcdf.hpp | 2 +- .../prim/skew_double_exponential_lpdf.hpp | 2 +- stan/math/opencl/prim/skew_normal_lpdf.hpp | 2 +- stan/math/opencl/prim/std_normal_cdf.hpp | 2 +- stan/math/opencl/prim/std_normal_lccdf.hpp | 2 +- stan/math/opencl/prim/std_normal_lcdf.hpp | 2 +- stan/math/opencl/prim/std_normal_lpdf.hpp | 2 +- stan/math/opencl/prim/student_t_lpdf.hpp | 2 +- stan/math/opencl/prim/uniform_cdf.hpp | 2 +- stan/math/opencl/prim/uniform_lccdf.hpp | 2 +- stan/math/opencl/prim/uniform_lcdf.hpp | 2 +- stan/math/opencl/prim/uniform_lpdf.hpp | 2 +- stan/math/opencl/prim/weibull_cdf.hpp | 2 +- stan/math/opencl/prim/weibull_lccdf.hpp | 2 +- stan/math/opencl/prim/weibull_lcdf.hpp | 2 +- stan/math/opencl/prim/weibull_lpdf.hpp | 2 +- stan/math/prim/fun/binomial_coefficient_log.hpp | 2 +- stan/math/prim/fun/constants.hpp | 10 +++++----- stan/math/prim/fun/inv_Phi.hpp | 12 ++++++------ stan/math/prim/fun/lbeta.hpp | 2 +- stan/math/prim/fun/linspaced_array.hpp | 2 +- stan/math/prim/fun/linspaced_int_array.hpp | 2 +- stan/math/prim/fun/linspaced_row_vector.hpp | 2 +- stan/math/prim/fun/linspaced_vector.hpp | 2 +- stan/math/prim/fun/log.hpp | 4 ++-- stan/math/prim/fun/log10.hpp | 2 +- stan/math/prim/fun/log_falling_factorial.hpp | 2 +- stan/math/prim/fun/log_mix.hpp | 4 ++-- .../prim/fun/log_modified_bessel_first_kind.hpp | 12 ++++++------ stan/math/prim/fun/log_rising_factorial.hpp | 2 +- stan/math/prim/fun/mdivide_left_spd.hpp | 2 +- stan/math/prim/fun/mdivide_right_spd.hpp | 2 +- stan/math/prim/fun/one_hot_array.hpp | 2 +- stan/math/prim/fun/one_hot_int_array.hpp | 2 +- stan/math/prim/fun/one_hot_row_vector.hpp | 2 +- stan/math/prim/fun/one_hot_vector.hpp | 2 +- stan/math/prim/fun/rising_factorial.hpp | 2 +- stan/math/prim/fun/to_int.hpp | 2 +- stan/math/prim/fun/to_matrix.hpp | 6 +++--- stan/math/prim/fun/unitspaced_array.hpp | 2 +- stan/math/prim/functor/map_rect.hpp | 2 +- stan/math/prim/prob/bernoulli_cdf.hpp | 2 +- stan/math/prim/prob/bernoulli_lccdf.hpp | 2 +- stan/math/prim/prob/bernoulli_lcdf.hpp | 2 +- .../math/prim/prob/bernoulli_logit_glm_lpmf.hpp | 4 ++-- stan/math/prim/prob/bernoulli_logit_glm_rng.hpp | 2 +- stan/math/prim/prob/bernoulli_logit_lpmf.hpp | 4 ++-- stan/math/prim/prob/bernoulli_lpmf.hpp | 2 +- stan/math/prim/prob/bernoulli_rng.hpp | 2 +- stan/math/prim/prob/beta_binomial_cdf.hpp | 2 +- stan/math/prim/prob/beta_binomial_lccdf.hpp | 2 +- stan/math/prim/prob/beta_binomial_lcdf.hpp | 2 +- stan/math/prim/prob/beta_binomial_lpmf.hpp | 2 +- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_cdf.hpp | 2 +- stan/math/prim/prob/beta_lccdf.hpp | 2 +- stan/math/prim/prob/beta_lcdf.hpp | 2 +- stan/math/prim/prob/beta_lpdf.hpp | 2 +- stan/math/prim/prob/beta_proportion_lccdf.hpp | 2 +- stan/math/prim/prob/beta_proportion_lcdf.hpp | 2 +- stan/math/prim/prob/beta_proportion_lpdf.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/binomial_cdf.hpp | 2 +- stan/math/prim/prob/binomial_lccdf.hpp | 2 +- stan/math/prim/prob/binomial_lcdf.hpp | 2 +- stan/math/prim/prob/binomial_logit_lpmf.hpp | 2 +- stan/math/prim/prob/binomial_lpmf.hpp | 2 +- stan/math/prim/prob/binomial_rng.hpp | 2 +- .../prim/prob/categorical_logit_glm_lpmf.hpp | 2 +- stan/math/prim/prob/categorical_logit_lpmf.hpp | 4 ++-- stan/math/prim/prob/categorical_logit_rng.hpp | 2 +- stan/math/prim/prob/categorical_lpmf.hpp | 4 ++-- stan/math/prim/prob/categorical_rng.hpp | 2 +- stan/math/prim/prob/cauchy_cdf.hpp | 2 +- stan/math/prim/prob/cauchy_lccdf.hpp | 2 +- stan/math/prim/prob/cauchy_lcdf.hpp | 2 +- stan/math/prim/prob/cauchy_lpdf.hpp | 2 +- stan/math/prim/prob/cauchy_rng.hpp | 2 +- stan/math/prim/prob/chi_square_cdf.hpp | 2 +- stan/math/prim/prob/chi_square_lccdf.hpp | 2 +- stan/math/prim/prob/chi_square_lcdf.hpp | 2 +- stan/math/prim/prob/chi_square_lpdf.hpp | 2 +- stan/math/prim/prob/chi_square_rng.hpp | 2 +- stan/math/prim/prob/dirichlet_lpdf.hpp | 2 +- stan/math/prim/prob/discrete_range_cdf.hpp | 2 +- stan/math/prim/prob/discrete_range_lccdf.hpp | 2 +- stan/math/prim/prob/discrete_range_lcdf.hpp | 2 +- stan/math/prim/prob/discrete_range_lpmf.hpp | 2 +- stan/math/prim/prob/discrete_range_rng.hpp | 2 +- stan/math/prim/prob/double_exponential_cdf.hpp | 2 +- .../math/prim/prob/double_exponential_lccdf.hpp | 2 +- stan/math/prim/prob/double_exponential_lcdf.hpp | 2 +- stan/math/prim/prob/double_exponential_lpdf.hpp | 2 +- stan/math/prim/prob/double_exponential_rng.hpp | 2 +- stan/math/prim/prob/exp_mod_normal_cdf.hpp | 2 +- stan/math/prim/prob/exp_mod_normal_lccdf.hpp | 2 +- stan/math/prim/prob/exp_mod_normal_lcdf.hpp | 2 +- stan/math/prim/prob/exp_mod_normal_lpdf.hpp | 2 +- stan/math/prim/prob/exp_mod_normal_rng.hpp | 2 +- stan/math/prim/prob/exponential_cdf.hpp | 2 +- stan/math/prim/prob/exponential_lccdf.hpp | 2 +- stan/math/prim/prob/exponential_lcdf.hpp | 2 +- stan/math/prim/prob/exponential_lpdf.hpp | 2 +- stan/math/prim/prob/exponential_rng.hpp | 2 +- stan/math/prim/prob/frechet_cdf.hpp | 2 +- stan/math/prim/prob/frechet_lccdf.hpp | 2 +- stan/math/prim/prob/frechet_lcdf.hpp | 2 +- stan/math/prim/prob/frechet_lpdf.hpp | 2 +- stan/math/prim/prob/frechet_rng.hpp | 2 +- stan/math/prim/prob/gamma_cdf.hpp | 2 +- stan/math/prim/prob/gamma_lccdf.hpp | 2 +- stan/math/prim/prob/gamma_lcdf.hpp | 2 +- stan/math/prim/prob/gamma_lpdf.hpp | 2 +- stan/math/prim/prob/gamma_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_lpdf.hpp | 4 ++-- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- stan/math/prim/prob/gumbel_cdf.hpp | 2 +- stan/math/prim/prob/gumbel_lccdf.hpp | 2 +- stan/math/prim/prob/gumbel_lcdf.hpp | 2 +- stan/math/prim/prob/gumbel_lpdf.hpp | 2 +- stan/math/prim/prob/gumbel_rng.hpp | 2 +- stan/math/prim/prob/hypergeometric_lpmf.hpp | 2 +- stan/math/prim/prob/hypergeometric_rng.hpp | 2 +- stan/math/prim/prob/inv_chi_square_cdf.hpp | 2 +- stan/math/prim/prob/inv_chi_square_lccdf.hpp | 2 +- stan/math/prim/prob/inv_chi_square_lcdf.hpp | 2 +- stan/math/prim/prob/inv_chi_square_lpdf.hpp | 2 +- stan/math/prim/prob/inv_chi_square_rng.hpp | 2 +- stan/math/prim/prob/inv_gamma_cdf.hpp | 2 +- stan/math/prim/prob/inv_gamma_lccdf.hpp | 2 +- stan/math/prim/prob/inv_gamma_lcdf.hpp | 2 +- stan/math/prim/prob/inv_gamma_lpdf.hpp | 2 +- stan/math/prim/prob/inv_gamma_rng.hpp | 2 +- .../prim/prob/inv_wishart_cholesky_lpdf.hpp | 2 +- .../math/prim/prob/inv_wishart_cholesky_rng.hpp | 2 +- stan/math/prim/prob/inv_wishart_lpdf.hpp | 2 +- stan/math/prim/prob/inv_wishart_rng.hpp | 2 +- stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp | 2 +- stan/math/prim/prob/lkj_corr_cholesky_rng.hpp | 2 +- stan/math/prim/prob/lkj_corr_lpdf.hpp | 2 +- stan/math/prim/prob/lkj_corr_rng.hpp | 2 +- stan/math/prim/prob/lkj_cov_lpdf.hpp | 4 ++-- stan/math/prim/prob/logistic_cdf.hpp | 2 +- stan/math/prim/prob/logistic_lccdf.hpp | 2 +- stan/math/prim/prob/logistic_lcdf.hpp | 2 +- stan/math/prim/prob/logistic_lpdf.hpp | 2 +- stan/math/prim/prob/logistic_rng.hpp | 2 +- stan/math/prim/prob/loglogistic_cdf.hpp | 2 +- stan/math/prim/prob/loglogistic_lpdf.hpp | 2 +- stan/math/prim/prob/loglogistic_rng.hpp | 2 +- stan/math/prim/prob/lognormal_cdf.hpp | 2 +- stan/math/prim/prob/lognormal_lccdf.hpp | 2 +- stan/math/prim/prob/lognormal_lcdf.hpp | 2 +- stan/math/prim/prob/lognormal_lpdf.hpp | 2 +- stan/math/prim/prob/lognormal_rng.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_lpdf.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp | 2 +- stan/math/prim/prob/multi_gp_lpdf.hpp | 2 +- .../prim/prob/multi_normal_cholesky_lpdf.hpp | 4 ++-- .../prim/prob/multi_normal_cholesky_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_lpdf.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_lpdf.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_rng.hpp | 2 +- .../prim/prob/multi_student_t_cholesky_lpdf.hpp | 2 +- .../prim/prob/multi_student_t_cholesky_rng.hpp | 2 +- stan/math/prim/prob/multi_student_t_lpdf.hpp | 2 +- stan/math/prim/prob/multi_student_t_rng.hpp | 2 +- stan/math/prim/prob/multinomial_logit_lpmf.hpp | 2 +- stan/math/prim/prob/multinomial_logit_rng.hpp | 2 +- stan/math/prim/prob/multinomial_lpmf.hpp | 2 +- stan/math/prim/prob/multinomial_rng.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_cdf.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_lccdf.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_lcdf.hpp | 2 +- .../prim/prob/neg_binomial_2_log_glm_lpmf.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_log_rng.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_lpmf.hpp | 2 +- stan/math/prim/prob/neg_binomial_2_rng.hpp | 2 +- stan/math/prim/prob/neg_binomial_cdf.hpp | 2 +- stan/math/prim/prob/neg_binomial_lccdf.hpp | 2 +- stan/math/prim/prob/neg_binomial_lcdf.hpp | 2 +- stan/math/prim/prob/neg_binomial_lpmf.hpp | 2 +- stan/math/prim/prob/neg_binomial_rng.hpp | 2 +- stan/math/prim/prob/normal_cdf.hpp | 2 +- stan/math/prim/prob/normal_id_glm_lpdf.hpp | 2 +- stan/math/prim/prob/normal_lccdf.hpp | 2 +- stan/math/prim/prob/normal_lcdf.hpp | 2 +- stan/math/prim/prob/normal_lpdf.hpp | 2 +- stan/math/prim/prob/normal_rng.hpp | 2 +- stan/math/prim/prob/normal_sufficient_lpdf.hpp | 2 +- .../prim/prob/ordered_logistic_glm_lpmf.hpp | 2 +- stan/math/prim/prob/ordered_logistic_lpmf.hpp | 2 +- stan/math/prim/prob/ordered_logistic_rng.hpp | 2 +- stan/math/prim/prob/ordered_probit_lpmf.hpp | 2 +- stan/math/prim/prob/ordered_probit_rng.hpp | 2 +- stan/math/prim/prob/pareto_cdf.hpp | 2 +- stan/math/prim/prob/pareto_lccdf.hpp | 2 +- stan/math/prim/prob/pareto_lcdf.hpp | 2 +- stan/math/prim/prob/pareto_lpdf.hpp | 2 +- stan/math/prim/prob/pareto_rng.hpp | 2 +- stan/math/prim/prob/pareto_type_2_cdf.hpp | 2 +- stan/math/prim/prob/pareto_type_2_lccdf.hpp | 2 +- stan/math/prim/prob/pareto_type_2_lcdf.hpp | 2 +- stan/math/prim/prob/pareto_type_2_lpdf.hpp | 2 +- stan/math/prim/prob/pareto_type_2_rng.hpp | 2 +- stan/math/prim/prob/poisson_binomial_cdf.hpp | 2 +- stan/math/prim/prob/poisson_binomial_lccdf.hpp | 2 +- stan/math/prim/prob/poisson_binomial_lcdf.hpp | 2 +- stan/math/prim/prob/poisson_binomial_lpmf.hpp | 2 +- stan/math/prim/prob/poisson_binomial_rng.hpp | 2 +- stan/math/prim/prob/poisson_cdf.hpp | 2 +- stan/math/prim/prob/poisson_lccdf.hpp | 2 +- stan/math/prim/prob/poisson_lcdf.hpp | 2 +- stan/math/prim/prob/poisson_log_glm_lpmf.hpp | 2 +- stan/math/prim/prob/poisson_log_lpmf.hpp | 2 +- stan/math/prim/prob/poisson_log_rng.hpp | 4 ++-- stan/math/prim/prob/poisson_lpmf.hpp | 2 +- stan/math/prim/prob/poisson_rng.hpp | 2 +- stan/math/prim/prob/rayleigh_cdf.hpp | 2 +- stan/math/prim/prob/rayleigh_lccdf.hpp | 2 +- stan/math/prim/prob/rayleigh_lcdf.hpp | 2 +- stan/math/prim/prob/rayleigh_lpdf.hpp | 2 +- stan/math/prim/prob/rayleigh_rng.hpp | 2 +- .../prim/prob/scaled_inv_chi_square_cdf.hpp | 2 +- .../prim/prob/scaled_inv_chi_square_lccdf.hpp | 2 +- .../prim/prob/scaled_inv_chi_square_lcdf.hpp | 2 +- .../prim/prob/scaled_inv_chi_square_lpdf.hpp | 2 +- .../prim/prob/scaled_inv_chi_square_rng.hpp | 2 +- .../prim/prob/skew_double_exponential_cdf.hpp | 2 +- .../prim/prob/skew_double_exponential_lccdf.hpp | 2 +- .../prim/prob/skew_double_exponential_lcdf.hpp | 2 +- .../prim/prob/skew_double_exponential_lpdf.hpp | 2 +- .../prim/prob/skew_double_exponential_rng.hpp | 2 +- stan/math/prim/prob/skew_normal_cdf.hpp | 2 +- stan/math/prim/prob/skew_normal_lccdf.hpp | 2 +- stan/math/prim/prob/skew_normal_lcdf.hpp | 2 +- stan/math/prim/prob/skew_normal_lpdf.hpp | 2 +- stan/math/prim/prob/skew_normal_rng.hpp | 2 +- stan/math/prim/prob/std_normal_cdf.hpp | 2 +- stan/math/prim/prob/std_normal_lccdf.hpp | 2 +- stan/math/prim/prob/std_normal_lcdf.hpp | 2 +- stan/math/prim/prob/std_normal_log_qf.hpp | 12 ++++++------ stan/math/prim/prob/std_normal_lpdf.hpp | 2 +- stan/math/prim/prob/student_t_cdf.hpp | 2 +- stan/math/prim/prob/student_t_lccdf.hpp | 2 +- stan/math/prim/prob/student_t_lcdf.hpp | 2 +- stan/math/prim/prob/student_t_lpdf.hpp | 2 +- stan/math/prim/prob/student_t_rng.hpp | 2 +- stan/math/prim/prob/uniform_cdf.hpp | 2 +- stan/math/prim/prob/uniform_lccdf.hpp | 2 +- stan/math/prim/prob/uniform_lcdf.hpp | 2 +- stan/math/prim/prob/uniform_lpdf.hpp | 2 +- stan/math/prim/prob/uniform_rng.hpp | 2 +- stan/math/prim/prob/von_mises_rng.hpp | 2 +- stan/math/prim/prob/weibull_cdf.hpp | 2 +- stan/math/prim/prob/weibull_lccdf.hpp | 2 +- stan/math/prim/prob/weibull_lcdf.hpp | 2 +- stan/math/prim/prob/weibull_lpdf.hpp | 2 +- stan/math/prim/prob/weibull_rng.hpp | 2 +- stan/math/prim/prob/wiener_lpdf.hpp | 17 +++++++++-------- stan/math/prim/prob/wishart_cholesky_lpdf.hpp | 2 +- stan/math/prim/prob/wishart_cholesky_rng.hpp | 2 +- stan/math/prim/prob/wishart_lpdf.hpp | 2 +- stan/math/prim/prob/wishart_rng.hpp | 2 +- stan/math/rev/fun/accumulator.hpp | 2 +- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +++--- 407 files changed, 467 insertions(+), 469 deletions(-) diff --git a/stan/math/opencl/double_d.hpp b/stan/math/opencl/double_d.hpp index 39f3a6870b6..54cf3114500 100644 --- a/stan/math/opencl/double_d.hpp +++ b/stan/math/opencl/double_d.hpp @@ -86,7 +86,7 @@ inline double_d mul_d_d(double a, double b) { } // \cond -static const char* double_d_src = STRINGIFY( +static constexpr const char* double_d_src = STRINGIFY( // \endcond typedef struct { double high; diff --git a/stan/math/opencl/kernel_generator/colwise_reduction.hpp b/stan/math/opencl/kernel_generator/colwise_reduction.hpp index 7a623e68f25..44d534b8b03 100644 --- a/stan/math/opencl/kernel_generator/colwise_reduction.hpp +++ b/stan/math/opencl/kernel_generator/colwise_reduction.hpp @@ -66,7 +66,7 @@ class colwise_reduction using Scalar = typename std::remove_reference_t::Scalar; using base = operation_cl; using base::var_name_; - static const bool require_specific_local_size = true; + static constexpr bool require_specific_local_size = true; protected: std::string init_; diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index a82d033c5f3..d5c58bcd233 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -71,7 +71,7 @@ struct multi_result_kernel_internal { next::check_assign_dimensions(n_rows, n_cols, assignment_pairs); const auto& expression = std::get(assignment_pairs).second; const auto& result = std::get(assignment_pairs).first; - const char* function = "results.operator="; + constexpr char* function = "results.operator="; int expression_rows = expression.rows(); int expression_cols = expression.cols(); @@ -376,8 +376,7 @@ class results_cl { using impl = typename internal::multi_result_kernel_internal< std::tuple_size>::value - 1, T_res...>::template inner; - static const bool require_specific_local_size = std::max( - {std::decay_t::Deriv::require_specific_local_size...}); + static constexpr bool require_specific_local_size = stan::math::disjunction::Deriv::require_specific_local_size...>::value; name_generator ng; std::map generated; @@ -442,14 +441,12 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; - static const bool any_output = std::max( - {false, !is_without_output>::value...}); + static constexpr bool any_output = stan::math::disjunction>::value...>::value; if (!any_output) { return; } - static const bool require_specific_local_size = std::max( - {std::decay_t::Deriv::require_specific_local_size...}); + static constexpr bool require_specific_local_size = stan::math::disjunction::Deriv::require_specific_local_size...>::value; int n_rows = std::get<0>(assignment_pairs).second.thread_rows(); int n_cols = std::get<0>(assignment_pairs).second.thread_cols(); diff --git a/stan/math/opencl/kernel_generator/operation_cl.hpp b/stan/math/opencl/kernel_generator/operation_cl.hpp index ef2d4977c97..8bed8faad89 100644 --- a/stan/math/opencl/kernel_generator/operation_cl.hpp +++ b/stan/math/opencl/kernel_generator/operation_cl.hpp @@ -114,7 +114,7 @@ class operation_cl : public operation_cl_base { static constexpr int N = sizeof...(Args); using view_transitivity = std::tuple...>; // value representing a not yet determined size - static const int dynamic = -1; + static constexpr int dynamic = -1; /** Returns an argument to this operation diff --git a/stan/math/opencl/kernel_generator/reduction_2d.hpp b/stan/math/opencl/kernel_generator/reduction_2d.hpp index ed3131a888b..149fcb0416a 100644 --- a/stan/math/opencl/kernel_generator/reduction_2d.hpp +++ b/stan/math/opencl/kernel_generator/reduction_2d.hpp @@ -50,7 +50,7 @@ class reduction_2d using Scalar = typename std::remove_reference_t::Scalar; using base = operation_cl; using base::var_name_; - static const bool require_specific_local_size = true; + static constexpr bool require_specific_local_size = true; protected: std::string init_; diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 7b558476220..169b2528cd1 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static const std::string add_batch_kernel_code = STRINGIFY( +static constexpr std::string add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/batch_identity.hpp b/stan/math/opencl/kernels/batch_identity.hpp index c067960a71d..0b38a6bea3d 100644 --- a/stan/math/opencl/kernels/batch_identity.hpp +++ b/stan/math/opencl/kernels/batch_identity.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string batch_identity_kernel_code = STRINGIFY( +static constexpr std::string batch_identity_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels diff --git a/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp b/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp index 55dde06808f..33d23af00d9 100644 --- a/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp +++ b/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const std::string categorical_logit_glm_kernel_code = STRINGIFY( +static constexpr std::string categorical_logit_glm_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU implementation of Generalized Linear Model (GLM) diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index f2e38234124..5c93bf3b525 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string is_symmetric_kernel_code = STRINGIFY( +static constexpr std::string is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cholesky_decompose.hpp b/stan/math/opencl/kernels/cholesky_decompose.hpp index a2f1eefd489..31f6f2caf61 100644 --- a/stan/math/opencl/kernels/cholesky_decompose.hpp +++ b/stan/math/opencl/kernels/cholesky_decompose.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string cholesky_decompose_kernel_code = STRINGIFY( +static constexpr std::string cholesky_decompose_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Calculates the Cholesky Decomposition of a matrix on an OpenCL diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index 848647c7ac2..12e5d94ca97 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char *cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static const char *cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static const char *cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/device_functions/Phi.hpp b/stan/math/opencl/kernels/device_functions/Phi.hpp index ba7ecb6a51f..f13c45550cd 100644 --- a/stan/math/opencl/kernels/device_functions/Phi.hpp +++ b/stan/math/opencl/kernels/device_functions/Phi.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* phi_device_function +static constexpr const char* phi_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_PHI\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_PHI\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/Phi_approx.hpp b/stan/math/opencl/kernels/device_functions/Phi_approx.hpp index 343710e7acc..a86c3563951 100644 --- a/stan/math/opencl/kernels/device_functions/Phi_approx.hpp +++ b/stan/math/opencl/kernels/device_functions/Phi_approx.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* phi_approx_device_function +static constexpr const char* phi_approx_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_PHI_APPROX\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp index 8ae6977ba6b..c7d2f0e5deb 100644 --- a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp +++ b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char *atomic_add_double_device_function +static constexpr const char *atomic_add_double_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" diff --git a/stan/math/opencl/kernels/device_functions/beta.hpp b/stan/math/opencl/kernels/device_functions/beta.hpp index 8a193db3f4d..e634cddb07c 100644 --- a/stan/math/opencl/kernels/device_functions/beta.hpp +++ b/stan/math/opencl/kernels/device_functions/beta.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* beta_device_function +static constexpr const char* beta_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_BETA\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_BETA\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/binomial_coefficient_log.hpp b/stan/math/opencl/kernels/device_functions/binomial_coefficient_log.hpp index b1d6d5f99fa..ac15cb19e17 100644 --- a/stan/math/opencl/kernels/device_functions/binomial_coefficient_log.hpp +++ b/stan/math/opencl/kernels/device_functions/binomial_coefficient_log.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* binomial_coefficient_log_device_function +static constexpr const char* binomial_coefficient_log_device_function = "\n" "#ifndef " "STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_BINOMIAL_COEFFICIENT_LOG\n" diff --git a/stan/math/opencl/kernels/device_functions/digamma.hpp b/stan/math/opencl/kernels/device_functions/digamma.hpp index f4ffc7b17d5..5552cfd822f 100644 --- a/stan/math/opencl/kernels/device_functions/digamma.hpp +++ b/stan/math/opencl/kernels/device_functions/digamma.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* digamma_device_function +static constexpr const char* digamma_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_DIGAMMA\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_DIGAMMA\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/inv_Phi.hpp b/stan/math/opencl/kernels/device_functions/inv_Phi.hpp index 68200168438..bec6070505a 100644 --- a/stan/math/opencl/kernels/device_functions/inv_Phi.hpp +++ b/stan/math/opencl/kernels/device_functions/inv_Phi.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* inv_phi_device_function +static constexpr const char* inv_phi_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_PHI\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_PHI\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/inv_logit.hpp b/stan/math/opencl/kernels/device_functions/inv_logit.hpp index 9cb9d56cc27..50c2103a703 100644 --- a/stan/math/opencl/kernels/device_functions/inv_logit.hpp +++ b/stan/math/opencl/kernels/device_functions/inv_logit.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* inv_logit_device_function +static constexpr const char* inv_logit_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_LOGIT\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/inv_square.hpp b/stan/math/opencl/kernels/device_functions/inv_square.hpp index 7ec970eeeb6..90d2c89549d 100644 --- a/stan/math/opencl/kernels/device_functions/inv_square.hpp +++ b/stan/math/opencl/kernels/device_functions/inv_square.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* inv_square_device_function +static constexpr const char* inv_square_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_INV_SQUARE\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/lbeta.hpp b/stan/math/opencl/kernels/device_functions/lbeta.hpp index f0aeb8061fb..ce83372801f 100644 --- a/stan/math/opencl/kernels/device_functions/lbeta.hpp +++ b/stan/math/opencl/kernels/device_functions/lbeta.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* lbeta_device_function +static constexpr const char* lbeta_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LBETA\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LBETA\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/lgamma_stirling.hpp b/stan/math/opencl/kernels/device_functions/lgamma_stirling.hpp index 19fc87b968f..34f480f64f3 100644 --- a/stan/math/opencl/kernels/device_functions/lgamma_stirling.hpp +++ b/stan/math/opencl/kernels/device_functions/lgamma_stirling.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* lgamma_stirling_device_function +static constexpr const char* lgamma_stirling_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/lgamma_stirling_diff.hpp b/stan/math/opencl/kernels/device_functions/lgamma_stirling_diff.hpp index 78118f3f9d3..87e11dce6ff 100644 --- a/stan/math/opencl/kernels/device_functions/lgamma_stirling_diff.hpp +++ b/stan/math/opencl/kernels/device_functions/lgamma_stirling_diff.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* lgamma_stirling_diff_device_function +static constexpr const char* lgamma_stirling_diff_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING_DIFF\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LGAMMA_STIRLING_DIFF\n" diff --git a/stan/math/opencl/kernels/device_functions/lmultiply.hpp b/stan/math/opencl/kernels/device_functions/lmultiply.hpp index 9f06058a83c..8f8e6077a4c 100644 --- a/stan/math/opencl/kernels/device_functions/lmultiply.hpp +++ b/stan/math/opencl/kernels/device_functions/lmultiply.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* lmultiply_device_function +static constexpr const char* lmultiply_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LMULTIPLY\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/log1m.hpp b/stan/math/opencl/kernels/device_functions/log1m.hpp index 2f43bf10ad2..62bdbdfa1dc 100644 --- a/stan/math/opencl/kernels/device_functions/log1m.hpp +++ b/stan/math/opencl/kernels/device_functions/log1m.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log1m_device_function +static constexpr const char* log1m_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/log1m_exp.hpp b/stan/math/opencl/kernels/device_functions/log1m_exp.hpp index 1ec7af2a379..54993594780 100644 --- a/stan/math/opencl/kernels/device_functions/log1m_exp.hpp +++ b/stan/math/opencl/kernels/device_functions/log1m_exp.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log1m_exp_device_function +static constexpr const char* log1m_exp_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_EXP\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/log1m_inv_logit.hpp b/stan/math/opencl/kernels/device_functions/log1m_inv_logit.hpp index 4f997edd3b4..33dfebf87ac 100644 --- a/stan/math/opencl/kernels/device_functions/log1m_inv_logit.hpp +++ b/stan/math/opencl/kernels/device_functions/log1m_inv_logit.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log1m_inv_logit_device_function +static constexpr const char* log1m_inv_logit_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1M_INV_LOGIT\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/log1p_exp.hpp b/stan/math/opencl/kernels/device_functions/log1p_exp.hpp index 786bd0c9900..2198bbe59a7 100644 --- a/stan/math/opencl/kernels/device_functions/log1p_exp.hpp +++ b/stan/math/opencl/kernels/device_functions/log1p_exp.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log1p_exp_device_function +static constexpr const char* log1p_exp_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_EXP\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG1P_EXP\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/log_diff_exp.hpp b/stan/math/opencl/kernels/device_functions/log_diff_exp.hpp index 649cb84ee6a..bbcdfc1ac09 100644 --- a/stan/math/opencl/kernels/device_functions/log_diff_exp.hpp +++ b/stan/math/opencl/kernels/device_functions/log_diff_exp.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log_diff_exp_device_function +static constexpr const char* log_diff_exp_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_DIFF_EXP\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/log_inv_logit.hpp b/stan/math/opencl/kernels/device_functions/log_inv_logit.hpp index cd3ebba121e..4d0b47106ce 100644 --- a/stan/math/opencl/kernels/device_functions/log_inv_logit.hpp +++ b/stan/math/opencl/kernels/device_functions/log_inv_logit.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log_inv_logit_device_function +static constexpr const char* log_inv_logit_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_INV_LOGIT\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/log_inv_logit_diff.hpp b/stan/math/opencl/kernels/device_functions/log_inv_logit_diff.hpp index 7756c79bde0..201064d3212 100644 --- a/stan/math/opencl/kernels/device_functions/log_inv_logit_diff.hpp +++ b/stan/math/opencl/kernels/device_functions/log_inv_logit_diff.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* log_inv_logit_diff_device_function +static constexpr const char* log_inv_logit_diff_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOG_INV_LOGIT_DIFF\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/logit.hpp b/stan/math/opencl/kernels/device_functions/logit.hpp index 8ec1bf8850b..c9bed7c849f 100644 --- a/stan/math/opencl/kernels/device_functions/logit.hpp +++ b/stan/math/opencl/kernels/device_functions/logit.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* logit_device_function +static constexpr const char* logit_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOGIT\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_LOGIT\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/device_functions/multiply_log.hpp b/stan/math/opencl/kernels/device_functions/multiply_log.hpp index eb5cde66104..b1f5071b070 100644 --- a/stan/math/opencl/kernels/device_functions/multiply_log.hpp +++ b/stan/math/opencl/kernels/device_functions/multiply_log.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static const char* multiply_log_device_function +static constexpr const char* multiply_log_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_MULTIPLY_LOG\n" "#define " diff --git a/stan/math/opencl/kernels/device_functions/trigamma.hpp b/stan/math/opencl/kernels/device_functions/trigamma.hpp index 31d67e9d3b4..f93db4f724f 100644 --- a/stan/math/opencl/kernels/device_functions/trigamma.hpp +++ b/stan/math/opencl/kernels/device_functions/trigamma.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const char* trigamma_device_function +static constexpr const char* trigamma_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_TRIGAMMA\n" STRINGIFY( diff --git a/stan/math/opencl/kernels/diag_inv.hpp b/stan/math/opencl/kernels/diag_inv.hpp index 707971e7f49..a4368f20ea8 100644 --- a/stan/math/opencl/kernels/diag_inv.hpp +++ b/stan/math/opencl/kernels/diag_inv.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string diag_inv_kernel_code = STRINGIFY( +static constexpr std::string diag_inv_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Calculates inplace submatrix inversions along the matrix diagonal. diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 2f929a70cf7..2d8728fbef2 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string divide_columns_kernel_code = STRINGIFY( +static constexpr std::string divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/opencl/kernels/fill_strict_tri.hpp b/stan/math/opencl/kernels/fill_strict_tri.hpp index 0c5d6f2551c..dca81dc9360 100644 --- a/stan/math/opencl/kernels/fill_strict_tri.hpp +++ b/stan/math/opencl/kernels/fill_strict_tri.hpp @@ -11,7 +11,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string fill_strict_tri_kernel_code = STRINGIFY( +static constexpr std::string fill_strict_tri_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Stores constant in the triangular part of a matrix diff --git a/stan/math/opencl/kernels/gp_exp_quad_cov.hpp b/stan/math/opencl/kernels/gp_exp_quad_cov.hpp index d9f293e5293..f647ef160f5 100644 --- a/stan/math/opencl/kernels/gp_exp_quad_cov.hpp +++ b/stan/math/opencl/kernels/gp_exp_quad_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string gp_exp_quad_cov_kernel_code = STRINGIFY( +static constexpr std::string gp_exp_quad_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of squared exponential kernel. @@ -51,7 +51,7 @@ const kernel_cl gp_exp_quad_cov("gp_exp_quad_cov", {gp_exp_quad_cov_kernel_code}); // \cond -static const std::string gp_exp_quad_cov_cross_kernel_code = STRINGIFY( +static constexpr std::string gp_exp_quad_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of squared exponential kernel. diff --git a/stan/math/opencl/kernels/gp_exponential_cov.hpp b/stan/math/opencl/kernels/gp_exponential_cov.hpp index 73afa4e8922..1ec3163c7fe 100644 --- a/stan/math/opencl/kernels/gp_exponential_cov.hpp +++ b/stan/math/opencl/kernels/gp_exponential_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string gp_exponential_cov_kernel_code = STRINGIFY( +static constexpr std::string gp_exponential_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern exponential kernel. @@ -53,7 +53,7 @@ const kernel_cl gp_exponential_cov("gp_exponential_cov", {gp_exponential_cov_kernel_code}); // \cond -static const std::string gp_exponential_cov_cross_kernel_code = STRINGIFY( +static constexpr std::string gp_exponential_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern exponential kernel. diff --git a/stan/math/opencl/kernels/gp_matern32_cov.hpp b/stan/math/opencl/kernels/gp_matern32_cov.hpp index e807e18aeee..ae44d64b39f 100644 --- a/stan/math/opencl/kernels/gp_matern32_cov.hpp +++ b/stan/math/opencl/kernels/gp_matern32_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string gp_matern32_cov_kernel_code = STRINGIFY( +static constexpr std::string gp_matern32_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 3/2 kernel. @@ -54,7 +54,7 @@ const kernel_cl gp_matern32_cov("gp_matern32_cov", {gp_matern32_cov_kernel_code}); // \cond -static const std::string gp_matern32_cov_cross_kernel_code = STRINGIFY( +static constexpr std::string gp_matern32_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 3/2 kernel. diff --git a/stan/math/opencl/kernels/gp_matern52_cov.hpp b/stan/math/opencl/kernels/gp_matern52_cov.hpp index d2cc63ac666..334ba9d25c3 100644 --- a/stan/math/opencl/kernels/gp_matern52_cov.hpp +++ b/stan/math/opencl/kernels/gp_matern52_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static const std::string gp_matern52_cov_kernel_code = STRINGIFY( +static constexpr std::string gp_matern52_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 5/2 kernel. @@ -56,7 +56,7 @@ const kernel_cl gp_matern52_cov("gp_matern52_cov", {gp_matern52_cov_kernel_code}); // \cond -static const std::string gp_matern52_cov_cross_kernel_code = STRINGIFY( +static constexpr std::string gp_matern52_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 5/2 kernel. diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index f4a601396e7..3c4e67f3439 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -13,7 +13,7 @@ namespace math { namespace opencl_kernels { // \cond -static const std::string indexing_rev_global_atomic_kernel_code = STRINGIFY( +static constexpr std::string indexing_rev_global_atomic_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * @@ -51,7 +51,7 @@ const kernel_cl indexing_rev_global_atomic_kernel_code}); // \cond -static const std::string indexing_rev_local_atomic_kernel_code = STRINGIFY( +static constexpr std::string indexing_rev_local_atomic_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * @@ -102,7 +102,7 @@ const kernel_cl; using MatrixXdd = Eigen::Matrix; -const double_d perturbation_range = 1e-20; +static constexpr double_d perturbation_range = 1e-20; /** * Generates a random number for perturbing a relatively robust representation @@ -29,8 +29,8 @@ const double_d perturbation_range = 1e-20; * / 2` and `1 + perturbation_range / 2`. */ inline double_d get_random_perturbation_multiplier() { - static const double_d rand_norm = perturbation_range / RAND_MAX; - static const double_d almost_one = 1 - perturbation_range * 0.5; + static constexpr double_d rand_norm = perturbation_range / RAND_MAX; + static constexpr double_d almost_one = 1 - perturbation_range * 0.5; return almost_one + std::rand() * rand_norm; } diff --git a/stan/math/opencl/prim/bernoulli_cdf.hpp b/stan/math/opencl/prim/bernoulli_cdf.hpp index 38e987f3b4d..2652317e7d5 100644 --- a/stan/math/opencl/prim/bernoulli_cdf.hpp +++ b/stan/math/opencl/prim/bernoulli_cdf.hpp @@ -29,7 +29,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t bernoulli_cdf(const T_n_cl& n, const T_prob_cl& theta) { - static const char* function = "bernoulli_cdf(OpenCL)"; + static constexpr const char* function = "bernoulli_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/bernoulli_lccdf.hpp b/stan/math/opencl/prim/bernoulli_lccdf.hpp index d2fd582b775..f290f32ac69 100644 --- a/stan/math/opencl/prim/bernoulli_lccdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lccdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t bernoulli_lccdf(const T_n_cl& n, const T_prob_cl& theta) { - static const char* function = "bernoulli_lccdf(OpenCL)"; + static constexpr const char* function = "bernoulli_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/bernoulli_lcdf.hpp b/stan/math/opencl/prim/bernoulli_lcdf.hpp index 30e42538f43..9306ddac122 100644 --- a/stan/math/opencl/prim/bernoulli_lcdf.hpp +++ b/stan/math/opencl/prim/bernoulli_lcdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t bernoulli_lcdf(const T_n_cl& n, const T_prob_cl& theta) { - static const char* function = "bernoulli_lcdf(OpenCL)"; + static constexpr const char* function = "bernoulli_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp b/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp index 9de5422b293..681e6482397 100644 --- a/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_logit_glm_lpmf.hpp @@ -56,7 +56,7 @@ template bernoulli_logit_glm_lpmf( const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta) { - static const char* function = "bernoulli_logit_glm_lpmf(OpenCL)"; + static constexpr const char* function = "bernoulli_logit_glm_lpmf(OpenCL)"; using T_partials_return = partials_return_t; constexpr bool is_y_vector = !is_stan_scalar::value; constexpr bool is_alpha_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp index accc947ab17..766f4a5afb1 100644 --- a/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_logit_lpmf.hpp @@ -28,7 +28,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t bernoulli_logit_lpmf(const T_n_cl& n, const T_prob_cl& theta) { - static const char* function = "bernoulli_logit_lpmf(OpenCL)"; + static constexpr const char* function = "bernoulli_logit_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; constexpr bool is_n_vector = !is_stan_scalar::value; @@ -57,7 +57,7 @@ return_type_t bernoulli_logit_lpmf(const T_n_cl& n, auto signs_expr = 2 * n - 1.0; // subtracting 1.0 converts int to double auto ntheta_expr = elt_multiply(signs_expr, theta_val); auto exp_m_ntheta_expr = exp(-ntheta_expr); - static const double cutoff = 20.0; + static constexpr double cutoff = 20.0; auto condition1_expr = ntheta_expr > cutoff; auto condition2_expr = ntheta_expr < -cutoff; auto logp_expr = colwise_sum( diff --git a/stan/math/opencl/prim/bernoulli_lpmf.hpp b/stan/math/opencl/prim/bernoulli_lpmf.hpp index ddbfb5e9074..89c3c8aaace 100644 --- a/stan/math/opencl/prim/bernoulli_lpmf.hpp +++ b/stan/math/opencl/prim/bernoulli_lpmf.hpp @@ -31,7 +31,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t bernoulli_lpmf(const T_n_cl& n, const T_prob_cl& theta) { - static const char* function = "bernoulli_lpmf(OpenCL)"; + static constexpr const char* function = "bernoulli_lpmf(OpenCL)"; using T_partials_return = partials_return_t; constexpr bool is_n_vector = !is_stan_scalar::value; constexpr bool is_theta_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/beta_binomial_lpmf.hpp b/stan/math/opencl/prim/beta_binomial_lpmf.hpp index df0e45397c9..c3e9a1c9c93 100644 --- a/stan/math/opencl/prim/beta_binomial_lpmf.hpp +++ b/stan/math/opencl/prim/beta_binomial_lpmf.hpp @@ -44,7 +44,7 @@ return_type_t beta_binomial_lpmf( const T_n_cl& n, const T_N_cl N, const T_size1_cl& alpha, const T_size2_cl& beta) { using std::isfinite; - static const char* function = "beta_binomial_lpmf(OpenCL)"; + static constexpr const char* function = "beta_binomial_lpmf(OpenCL)"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, diff --git a/stan/math/opencl/prim/beta_lpdf.hpp b/stan/math/opencl/prim/beta_lpdf.hpp index d1fe897c4ca..1ade2f1ce4b 100644 --- a/stan/math/opencl/prim/beta_lpdf.hpp +++ b/stan/math/opencl/prim/beta_lpdf.hpp @@ -44,7 +44,7 @@ return_type_t beta_lpdf( const T_y_cl& y, const T_scale_succ_cl& alpha, const T_scale_fail_cl& beta) { using std::isfinite; - static const char* function = "beta_lpdf(OpenCL)"; + static constexpr const char* function = "beta_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/beta_proportion_lpdf.hpp b/stan/math/opencl/prim/beta_proportion_lpdf.hpp index 480cb0bf3f9..4aaa334fb3b 100644 --- a/stan/math/opencl/prim/beta_proportion_lpdf.hpp +++ b/stan/math/opencl/prim/beta_proportion_lpdf.hpp @@ -41,7 +41,7 @@ template * = nullptr> return_type_t beta_proportion_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_prec_cl& kappa) { - static const char* function = "beta_proportion_lpdf(OpenCL)"; + static constexpr const char* function = "beta_proportion_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/binomial_logit_lpmf.hpp b/stan/math/opencl/prim/binomial_logit_lpmf.hpp index 72d0f67b344..fa45e0fc4f5 100644 --- a/stan/math/opencl/prim/binomial_logit_lpmf.hpp +++ b/stan/math/opencl/prim/binomial_logit_lpmf.hpp @@ -32,7 +32,7 @@ template * = nullptr> return_type_t binomial_logit_lpmf(const T_n_cl& n, const T_N_cl N, const T_prob_cl& alpha) { - static const char* function = "binomial_logit_lpmf(OpenCL)"; + static constexpr const char* function = "binomial_logit_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/binomial_lpmf.hpp b/stan/math/opencl/prim/binomial_lpmf.hpp index 6e4a0029f49..59142af4781 100644 --- a/stan/math/opencl/prim/binomial_lpmf.hpp +++ b/stan/math/opencl/prim/binomial_lpmf.hpp @@ -35,7 +35,7 @@ template * = nullptr> return_type_t binomial_lpmf(const T_n_cl& n, const T_N_cl N, const T_prob_cl& theta) { - static const char* function = "binomial_lpmf(OpenCL)"; + static constexpr const char* function = "binomial_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isnan; diff --git a/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp b/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp index baf4974f60d..83242f2c762 100644 --- a/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp +++ b/stan/math/opencl/prim/categorical_logit_glm_lpmf.hpp @@ -58,7 +58,7 @@ return_type_t categorical_logit_glm_lpmf( const size_t N_attributes = x.cols(); const size_t N_classes = beta.cols(); - static const char* function = "categorical_logit_glm_lpmf"; + static constexpr const char* function = "categorical_logit_glm_lpmf"; if (is_y_vector) { check_size_match(function, "Rows of ", "x", N_instances, "size of ", "y", math::size(y)); diff --git a/stan/math/opencl/prim/cauchy_cdf.hpp b/stan/math/opencl/prim/cauchy_cdf.hpp index f0b294aa0dd..d7938b21ac2 100644 --- a/stan/math/opencl/prim/cauchy_cdf.hpp +++ b/stan/math/opencl/prim/cauchy_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t cauchy_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "cauchy_cdf(OpenCL)"; + static constexpr const char* function = "cauchy_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/cauchy_lccdf.hpp b/stan/math/opencl/prim/cauchy_lccdf.hpp index 50b007b689e..73805a11fc3 100644 --- a/stan/math/opencl/prim/cauchy_lccdf.hpp +++ b/stan/math/opencl/prim/cauchy_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t cauchy_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "cauchy_lccdf(OpenCL)"; + static constexpr const char* function = "cauchy_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/cauchy_lcdf.hpp b/stan/math/opencl/prim/cauchy_lcdf.hpp index 6e32bab810b..aabaa9d3533 100644 --- a/stan/math/opencl/prim/cauchy_lcdf.hpp +++ b/stan/math/opencl/prim/cauchy_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t cauchy_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "cauchy_lcdf(OpenCL)"; + static constexpr const char* function = "cauchy_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/cauchy_lpdf.hpp b/stan/math/opencl/prim/cauchy_lpdf.hpp index 32a7e54f79b..6c418573a06 100644 --- a/stan/math/opencl/prim/cauchy_lpdf.hpp +++ b/stan/math/opencl/prim/cauchy_lpdf.hpp @@ -37,7 +37,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t cauchy_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "cauchy_lpdf(OpenCL)"; + static constexpr const char* function = "cauchy_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/chi_square_lpdf.hpp b/stan/math/opencl/prim/chi_square_lpdf.hpp index 38b4a562c71..af227e13242 100644 --- a/stan/math/opencl/prim/chi_square_lpdf.hpp +++ b/stan/math/opencl/prim/chi_square_lpdf.hpp @@ -37,7 +37,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t chi_square_lpdf(const T_y_cl& y, const T_dof_cl& nu) { - static const char* function = "chi_square_lpdf(OpenCL)"; + static constexpr const char* function = "chi_square_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/dirichlet_lpdf.hpp b/stan/math/opencl/prim/dirichlet_lpdf.hpp index d410c74cf07..41ebf2f92e6 100644 --- a/stan/math/opencl/prim/dirichlet_lpdf.hpp +++ b/stan/math/opencl/prim/dirichlet_lpdf.hpp @@ -60,7 +60,7 @@ template * = nullptr> inline return_type_t dirichlet_lpdf( const T_prob_cl& theta, const T_prior_size_cl& alpha) { - static const char* function = "dirichlet_lpdf(OpenCL)"; + static constexpr const char* function = "dirichlet_lpdf(OpenCL)"; check_consistent_sizes(function, "probabilities", theta, "prior sample sizes", alpha); diff --git a/stan/math/opencl/prim/double_exponential_cdf.hpp b/stan/math/opencl/prim/double_exponential_cdf.hpp index 401a1437533..75fe44f5ce9 100644 --- a/stan/math/opencl/prim/double_exponential_cdf.hpp +++ b/stan/math/opencl/prim/double_exponential_cdf.hpp @@ -32,7 +32,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t double_exponential_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "double_exponential_cdf(OpenCL)"; + static constexpr const char* function = "double_exponential_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/double_exponential_lccdf.hpp b/stan/math/opencl/prim/double_exponential_lccdf.hpp index 8ae38d12d99..8bf9b015162 100644 --- a/stan/math/opencl/prim/double_exponential_lccdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t double_exponential_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "double_exponential_lccdf(OpenCL)"; + static constexpr const char* function = "double_exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/double_exponential_lcdf.hpp b/stan/math/opencl/prim/double_exponential_lcdf.hpp index 39a9a877cc9..aa58d6ab739 100644 --- a/stan/math/opencl/prim/double_exponential_lcdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lcdf.hpp @@ -32,7 +32,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t double_exponential_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "double_exponential_lcdf(OpenCL)"; + static constexpr const char* function = "double_exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/double_exponential_lpdf.hpp b/stan/math/opencl/prim/double_exponential_lpdf.hpp index 1078d070719..9816b7ae6d5 100644 --- a/stan/math/opencl/prim/double_exponential_lpdf.hpp +++ b/stan/math/opencl/prim/double_exponential_lpdf.hpp @@ -35,7 +35,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t double_exponential_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "double_exponential_lpdf(OpenCL)"; + static constexpr const char* function = "double_exponential_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/exp_mod_normal_cdf.hpp b/stan/math/opencl/prim/exp_mod_normal_cdf.hpp index 0aa1f9b3085..4436ab4c8c3 100644 --- a/stan/math/opencl/prim/exp_mod_normal_cdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_cdf.hpp @@ -36,7 +36,7 @@ template exp_mod_normal_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { - static const char* function = "exp_mod_normal_cdf(OpenCL)"; + static constexpr const char* function = "exp_mod_normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp index 8f2425a0bf1..8d8d2ab1a4e 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lccdf.hpp @@ -37,7 +37,7 @@ template exp_mod_normal_lccdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { - static const char* function = "exp_mod_normal_lccdf(OpenCL)"; + static constexpr const char* function = "exp_mod_normal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp index 181f2cf8466..1ec9fb10e68 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lcdf.hpp @@ -37,7 +37,7 @@ template exp_mod_normal_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { - static const char* function = "exp_mod_normal_lcdf(OpenCL)"; + static constexpr const char* function = "exp_mod_normal_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp b/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp index 8c0f603f503..7e3696fb449 100644 --- a/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp +++ b/stan/math/opencl/prim/exp_mod_normal_lpdf.hpp @@ -39,7 +39,7 @@ template exp_mod_normal_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_inv_scale_cl& lambda) { - static const char* function = "exp_mod_normal_lpdf(OpenCL)"; + static constexpr const char* function = "exp_mod_normal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/exponential_cdf.hpp b/stan/math/opencl/prim/exponential_cdf.hpp index 85f94454b9b..9111054186d 100644 --- a/stan/math/opencl/prim/exponential_cdf.hpp +++ b/stan/math/opencl/prim/exponential_cdf.hpp @@ -32,7 +32,7 @@ template * = nullptr> return_type_t exponential_cdf( const T_y_cl& y, const T_inv_scale_cl& beta) { - static const char* function = "exponential_cdf(OpenCL)"; + static constexpr const char* function = "exponential_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/exponential_lccdf.hpp b/stan/math/opencl/prim/exponential_lccdf.hpp index 60b2662d4dc..1e1a9984bb5 100644 --- a/stan/math/opencl/prim/exponential_lccdf.hpp +++ b/stan/math/opencl/prim/exponential_lccdf.hpp @@ -32,7 +32,7 @@ template * = nullptr> return_type_t exponential_lccdf( const T_y_cl& y, const T_inv_scale_cl& beta) { - static const char* function = "exponential_lccdf(OpenCL)"; + static constexpr const char* function = "exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/exponential_lcdf.hpp b/stan/math/opencl/prim/exponential_lcdf.hpp index 6f3802eb7c0..1da6473b12d 100644 --- a/stan/math/opencl/prim/exponential_lcdf.hpp +++ b/stan/math/opencl/prim/exponential_lcdf.hpp @@ -32,7 +32,7 @@ template * = nullptr> return_type_t exponential_lcdf( const T_y_cl& y, const T_inv_scale_cl& beta) { - static const char* function = "exponential_lcdf(OpenCL)"; + static constexpr const char* function = "exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/exponential_lpdf.hpp b/stan/math/opencl/prim/exponential_lpdf.hpp index 685645bb9ad..d31ee5e9eb5 100644 --- a/stan/math/opencl/prim/exponential_lpdf.hpp +++ b/stan/math/opencl/prim/exponential_lpdf.hpp @@ -47,7 +47,7 @@ template exponential_lpdf( const T_y_cl& y, const T_inv_scale_cl& beta) { using std::isfinite; - static const char* function = "exponential_lpdf(OpenCL)"; + static constexpr const char* function = "exponential_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, diff --git a/stan/math/opencl/prim/frechet_cdf.hpp b/stan/math/opencl/prim/frechet_cdf.hpp index 24e266885d4..9053f84411f 100644 --- a/stan/math/opencl/prim/frechet_cdf.hpp +++ b/stan/math/opencl/prim/frechet_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t frechet_cdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "frechet_cdf(OpenCL)"; + static constexpr const char* function = "frechet_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/frechet_lccdf.hpp b/stan/math/opencl/prim/frechet_lccdf.hpp index 789eb51cac6..0d6bf5dccd7 100644 --- a/stan/math/opencl/prim/frechet_lccdf.hpp +++ b/stan/math/opencl/prim/frechet_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t frechet_lccdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "frechet_lccdf(OpenCL)"; + static constexpr const char* function = "frechet_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/frechet_lcdf.hpp b/stan/math/opencl/prim/frechet_lcdf.hpp index 4dc9034119b..966ffd36b41 100644 --- a/stan/math/opencl/prim/frechet_lcdf.hpp +++ b/stan/math/opencl/prim/frechet_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t frechet_lcdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "frechet_lcdf(OpenCL)"; + static constexpr const char* function = "frechet_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/frechet_lpdf.hpp b/stan/math/opencl/prim/frechet_lpdf.hpp index 9a6c125b56a..9143d2df036 100644 --- a/stan/math/opencl/prim/frechet_lpdf.hpp +++ b/stan/math/opencl/prim/frechet_lpdf.hpp @@ -39,7 +39,7 @@ template < return_type_t frechet_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { using std::isfinite; - static const char* function = "frechet_lpdf(OpenCL)"; + static constexpr const char* function = "frechet_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Shape parameter", diff --git a/stan/math/opencl/prim/gamma_lpdf.hpp b/stan/math/opencl/prim/gamma_lpdf.hpp index 9f7c1ad0635..f803143142c 100644 --- a/stan/math/opencl/prim/gamma_lpdf.hpp +++ b/stan/math/opencl/prim/gamma_lpdf.hpp @@ -48,7 +48,7 @@ return_type_t gamma_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_inv_scale_cl& beta) { using std::isfinite; using std::isnan; - static const char* function = "gamma_lpdf(OpenCL)"; + static constexpr const char* function = "gamma_lpdf(OpenCL)"; using T_partials_return = partials_return_t; diff --git a/stan/math/opencl/prim/gumbel_cdf.hpp b/stan/math/opencl/prim/gumbel_cdf.hpp index da5eabc2b9b..31066db055e 100644 --- a/stan/math/opencl/prim/gumbel_cdf.hpp +++ b/stan/math/opencl/prim/gumbel_cdf.hpp @@ -34,7 +34,7 @@ template < return_type_t gumbel_cdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { - static const char* function = "gumbel_cdf(OpenCL)"; + static constexpr const char* function = "gumbel_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/gumbel_lccdf.hpp b/stan/math/opencl/prim/gumbel_lccdf.hpp index 31b2a1310e0..f4ce5089ac4 100644 --- a/stan/math/opencl/prim/gumbel_lccdf.hpp +++ b/stan/math/opencl/prim/gumbel_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t gumbel_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { - static const char* function = "gumbel_lccdf(OpenCL)"; + static constexpr const char* function = "gumbel_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/gumbel_lcdf.hpp b/stan/math/opencl/prim/gumbel_lcdf.hpp index fa2e5d8c9c4..0de17c0f4b1 100644 --- a/stan/math/opencl/prim/gumbel_lcdf.hpp +++ b/stan/math/opencl/prim/gumbel_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t gumbel_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { - static const char* function = "gumbel_lcdf(OpenCL)"; + static constexpr const char* function = "gumbel_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/gumbel_lpdf.hpp b/stan/math/opencl/prim/gumbel_lpdf.hpp index 683e5e1c08e..9f706900abd 100644 --- a/stan/math/opencl/prim/gumbel_lpdf.hpp +++ b/stan/math/opencl/prim/gumbel_lpdf.hpp @@ -37,7 +37,7 @@ return_type_t gumbel_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& beta) { using std::isfinite; using std::isnan; - static const char* function = "gumbel_lpdf(OpenCL)"; + static constexpr const char* function = "gumbel_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/opencl/prim/inv_chi_square_lpdf.hpp b/stan/math/opencl/prim/inv_chi_square_lpdf.hpp index ad680fa8cfe..09c7e8c34cd 100644 --- a/stan/math/opencl/prim/inv_chi_square_lpdf.hpp +++ b/stan/math/opencl/prim/inv_chi_square_lpdf.hpp @@ -45,7 +45,7 @@ return_type_t inv_chi_square_lpdf(const T_y_cl& y, const T_dof_cl& nu) { using std::isfinite; using std::isnan; - static const char* function = "inv_chi_square_lpdf(OpenCL)"; + static constexpr const char* function = "inv_chi_square_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, diff --git a/stan/math/opencl/prim/inv_gamma_lpdf.hpp b/stan/math/opencl/prim/inv_gamma_lpdf.hpp index a13f6fc872a..57dedb52a99 100644 --- a/stan/math/opencl/prim/inv_gamma_lpdf.hpp +++ b/stan/math/opencl/prim/inv_gamma_lpdf.hpp @@ -40,7 +40,7 @@ return_type_t inv_gamma_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& beta) { using std::isfinite; using std::isnan; - static const char* function = "inv_gamma_lpdf(OpenCL)"; + static constexpr const char* function = "inv_gamma_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, diff --git a/stan/math/opencl/prim/log_mix.hpp b/stan/math/opencl/prim/log_mix.hpp index 6a4290ed393..188ae45e8b7 100644 --- a/stan/math/opencl/prim/log_mix.hpp +++ b/stan/math/opencl/prim/log_mix.hpp @@ -37,7 +37,7 @@ template * = nullptr> inline auto log_mix(const T_theta_cl& theta, const T_lambda_cl& lambda) { - static const char* function = "log_mix(OpenCL)"; + static constexpr const char* function = "log_mix(OpenCL)"; using T_return = return_type_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/logistic_cdf.hpp b/stan/math/opencl/prim/logistic_cdf.hpp index b352c7f200c..aa07b81d3a1 100644 --- a/stan/math/opencl/prim/logistic_cdf.hpp +++ b/stan/math/opencl/prim/logistic_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t logistic_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "logistic_cdf(OpenCL)"; + static constexpr const char* function = "logistic_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/logistic_lccdf.hpp b/stan/math/opencl/prim/logistic_lccdf.hpp index e1b9959a69a..db5dd37209c 100644 --- a/stan/math/opencl/prim/logistic_lccdf.hpp +++ b/stan/math/opencl/prim/logistic_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t logistic_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "logistic_lccdf(OpenCL)"; + static constexpr const char* function = "logistic_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/logistic_lcdf.hpp b/stan/math/opencl/prim/logistic_lcdf.hpp index b9e9f1f954f..c8d4d2741fb 100644 --- a/stan/math/opencl/prim/logistic_lcdf.hpp +++ b/stan/math/opencl/prim/logistic_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t logistic_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "logistic_lcdf(OpenCL)"; + static constexpr const char* function = "logistic_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/logistic_lpdf.hpp b/stan/math/opencl/prim/logistic_lpdf.hpp index 31b19b1177d..c5c816e712b 100644 --- a/stan/math/opencl/prim/logistic_lpdf.hpp +++ b/stan/math/opencl/prim/logistic_lpdf.hpp @@ -39,7 +39,7 @@ template < return_type_t logistic_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { using std::isfinite; - static const char* function = "logistic_lpdf(OpenCL)"; + static constexpr const char* function = "logistic_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/opencl/prim/lognormal_cdf.hpp b/stan/math/opencl/prim/lognormal_cdf.hpp index 96f0b5a0743..17380192558 100644 --- a/stan/math/opencl/prim/lognormal_cdf.hpp +++ b/stan/math/opencl/prim/lognormal_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t lognormal_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "lognormal_cdf(OpenCL)"; + static constexpr const char* function = "lognormal_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/lognormal_lccdf.hpp b/stan/math/opencl/prim/lognormal_lccdf.hpp index a300b686540..79a1c31eb8d 100644 --- a/stan/math/opencl/prim/lognormal_lccdf.hpp +++ b/stan/math/opencl/prim/lognormal_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t lognormal_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "lognormal_lccdf(OpenCL)"; + static constexpr const char* function = "lognormal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/lognormal_lcdf.hpp b/stan/math/opencl/prim/lognormal_lcdf.hpp index 0ccc7ccac91..31503d3b488 100644 --- a/stan/math/opencl/prim/lognormal_lcdf.hpp +++ b/stan/math/opencl/prim/lognormal_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t lognormal_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "lognormal_lcdf(OpenCL)"; + static constexpr const char* function = "lognormal_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/lognormal_lpdf.hpp b/stan/math/opencl/prim/lognormal_lpdf.hpp index 522d48b3c45..fc55000bec7 100644 --- a/stan/math/opencl/prim/lognormal_lpdf.hpp +++ b/stan/math/opencl/prim/lognormal_lpdf.hpp @@ -40,7 +40,7 @@ template < return_type_t lognormal_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { using std::isfinite; - static const char* function = "lognormal_lpdf(OpenCL)"; + static constexpr const char* function = "lognormal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Location parameter", diff --git a/stan/math/opencl/prim/multi_normal_cholesky_lpdf.hpp b/stan/math/opencl/prim/multi_normal_cholesky_lpdf.hpp index 21cb0cfa678..068329d1709 100644 --- a/stan/math/opencl/prim/multi_normal_cholesky_lpdf.hpp +++ b/stan/math/opencl/prim/multi_normal_cholesky_lpdf.hpp @@ -41,7 +41,7 @@ template * = nullptr> inline return_type_t multi_normal_cholesky_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_covar_cl& L) { - static const char* function = "multi_normal_cholesky_lpdf(OpenCL)"; + static constexpr const char* function = "multi_normal_cholesky_lpdf(OpenCL)"; check_consistent_sizes(function, "y", y, "mu", mu); check_square(function, "covariance parameter", L); diff --git a/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp b/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp index 1bfec8258b6..973d63b0ba6 100644 --- a/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp +++ b/stan/math/opencl/prim/neg_binomial_2_log_glm_lpmf.hpp @@ -69,7 +69,7 @@ return_type_t neg_binomial_2_log_glm_lpmf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta, const T_phi_cl& phi) { - static const char* function = "neg_binomial_2_log_glm_lpmf(OpenCL)"; + static constexpr const char* function = "neg_binomial_2_log_glm_lpmf(OpenCL)"; using T_partials_return = partials_return_t; constexpr bool is_y_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/neg_binomial_2_log_lpmf.hpp b/stan/math/opencl/prim/neg_binomial_2_log_lpmf.hpp index 91a8a80f612..5016acaac1d 100644 --- a/stan/math/opencl/prim/neg_binomial_2_log_lpmf.hpp +++ b/stan/math/opencl/prim/neg_binomial_2_log_lpmf.hpp @@ -42,7 +42,7 @@ template neg_binomial_2_log_lpmf(const T_n_cl& n, const T_log_location_cl& eta, const T_precision_cl& phi) { - static const char* function = "neg_binomial_2_log_lpmf(OpenCL)"; + static constexpr const char* function = "neg_binomial_2_log_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/neg_binomial_2_lpmf.hpp b/stan/math/opencl/prim/neg_binomial_2_lpmf.hpp index a64ad66115c..97eba8288d4 100644 --- a/stan/math/opencl/prim/neg_binomial_2_lpmf.hpp +++ b/stan/math/opencl/prim/neg_binomial_2_lpmf.hpp @@ -41,7 +41,7 @@ template * = nullptr> inline return_type_t neg_binomial_2_lpmf( const T_n_cl& n, const T_location_cl& mu, const T_precision_cl& phi) { - static const char* function = "neg_binomial_2_lpmf(OpenCL)"; + static constexpr const char* function = "neg_binomial_2_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/neg_binomial_lpmf.hpp b/stan/math/opencl/prim/neg_binomial_lpmf.hpp index 9f65096c765..0041fc574d6 100644 --- a/stan/math/opencl/prim/neg_binomial_lpmf.hpp +++ b/stan/math/opencl/prim/neg_binomial_lpmf.hpp @@ -39,7 +39,7 @@ template * = nullptr> inline return_type_t neg_binomial_lpmf( const T_n_cl& n, const T_shape_cl& alpha, const T_inv_scale_cl& beta) { - static const char* function = "neg_binomial_lpmf(OpenCL)"; + static constexpr const char* function = "neg_binomial_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/normal_cdf.hpp b/stan/math/opencl/prim/normal_cdf.hpp index 2f8e2292498..5f7358fadcc 100644 --- a/stan/math/opencl/prim/normal_cdf.hpp +++ b/stan/math/opencl/prim/normal_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t normal_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "normal_cdf(OpenCL)"; + static constexpr const char* function = "normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/normal_id_glm_lpdf.hpp b/stan/math/opencl/prim/normal_id_glm_lpdf.hpp index b999c25e535..86feca3e624 100644 --- a/stan/math/opencl/prim/normal_id_glm_lpdf.hpp +++ b/stan/math/opencl/prim/normal_id_glm_lpdf.hpp @@ -68,7 +68,7 @@ normal_id_glm_lpdf(const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, constexpr bool is_sigma_vector = !is_stan_scalar::value; constexpr bool is_alpha_vector = !is_stan_scalar::value; using std::isfinite; - static const char* function = "normal_id_glm_lpdf(OpenCL)"; + static constexpr const char* function = "normal_id_glm_lpdf(OpenCL)"; const size_t N = x.rows(); const size_t M = x.cols(); diff --git a/stan/math/opencl/prim/normal_lccdf.hpp b/stan/math/opencl/prim/normal_lccdf.hpp index 94793109064..df4e77389a3 100644 --- a/stan/math/opencl/prim/normal_lccdf.hpp +++ b/stan/math/opencl/prim/normal_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t normal_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "normal_lccdf(OpenCL)"; + static constexpr const char* function = "normal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/normal_lcdf.hpp b/stan/math/opencl/prim/normal_lcdf.hpp index 15ef55cedac..12d7122cda9 100644 --- a/stan/math/opencl/prim/normal_lcdf.hpp +++ b/stan/math/opencl/prim/normal_lcdf.hpp @@ -179,7 +179,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t normal_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "normal_lcdf(OpenCL)"; + static constexpr const char* function = "normal_lcdf(OpenCL)"; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/normal_lpdf.hpp b/stan/math/opencl/prim/normal_lpdf.hpp index dfe2f6ebf0a..4e8b5dfda0a 100644 --- a/stan/math/opencl/prim/normal_lpdf.hpp +++ b/stan/math/opencl/prim/normal_lpdf.hpp @@ -39,7 +39,7 @@ template < require_any_not_stan_scalar_t* = nullptr> inline return_type_t normal_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "normal_lpdf(OpenCL)"; + static constexpr const char* function = "normal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp b/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp index 5f5912b2328..fcdbe0f078f 100644 --- a/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/opencl/prim/ordered_logistic_glm_lpmf.hpp @@ -59,7 +59,7 @@ return_type_t ordered_logistic_glm_lpmf( using T_partials_return = partials_return_t; constexpr bool is_y_vector = !is_stan_scalar::value; - static const char* function = "ordered_logistic_glm_lpmf"; + static constexpr const char* function = "ordered_logistic_glm_lpmf"; const size_t N_instances = x.rows(); const size_t N_attributes = x.cols(); diff --git a/stan/math/opencl/prim/ordered_logistic_lpmf.hpp b/stan/math/opencl/prim/ordered_logistic_lpmf.hpp index 9e248340335..4a628c191ca 100644 --- a/stan/math/opencl/prim/ordered_logistic_lpmf.hpp +++ b/stan/math/opencl/prim/ordered_logistic_lpmf.hpp @@ -70,7 +70,7 @@ template ordered_logistic_lpmf( const T_y_cl& y, const T_loc_cl& lambda, const T_cuts_cl& cuts) { constexpr bool is_y_vector = !is_stan_scalar::value; - static const char* function = "ordered_logistic_lpmf(OpenCL)"; + static constexpr const char* function = "ordered_logistic_lpmf(OpenCL)"; if (size(y) != 1) { check_size_match(function, "Size of ", "y", math::size(y), "Size of", diff --git a/stan/math/opencl/prim/pareto_cdf.hpp b/stan/math/opencl/prim/pareto_cdf.hpp index 7f8b1d83003..cf4956bc26a 100644 --- a/stan/math/opencl/prim/pareto_cdf.hpp +++ b/stan/math/opencl/prim/pareto_cdf.hpp @@ -32,7 +32,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t pareto_cdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { - static const char* function = "pareto_cdf(OpenCL)"; + static constexpr const char* function = "pareto_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/pareto_lccdf.hpp b/stan/math/opencl/prim/pareto_lccdf.hpp index a048719a5a3..c548160cfd6 100644 --- a/stan/math/opencl/prim/pareto_lccdf.hpp +++ b/stan/math/opencl/prim/pareto_lccdf.hpp @@ -32,7 +32,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t pareto_lccdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { - static const char* function = "pareto_lccdf(OpenCL)"; + static constexpr const char* function = "pareto_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isinf; diff --git a/stan/math/opencl/prim/pareto_lcdf.hpp b/stan/math/opencl/prim/pareto_lcdf.hpp index 9835e336313..005a7b71725 100644 --- a/stan/math/opencl/prim/pareto_lcdf.hpp +++ b/stan/math/opencl/prim/pareto_lcdf.hpp @@ -32,7 +32,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t pareto_lcdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { - static const char* function = "pareto_lcdf(OpenCL)"; + static constexpr const char* function = "pareto_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isinf; diff --git a/stan/math/opencl/prim/pareto_lpdf.hpp b/stan/math/opencl/prim/pareto_lpdf.hpp index 5ccd2cd14f9..f204d59b058 100644 --- a/stan/math/opencl/prim/pareto_lpdf.hpp +++ b/stan/math/opencl/prim/pareto_lpdf.hpp @@ -37,7 +37,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t pareto_lpdf( const T_y_cl& y, const T_scale_cl& y_min, const T_shape_cl& alpha) { - static const char* function = "pareto_lpdf(OpenCL)"; + static constexpr const char* function = "pareto_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/pareto_type_2_cdf.hpp b/stan/math/opencl/prim/pareto_type_2_cdf.hpp index ae39b84a47c..4dc1e120589 100644 --- a/stan/math/opencl/prim/pareto_type_2_cdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_cdf.hpp @@ -36,7 +36,7 @@ template pareto_type_2_cdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, const T_shape_cl& alpha) { - static const char* function = "pareto_type_2_cdf(OpenCL)"; + static constexpr const char* function = "pareto_type_2_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/pareto_type_2_lccdf.hpp b/stan/math/opencl/prim/pareto_type_2_lccdf.hpp index 11e85783945..18dadd91786 100644 --- a/stan/math/opencl/prim/pareto_type_2_lccdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lccdf.hpp @@ -36,7 +36,7 @@ template pareto_type_2_lccdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, const T_shape_cl& alpha) { - static const char* function = "pareto_type_2_lccdf(OpenCL)"; + static constexpr const char* function = "pareto_type_2_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/pareto_type_2_lcdf.hpp b/stan/math/opencl/prim/pareto_type_2_lcdf.hpp index 376ff2c698c..3cfa71ea534 100644 --- a/stan/math/opencl/prim/pareto_type_2_lcdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lcdf.hpp @@ -36,7 +36,7 @@ template pareto_type_2_lcdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, const T_shape_cl& alpha) { - static const char* function = "pareto_type_2_lcdf(OpenCL)"; + static constexpr const char* function = "pareto_type_2_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/pareto_type_2_lpdf.hpp b/stan/math/opencl/prim/pareto_type_2_lpdf.hpp index 5e567cfe2e0..ce0b4384982 100644 --- a/stan/math/opencl/prim/pareto_type_2_lpdf.hpp +++ b/stan/math/opencl/prim/pareto_type_2_lpdf.hpp @@ -39,7 +39,7 @@ template pareto_type_2_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& lambda, const T_shape_cl& alpha) { - static const char* function = "pareto_type_2_lpdf(OpenCL)"; + static constexpr const char* function = "pareto_type_2_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp b/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp index c6b730e7644..065d9ce896b 100644 --- a/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_log_glm_lpmf.hpp @@ -54,7 +54,7 @@ template poisson_log_glm_lpmf( const T_y_cl& y, const T_x_cl& x, const T_alpha_cl& alpha, const T_beta_cl& beta) { - static const char* function = "poisson_log_glm_lpmf(OpenCL)"; + static constexpr const char* function = "poisson_log_glm_lpmf(OpenCL)"; using T_partials_return = partials_return_t; constexpr bool is_y_vector = !is_stan_scalar::value; constexpr bool is_alpha_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/poisson_log_lpmf.hpp b/stan/math/opencl/prim/poisson_log_lpmf.hpp index 31ed3dfaecd..db3bb86f61d 100644 --- a/stan/math/opencl/prim/poisson_log_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_log_lpmf.hpp @@ -30,7 +30,7 @@ template * = nullptr> return_type_t poisson_log_lpmf(const T_n_cl& n, const T_log_rate_cl& alpha) { - static const char* function = "poisson_log_lpmf(OpenCL)"; + static constexpr const char* function = "poisson_log_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isinf; using std::isnan; diff --git a/stan/math/opencl/prim/poisson_lpmf.hpp b/stan/math/opencl/prim/poisson_lpmf.hpp index 2878e9d2849..2e4c30cd2cf 100644 --- a/stan/math/opencl/prim/poisson_lpmf.hpp +++ b/stan/math/opencl/prim/poisson_lpmf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t poisson_lpmf(const T_n_cl& n, const T_rate_cl& lambda) { - static const char* function = "poisson_lpmf(OpenCL)"; + static constexpr const char* function = "poisson_lpmf(OpenCL)"; using T_partials_return = partials_return_t; using std::isinf; constexpr bool is_n_vector = !is_stan_scalar::value; diff --git a/stan/math/opencl/prim/rayleigh_cdf.hpp b/stan/math/opencl/prim/rayleigh_cdf.hpp index edccadd8256..cb111c223c9 100644 --- a/stan/math/opencl/prim/rayleigh_cdf.hpp +++ b/stan/math/opencl/prim/rayleigh_cdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t rayleigh_cdf(const T_y_cl& y, const T_scale_cl& sigma) { - static const char* function = "rayleigh_cdf(OpenCL)"; + static constexpr const char* function = "rayleigh_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/rayleigh_lccdf.hpp b/stan/math/opencl/prim/rayleigh_lccdf.hpp index 30168b94f3f..6384f938eb9 100644 --- a/stan/math/opencl/prim/rayleigh_lccdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lccdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t rayleigh_lccdf(const T_y_cl& y, const T_scale_cl& sigma) { - static const char* function = "rayleigh_lccdf(OpenCL)"; + static constexpr const char* function = "rayleigh_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/rayleigh_lcdf.hpp b/stan/math/opencl/prim/rayleigh_lcdf.hpp index de3c9301454..d1b820ceaf1 100644 --- a/stan/math/opencl/prim/rayleigh_lcdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lcdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t rayleigh_lcdf(const T_y_cl& y, const T_scale_cl& sigma) { - static const char* function = "rayleigh_lcdf(OpenCL)"; + static constexpr const char* function = "rayleigh_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/rayleigh_lpdf.hpp b/stan/math/opencl/prim/rayleigh_lpdf.hpp index 5aa058b5d5c..28229526937 100644 --- a/stan/math/opencl/prim/rayleigh_lpdf.hpp +++ b/stan/math/opencl/prim/rayleigh_lpdf.hpp @@ -30,7 +30,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t rayleigh_lpdf(const T_y_cl& y, const T_scale_cl& sigma) { - static const char* function = "rayleigh_lpdf(OpenCL)"; + static constexpr const char* function = "rayleigh_lpdf(OpenCL)"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Scale parameter", diff --git a/stan/math/opencl/prim/scaled_inv_chi_square_lpdf.hpp b/stan/math/opencl/prim/scaled_inv_chi_square_lpdf.hpp index 8f3e1bd22ef..768248df815 100644 --- a/stan/math/opencl/prim/scaled_inv_chi_square_lpdf.hpp +++ b/stan/math/opencl/prim/scaled_inv_chi_square_lpdf.hpp @@ -42,7 +42,7 @@ template < require_any_not_stan_scalar_t* = nullptr> inline return_type_t scaled_inv_chi_square_lpdf( const T_y_cl& y, const T_dof_cl& nu, const T_scale_cl& s) { - static const char* function = "scaled_inv_chi_square_lpdf(OpenCL)"; + static constexpr const char* function = "scaled_inv_chi_square_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/skew_double_exponential_cdf.hpp b/stan/math/opencl/prim/skew_double_exponential_cdf.hpp index 3f477719398..a888945c48c 100644 --- a/stan/math/opencl/prim/skew_double_exponential_cdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_cdf.hpp @@ -36,7 +36,7 @@ template skew_double_exponential_cdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static const char* function = "skew_double_exponential_cdf(OpenCL)"; + static constexpr const char* function = "skew_double_exponential_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp index c8fa3c5e9f4..e9937280919 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp @@ -37,7 +37,7 @@ return_type_t skew_double_exponential_lccdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static const char* function = "skew_double_exponential_lccdf(OpenCL)"; + static constexpr const char* function = "skew_double_exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp index a547e711e2a..af07bb52f4a 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp @@ -37,7 +37,7 @@ return_type_t skew_double_exponential_lcdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static const char* function = "skew_double_exponential_lcdf(OpenCL)"; + static constexpr const char* function = "skew_double_exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp index 2aa68aa60ac..3d5096714e2 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp @@ -40,7 +40,7 @@ return_type_t skew_double_exponential_lpdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static const char* function = "skew_double_exponential_lpdf(OpenCL)"; + static constexpr const char* function = "skew_double_exponential_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_normal_lpdf.hpp b/stan/math/opencl/prim/skew_normal_lpdf.hpp index 2d781ee151d..2d355bb9111 100644 --- a/stan/math/opencl/prim/skew_normal_lpdf.hpp +++ b/stan/math/opencl/prim/skew_normal_lpdf.hpp @@ -42,7 +42,7 @@ template skew_normal_lpdf( const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_shape_cl& alpha) { - static const char* function = "skew_normal_lpdf(OpenCL)"; + static constexpr const char* function = "skew_normal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/std_normal_cdf.hpp b/stan/math/opencl/prim/std_normal_cdf.hpp index 739d496780b..9a624213c8e 100644 --- a/stan/math/opencl/prim/std_normal_cdf.hpp +++ b/stan/math/opencl/prim/std_normal_cdf.hpp @@ -24,7 +24,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> return_type_t std_normal_cdf(const T_y_cl& y) { - static const char* function = "std_normal_cdf(OpenCL)"; + static constexpr const char* function = "std_normal_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/std_normal_lccdf.hpp b/stan/math/opencl/prim/std_normal_lccdf.hpp index 1e531fdaf0f..89973bda5f2 100644 --- a/stan/math/opencl/prim/std_normal_lccdf.hpp +++ b/stan/math/opencl/prim/std_normal_lccdf.hpp @@ -25,7 +25,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> return_type_t std_normal_lccdf(const T_y_cl& y) { - static const char* function = "std_normal_lccdf(OpenCL)"; + static constexpr const char* function = "std_normal_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/std_normal_lcdf.hpp b/stan/math/opencl/prim/std_normal_lcdf.hpp index 86966cf7a60..ec8d9f38949 100644 --- a/stan/math/opencl/prim/std_normal_lcdf.hpp +++ b/stan/math/opencl/prim/std_normal_lcdf.hpp @@ -179,7 +179,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> return_type_t std_normal_lcdf(const T_y_cl& y) { - static const char* function = "std_normal_lcdf(OpenCL)"; + static constexpr const char* function = "std_normal_lcdf(OpenCL)"; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/std_normal_lpdf.hpp b/stan/math/opencl/prim/std_normal_lpdf.hpp index 2bf4de436c1..a1cafc3d983 100644 --- a/stan/math/opencl/prim/std_normal_lpdf.hpp +++ b/stan/math/opencl/prim/std_normal_lpdf.hpp @@ -30,7 +30,7 @@ template * = nullptr, require_any_not_stan_scalar_t* = nullptr> inline return_type_t std_normal_lpdf(const T_y_cl& y) { - static const char* function = "std_normal_lpdf(OpenCL)"; + static constexpr const char* function = "std_normal_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/student_t_lpdf.hpp b/stan/math/opencl/prim/student_t_lpdf.hpp index f6877abf320..3aabb46198c 100644 --- a/stan/math/opencl/prim/student_t_lpdf.hpp +++ b/stan/math/opencl/prim/student_t_lpdf.hpp @@ -51,7 +51,7 @@ template student_t_lpdf( const T_y_cl& y, const T_dof_cl& nu, const T_loc_cl& mu, const T_scale_cl& sigma) { - static const char* function = "student_t_lpdf(OpenCL)"; + static constexpr const char* function = "student_t_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/uniform_cdf.hpp b/stan/math/opencl/prim/uniform_cdf.hpp index a5a4fe44743..b41f87fb45d 100644 --- a/stan/math/opencl/prim/uniform_cdf.hpp +++ b/stan/math/opencl/prim/uniform_cdf.hpp @@ -33,7 +33,7 @@ template uniform_cdf(const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { - static const char* function = "uniform_cdf(OpenCL)"; + static constexpr const char* function = "uniform_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/uniform_lccdf.hpp b/stan/math/opencl/prim/uniform_lccdf.hpp index 512fa986bcf..bff5ef73ee9 100644 --- a/stan/math/opencl/prim/uniform_lccdf.hpp +++ b/stan/math/opencl/prim/uniform_lccdf.hpp @@ -32,7 +32,7 @@ template * = nullptr> return_type_t uniform_lccdf( const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { - static const char* function = "uniform_lccdf(OpenCL)"; + static constexpr const char* function = "uniform_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/uniform_lcdf.hpp b/stan/math/opencl/prim/uniform_lcdf.hpp index 3845c7345ab..a39d40bae27 100644 --- a/stan/math/opencl/prim/uniform_lcdf.hpp +++ b/stan/math/opencl/prim/uniform_lcdf.hpp @@ -33,7 +33,7 @@ template uniform_lcdf(const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { - static const char* function = "uniform_lcdf(OpenCL)"; + static constexpr const char* function = "uniform_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/uniform_lpdf.hpp b/stan/math/opencl/prim/uniform_lpdf.hpp index c486d2e9e1b..58b4d81a984 100644 --- a/stan/math/opencl/prim/uniform_lpdf.hpp +++ b/stan/math/opencl/prim/uniform_lpdf.hpp @@ -41,7 +41,7 @@ template * = nullptr> inline return_type_t uniform_lpdf( const T_y_cl& y, const T_low_cl& alpha, const T_high_cl& beta) { - static const char* function = "uniform_lpdf(OpenCL)"; + static constexpr const char* function = "uniform_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/weibull_cdf.hpp b/stan/math/opencl/prim/weibull_cdf.hpp index 4a6a0b9fcb8..94dd44b7cf9 100644 --- a/stan/math/opencl/prim/weibull_cdf.hpp +++ b/stan/math/opencl/prim/weibull_cdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t weibull_cdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "weibull_cdf(OpenCL)"; + static constexpr const char* function = "weibull_cdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/weibull_lccdf.hpp b/stan/math/opencl/prim/weibull_lccdf.hpp index b3b05dd4840..909b3e9b5f6 100644 --- a/stan/math/opencl/prim/weibull_lccdf.hpp +++ b/stan/math/opencl/prim/weibull_lccdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t weibull_lccdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "weibull_lccdf(OpenCL)"; + static constexpr const char* function = "weibull_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/weibull_lcdf.hpp b/stan/math/opencl/prim/weibull_lcdf.hpp index c5d9272434c..f525d4fce09 100644 --- a/stan/math/opencl/prim/weibull_lcdf.hpp +++ b/stan/math/opencl/prim/weibull_lcdf.hpp @@ -33,7 +33,7 @@ template < require_any_not_stan_scalar_t* = nullptr> return_type_t weibull_lcdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "weibull_lcdf(OpenCL)"; + static constexpr const char* function = "weibull_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/opencl/prim/weibull_lpdf.hpp b/stan/math/opencl/prim/weibull_lpdf.hpp index 76912e590ba..09db3445720 100644 --- a/stan/math/opencl/prim/weibull_lpdf.hpp +++ b/stan/math/opencl/prim/weibull_lpdf.hpp @@ -34,7 +34,7 @@ template < require_any_not_stan_scalar_t* = nullptr> inline return_type_t weibull_lpdf( const T_y_cl& y, const T_shape_cl& alpha, const T_scale_cl& sigma) { - static const char* function = "weibull_lpdf(OpenCL)"; + static constexpr const char* function = "weibull_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; using std::isnan; diff --git a/stan/math/prim/fun/binomial_coefficient_log.hpp b/stan/math/prim/fun/binomial_coefficient_log.hpp index 986eca5995b..eb9d05798fa 100644 --- a/stan/math/prim/fun/binomial_coefficient_log.hpp +++ b/stan/math/prim/fun/binomial_coefficient_log.hpp @@ -96,7 +96,7 @@ inline return_type_t binomial_coefficient_log(const T_n n, const T_partials_return n_plus_1 = n_dbl + 1; const T_partials_return n_plus_1_mk = n_plus_1 - k_dbl; - static const char* function = "binomial_coefficient_log"; + static constexpr const char* function = "binomial_coefficient_log"; check_greater_or_equal(function, "first argument", n, -1); check_greater_or_equal(function, "second argument", k, -1); check_greater_or_equal(function, "(first argument - second argument + 1)", diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index e7f483ce7f7..0edf7de085b 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -77,7 +77,7 @@ const double LOG_EPSILON = std::log(EPSILON); * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. */ -const double LOG_PI = std::log(pi()); +static constexpr double LOG_PI = 1.14472988584940017414342735135305871164729481291531157151362; /** * The natural logarithm of 2, @@ -95,19 +95,19 @@ static constexpr double LOG_HALF = -LOG_TWO; * The natural logarithm of 2 plus the natural logarithm of \f$ \pi \f$, * \f$ \log(2\pi) \f$. */ -const double LOG_TWO_PI = LOG_TWO + LOG_PI; +static constexpr double LOG_TWO_PI = LOG_TWO + LOG_PI; /** * The value of one quarter the natural logarithm of \f$ \pi \f$, * \f$ \log(\pi) / 4 \f$. */ -const double LOG_PI_OVER_FOUR = 0.25 * LOG_PI; +static constexpr double LOG_PI_OVER_FOUR = 0.25 * LOG_PI; /** * The natural logarithm of the square root of \f$ \pi \f$, * \f$ \log(sqrt{\pi}) \f$. */ -const double LOG_SQRT_PI = std::log(boost::math::constants::root_pi()); +static constexpr double LOG_SQRT_PI = 0.5723649429247000870717136756765293558236474064576557857568115357; /** * The natural logarithm of 10, @@ -178,7 +178,7 @@ static constexpr double HALF_LOG_TWO = 0.5 * LOG_TWO; * The value of half the natural logarithm \f$ 2\pi \f$, * \f$ \log(2\pi) / 2 \f$. */ -const double HALF_LOG_TWO_PI = 0.5 * LOG_TWO_PI; +static constexpr double HALF_LOG_TWO_PI = 0.5 * LOG_TWO_PI; /** * The value of minus the natural logarithm of the square root of \f$ 2\pi \f$, diff --git a/stan/math/prim/fun/inv_Phi.hpp b/stan/math/prim/fun/inv_Phi.hpp index 9c9811133f1..0ec72de8062 100644 --- a/stan/math/prim/fun/inv_Phi.hpp +++ b/stan/math/prim/fun/inv_Phi.hpp @@ -38,32 +38,32 @@ inline double inv_Phi_lambda(double p) { return INFTY; } - static const double a[8] + static constexpr double a[8] = {3.3871328727963666080e+00, 1.3314166789178437745e+02, 1.9715909503065514427e+03, 1.3731693765509461125e+04, 4.5921953931549871457e+04, 6.7265770927008700853e+04, 3.3430575583588128105e+04, 2.5090809287301226727e+03}; - static const double b[7] + static constexpr double b[7] = {4.2313330701600911252e+01, 6.8718700749205790830e+02, 5.3941960214247511077e+03, 2.1213794301586595867e+04, 3.9307895800092710610e+04, 2.8729085735721942674e+04, 5.2264952788528545610e+03}; - static const double c[8] + static constexpr double c[8] = {1.42343711074968357734e+00, 4.63033784615654529590e+00, 5.76949722146069140550e+00, 3.64784832476320460504e+00, 1.27045825245236838258e+00, 2.41780725177450611770e-01, 2.27238449892691845833e-02, 7.74545014278341407640e-04}; - static const double d[7] + static constexpr double d[7] = {2.05319162663775882187e+00, 1.67638483018380384940e+00, 6.89767334985100004550e-01, 1.48103976427480074590e-01, 1.51986665636164571966e-02, 5.47593808499534494600e-04, 1.05075007164441684324e-09}; - static const double e[8] + static constexpr double e[8] = {6.65790464350110377720e+00, 5.46378491116411436990e+00, 1.78482653991729133580e+00, 2.96560571828504891230e-01, 2.65321895265761230930e-02, 1.24266094738807843860e-03, 2.71155556874348757815e-05, 2.01033439929228813265e-07}; - static const double f[7] + static constexpr double f[7] = {5.99832206555887937690e-01, 1.36929880922735805310e-01, 1.48753612908506148525e-02, 7.86869131145613259100e-04, 1.84631831751005468180e-05, 1.42151175831644588870e-07, diff --git a/stan/math/prim/fun/lbeta.hpp b/stan/math/prim/fun/lbeta.hpp index 22ed7e788bc..27279e8e7db 100644 --- a/stan/math/prim/fun/lbeta.hpp +++ b/stan/math/prim/fun/lbeta.hpp @@ -69,7 +69,7 @@ return_type_t lbeta(const T1 a, const T2 b) { return NOT_A_NUMBER; } - static const char* function = "lbeta"; + static constexpr const char* function = "lbeta"; check_nonnegative(function, "first argument", a); check_nonnegative(function, "second argument", b); T_ret x; // x is the smaller of the two diff --git a/stan/math/prim/fun/linspaced_array.hpp b/stan/math/prim/fun/linspaced_array.hpp index 59d18572b2b..ef09080bd56 100644 --- a/stan/math/prim/fun/linspaced_array.hpp +++ b/stan/math/prim/fun/linspaced_array.hpp @@ -24,7 +24,7 @@ namespace math { * if high is nan or infinite, or if high is less than low. */ inline std::vector linspaced_array(int K, double low, double high) { - static const char* function = "linspaced_array"; + static constexpr const char* function = "linspaced_array"; check_nonnegative(function, "size", K); check_finite(function, "low", low); check_finite(function, "high", high); diff --git a/stan/math/prim/fun/linspaced_int_array.hpp b/stan/math/prim/fun/linspaced_int_array.hpp index 31499ac6491..cc9346262bf 100644 --- a/stan/math/prim/fun/linspaced_int_array.hpp +++ b/stan/math/prim/fun/linspaced_int_array.hpp @@ -31,7 +31,7 @@ namespace math { * @throw std::domain_error if K is negative or high is less than low. */ inline std::vector linspaced_int_array(int K, int low, int high) { - static const char* function = "linspaced_int_array"; + static constexpr const char* function = "linspaced_int_array"; check_nonnegative(function, "size", K); check_greater_or_equal(function, "high", high, low); if (K == 0) { diff --git a/stan/math/prim/fun/linspaced_row_vector.hpp b/stan/math/prim/fun/linspaced_row_vector.hpp index 31f0d455af4..6f6f39e63fb 100644 --- a/stan/math/prim/fun/linspaced_row_vector.hpp +++ b/stan/math/prim/fun/linspaced_row_vector.hpp @@ -23,7 +23,7 @@ namespace math { * if high is nan or infinite, or if high is less than low. */ inline auto linspaced_row_vector(int K, double low, double high) { - static const char* function = "linspaced_row_vector"; + static constexpr const char* function = "linspaced_row_vector"; check_nonnegative(function, "size", K); check_finite(function, "low", low); check_finite(function, "high", high); diff --git a/stan/math/prim/fun/linspaced_vector.hpp b/stan/math/prim/fun/linspaced_vector.hpp index 807adfdac53..76051b3fa33 100644 --- a/stan/math/prim/fun/linspaced_vector.hpp +++ b/stan/math/prim/fun/linspaced_vector.hpp @@ -23,7 +23,7 @@ namespace math { * if high is nan or infinite, or if high is less than low. */ inline auto linspaced_vector(int K, double low, double high) { - static const char* function = "linspaced_vector"; + static constexpr const char* function = "linspaced_vector"; check_nonnegative(function, "size", K); check_finite(function, "low", low); check_finite(function, "high", high); diff --git a/stan/math/prim/fun/log.hpp b/stan/math/prim/fun/log.hpp index 124aab6d302..d18c35db721 100644 --- a/stan/math/prim/fun/log.hpp +++ b/stan/math/prim/fun/log.hpp @@ -76,8 +76,8 @@ namespace internal { */ template inline std::complex complex_log(const std::complex& z) { - static const double inf = std::numeric_limits::infinity(); - static const double nan = std::numeric_limits::quiet_NaN(); + static constexpr double inf = std::numeric_limits::infinity(); + static constexpr double nan = std::numeric_limits::quiet_NaN(); if ((is_nan(z.real()) && is_inf(z.imag())) || (is_inf(z.real()) && is_nan(z.imag()))) { return {inf, nan}; diff --git a/stan/math/prim/fun/log10.hpp b/stan/math/prim/fun/log10.hpp index 70954bbd4fc..b7e4f72af10 100644 --- a/stan/math/prim/fun/log10.hpp +++ b/stan/math/prim/fun/log10.hpp @@ -67,7 +67,7 @@ namespace internal { */ template inline std::complex complex_log10(const std::complex& z) { - static const double inv_log_10 = 1 / std::log(10); + static constexpr double inv_log_10 = 1 / 2.30258509299404568401799145468; return log(z) * inv_log_10; } } // namespace internal diff --git a/stan/math/prim/fun/log_falling_factorial.hpp b/stan/math/prim/fun/log_falling_factorial.hpp index 03aca842c9e..83b16626ce3 100644 --- a/stan/math/prim/fun/log_falling_factorial.hpp +++ b/stan/math/prim/fun/log_falling_factorial.hpp @@ -56,7 +56,7 @@ inline return_type_t log_falling_factorial(const T1 x, const T2 n) { if (is_any_nan(x, n)) { return NOT_A_NUMBER; } - static const char* function = "log_falling_factorial"; + static constexpr const char* function = "log_falling_factorial"; check_positive(function, "first argument", x); return lgamma(x + 1) - lgamma(x - n + 1); } diff --git a/stan/math/prim/fun/log_mix.hpp b/stan/math/prim/fun/log_mix.hpp index 6d5cc22b61d..8784b9bb5f6 100644 --- a/stan/math/prim/fun/log_mix.hpp +++ b/stan/math/prim/fun/log_mix.hpp @@ -76,7 +76,7 @@ template * = nullptr> return_type_t log_mix(const T_theta& theta, const T_lam& lambda) { - static const char* function = "log_mix"; + static constexpr const char* function = "log_mix"; using T_partials_return = partials_return_t; using T_partials_vec = typename Eigen::Matrix; @@ -144,7 +144,7 @@ return_type_t log_mix(const T_theta& theta, template * = nullptr> return_type_t> log_mix( const T_theta& theta, const std::vector& lambda) { - static const char* function = "log_mix"; + static constexpr const char* function = "log_mix"; using T_partials_return = partials_return_t>; using T_partials_vec = typename Eigen::Matrix; diff --git a/stan/math/prim/fun/log_modified_bessel_first_kind.hpp b/stan/math/prim/fun/log_modified_bessel_first_kind.hpp index 6935eec131a..aa6b3b98d1f 100644 --- a/stan/math/prim/fun/log_modified_bessel_first_kind.hpp +++ b/stan/math/prim/fun/log_modified_bessel_first_kind.hpp @@ -91,7 +91,7 @@ inline return_type_t log_modified_bessel_first_kind( // Max error in interpolated form : 3.042e-18 // Max Error found at double precision = Poly : 5.106609e-16 // Cheb : 5.239199e-16 - static const double P[] + static constexpr double P[15] = {1.00000000000000000e+00, 2.49999999999999909e-01, 2.77777777777782257e-02, 1.73611111111023792e-03, 6.94444444453352521e-05, 1.92901234513219920e-06, @@ -107,7 +107,7 @@ inline return_type_t log_modified_bessel_first_kind( // Max error in interpolated form : 1.685e-16 // Max Error found at double precision = Poly : 2.575063e-16 // Cheb : 2.247615e+00 - static const double P[] + static constexpr double P[22] = {3.98942280401425088e-01, 4.98677850604961985e-02, 2.80506233928312623e-02, 2.92211225166047873e-02, 4.44207299493659561e-02, 1.30970574605856719e-01, @@ -123,7 +123,7 @@ inline return_type_t log_modified_bessel_first_kind( } // Max error in interpolated form : 2.437e-18 // Max Error found at double precision = Poly : 1.216719e-16 - static const double P[] = {3.98942280401432905e-01, 4.98677850491434560e-02, + static constexpr double P[5] = {3.98942280401432905e-01, 4.98677850491434560e-02, 2.80506308916506102e-02, 2.92179096853915176e-02, 4.53371208762579442e-02}; return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z); @@ -136,7 +136,7 @@ inline return_type_t log_modified_bessel_first_kind( // Max error in interpolated form: 5.639e-17 // Max Error found at double precision = Poly: 1.795559e-16 - static const double P[] + static constexpr double P[13] = {8.333333333333333803e-02, 6.944444444444341983e-03, 3.472222222225921045e-04, 1.157407407354987232e-05, 2.755731926254790268e-07, 4.920949692800671435e-09, @@ -152,7 +152,7 @@ inline return_type_t log_modified_bessel_first_kind( // Max error in interpolated form: 1.796e-16 // Max Error found at double precision = Poly: 2.898731e-16 - static const double P[] + static constexpr double P[22] = {3.989422804014406054e-01, -1.496033551613111533e-01, -4.675104253598537322e-02, -4.090895951581637791e-02, -5.719036414430205390e-02, -1.528189554374492735e-01, @@ -168,7 +168,7 @@ inline return_type_t log_modified_bessel_first_kind( } // Max error in interpolated form: 1.320e-19 // Max Error found at double precision = Poly: 7.065357e-17 - static const double P[] + static constexpr double P[5] = {3.989422804014314820e-01, -1.496033551467584157e-01, -4.675105322571775911e-02, -4.090421597376992892e-02, -5.843630344778927582e-02}; diff --git a/stan/math/prim/fun/log_rising_factorial.hpp b/stan/math/prim/fun/log_rising_factorial.hpp index 058b3d7d361..2f5d834779a 100644 --- a/stan/math/prim/fun/log_rising_factorial.hpp +++ b/stan/math/prim/fun/log_rising_factorial.hpp @@ -54,7 +54,7 @@ inline return_type_t log_rising_factorial(const T1& x, const T2& n) { if (is_any_nan(x, n)) { return NOT_A_NUMBER; } - static const char* function = "log_rising_factorial"; + static constexpr const char* function = "log_rising_factorial"; check_positive(function, "first argument", x); return lgamma(x + n) - lgamma(x); } diff --git a/stan/math/prim/fun/mdivide_left_spd.hpp b/stan/math/prim/fun/mdivide_left_spd.hpp index f403f40f5b9..25b0f404fa0 100644 --- a/stan/math/prim/fun/mdivide_left_spd.hpp +++ b/stan/math/prim/fun/mdivide_left_spd.hpp @@ -28,7 +28,7 @@ template , EigMat1::RowsAtCompileTime, EigMat2::ColsAtCompileTime> mdivide_left_spd(const EigMat1& A, const EigMat2& b) { - static const char* function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto& A_ref = to_ref(A); check_symmetric(function, "A", A_ref); diff --git a/stan/math/prim/fun/mdivide_right_spd.hpp b/stan/math/prim/fun/mdivide_right_spd.hpp index c874b78bbc4..c3c177dbb26 100644 --- a/stan/math/prim/fun/mdivide_right_spd.hpp +++ b/stan/math/prim/fun/mdivide_right_spd.hpp @@ -28,7 +28,7 @@ template , EigMat1::RowsAtCompileTime, EigMat2::ColsAtCompileTime> mdivide_right_spd(const EigMat1& b, const EigMat2& A) { - static const char* function = "mdivide_right_spd"; + static constexpr const char* function = "mdivide_right_spd"; check_multiplicable(function, "b", b, "A", A); const auto& A_ref = to_ref(A); check_symmetric(function, "A", A_ref); diff --git a/stan/math/prim/fun/one_hot_array.hpp b/stan/math/prim/fun/one_hot_array.hpp index 9fc947d0a3d..3e91038914c 100644 --- a/stan/math/prim/fun/one_hot_array.hpp +++ b/stan/math/prim/fun/one_hot_array.hpp @@ -18,7 +18,7 @@ namespace math { * greater than K. */ inline std::vector one_hot_array(int K, int k) { - static const char* function = "one_hot_array"; + static constexpr const char* function = "one_hot_array"; check_positive(function, "size", K); check_bounded(function, "k", k, 1, K); diff --git a/stan/math/prim/fun/one_hot_int_array.hpp b/stan/math/prim/fun/one_hot_int_array.hpp index f6d9e222ef4..e743b1ec881 100644 --- a/stan/math/prim/fun/one_hot_int_array.hpp +++ b/stan/math/prim/fun/one_hot_int_array.hpp @@ -18,7 +18,7 @@ namespace math { * greater than K. */ inline std::vector one_hot_int_array(int K, int k) { - static const char* function = "one_hot_int_array"; + static constexpr const char* function = "one_hot_int_array"; check_positive(function, "size", K); check_bounded(function, "k", k, 1, K); diff --git a/stan/math/prim/fun/one_hot_row_vector.hpp b/stan/math/prim/fun/one_hot_row_vector.hpp index fa841dddc54..5212c77d52d 100644 --- a/stan/math/prim/fun/one_hot_row_vector.hpp +++ b/stan/math/prim/fun/one_hot_row_vector.hpp @@ -18,7 +18,7 @@ namespace math { * greater than K. */ inline Eigen::RowVectorXd one_hot_row_vector(int K, int k) { - static const char* function = "one_hot_row_vector"; + static constexpr const char* function = "one_hot_row_vector"; check_positive(function, "size", K); check_bounded(function, "k", k, 1, K); diff --git a/stan/math/prim/fun/one_hot_vector.hpp b/stan/math/prim/fun/one_hot_vector.hpp index ee20d8aa4c5..ac1c2f42841 100644 --- a/stan/math/prim/fun/one_hot_vector.hpp +++ b/stan/math/prim/fun/one_hot_vector.hpp @@ -18,7 +18,7 @@ namespace math { * greater than K. */ inline Eigen::VectorXd one_hot_vector(int K, int k) { - static const char* function = "one_hot_vector"; + static constexpr const char* function = "one_hot_vector"; check_positive(function, "size", K); check_bounded(function, "k", k, 1, K); diff --git a/stan/math/prim/fun/rising_factorial.hpp b/stan/math/prim/fun/rising_factorial.hpp index f934fd5c1c0..6be3ef968d6 100644 --- a/stan/math/prim/fun/rising_factorial.hpp +++ b/stan/math/prim/fun/rising_factorial.hpp @@ -61,7 +61,7 @@ namespace math { */ template * = nullptr> inline return_type_t rising_factorial(const T& x, int n) { - static const char* function = "rising_factorial"; + static constexpr const char* function = "rising_factorial"; check_not_nan(function, "first argument", x); check_nonnegative(function, "second argument", n); return boost::math::rising_factorial(x, n, boost_policy_t<>()); diff --git a/stan/math/prim/fun/to_int.hpp b/stan/math/prim/fun/to_int.hpp index 1aae1878e6f..bc9be58c10b 100644 --- a/stan/math/prim/fun/to_int.hpp +++ b/stan/math/prim/fun/to_int.hpp @@ -40,7 +40,7 @@ inline T to_int(T x) { */ template * = nullptr> inline int to_int(T x) { - static const char* function = "to_int"; + static constexpr const char* function = "to_int"; check_bounded(function, "x", x, std::numeric_limits::min(), std::numeric_limits::max()); return static_cast(x); diff --git a/stan/math/prim/fun/to_matrix.hpp b/stan/math/prim/fun/to_matrix.hpp index 28b9def5f55..2b9e1b789cf 100644 --- a/stan/math/prim/fun/to_matrix.hpp +++ b/stan/math/prim/fun/to_matrix.hpp @@ -106,7 +106,7 @@ to_matrix(const std::vector>& x) { template * = nullptr> inline Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> to_matrix(EigMat&& x, int m, int n) { - static const char* function = "to_matrix(matrix)"; + static constexpr const char* function = "to_matrix(matrix)"; check_size_match(function, "rows * columns", m * n, "vector size", x.size()); Eigen::Matrix, Eigen::Dynamic, Eigen::Dynamic> y = std::forward(x); @@ -128,7 +128,7 @@ to_matrix(EigMat&& x, int m, int n) { */ template inline auto to_matrix(const std::vector& x, int m, int n) { - static const char* function = "to_matrix(array)"; + static constexpr const char* function = "to_matrix(array)"; check_size_match(function, "rows * columns", m * n, "vector size", x.size()); return Eigen::Map>( &x[0], m, n); @@ -147,7 +147,7 @@ inline auto to_matrix(const std::vector& x, int m, int n) { */ inline Eigen::Matrix to_matrix( const std::vector& x, int m, int n) { - static const char* function = "to_matrix(array)"; + static constexpr const char* function = "to_matrix(array)"; int x_size = x.size(); check_size_match(function, "rows * columns", m * n, "vector size", x_size); Eigen::Matrix result(m, n); diff --git a/stan/math/prim/fun/unitspaced_array.hpp b/stan/math/prim/fun/unitspaced_array.hpp index 4985ee2a5bb..75f01faf3f4 100644 --- a/stan/math/prim/fun/unitspaced_array.hpp +++ b/stan/math/prim/fun/unitspaced_array.hpp @@ -21,7 +21,7 @@ namespace math { * @throw std::domain_error if high is less than low. */ inline std::vector unitspaced_array(int low, int high) { - static const char* function = "unitspaced_array"; + static constexpr const char* function = "unitspaced_array"; check_greater_or_equal(function, "high", high, low); int K = std::abs(high - low + 1); diff --git a/stan/math/prim/functor/map_rect.hpp b/stan/math/prim/functor/map_rect.hpp index f3952eef2e4..9fcc7ee7fde 100644 --- a/stan/math/prim/functor/map_rect.hpp +++ b/stan/math/prim/functor/map_rect.hpp @@ -130,7 +130,7 @@ map_rect(const T_shared_param& shared_params, const std::vector>& x_r, const std::vector>& x_i, std::ostream* msgs = nullptr) { - static const char* function = "map_rect"; + static constexpr const char* function = "map_rect"; using return_t = Eigen::Matrix, Eigen::Dynamic, 1>; diff --git a/stan/math/prim/prob/bernoulli_cdf.hpp b/stan/math/prim/prob/bernoulli_cdf.hpp index 3e0154bb22d..869a345aca7 100644 --- a/stan/math/prim/prob/bernoulli_cdf.hpp +++ b/stan/math/prim/prob/bernoulli_cdf.hpp @@ -32,7 +32,7 @@ template bernoulli_cdf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_theta_ref = ref_type_t; - static const char* function = "bernoulli_cdf"; + static constexpr const char* function = "bernoulli_cdf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); T_theta_ref theta_ref = theta; diff --git a/stan/math/prim/prob/bernoulli_lccdf.hpp b/stan/math/prim/prob/bernoulli_lccdf.hpp index e63119bbd69..d823c9293bd 100644 --- a/stan/math/prim/prob/bernoulli_lccdf.hpp +++ b/stan/math/prim/prob/bernoulli_lccdf.hpp @@ -36,7 +36,7 @@ return_type_t bernoulli_lccdf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_theta_ref = ref_type_t; using std::log; - static const char* function = "bernoulli_lccdf"; + static constexpr const char* function = "bernoulli_lccdf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); T_theta_ref theta_ref = theta; diff --git a/stan/math/prim/prob/bernoulli_lcdf.hpp b/stan/math/prim/prob/bernoulli_lcdf.hpp index d9a40898ff9..d17618217de 100644 --- a/stan/math/prim/prob/bernoulli_lcdf.hpp +++ b/stan/math/prim/prob/bernoulli_lcdf.hpp @@ -36,7 +36,7 @@ return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { using T_partials_return = partials_return_t; using T_theta_ref = ref_type_t; using std::log; - static const char* function = "bernoulli_lcdf"; + static constexpr const char* function = "bernoulli_lcdf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); T_theta_ref theta_ref = theta; diff --git a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp index 0d4e7d10eb3..213dffd7c30 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_lpmf.hpp @@ -66,7 +66,7 @@ return_type_t bernoulli_logit_glm_lpmf( const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); - static const char* function = "bernoulli_logit_glm_lpmf"; + static constexpr const char* function = "bernoulli_logit_glm_lpmf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Weight vector", beta, N_attributes); @@ -113,7 +113,7 @@ return_type_t bernoulli_logit_glm_lpmf( // Compute the log-density and handle extreme values gracefully // using Taylor approximations. // And compute the derivatives wrt theta. - static const double cutoff = 20.0; + static constexpr double cutoff = 20.0; Eigen::Array exp_m_ytheta = exp(-ytheta); T_partials_return logp = sum( (ytheta > cutoff) diff --git a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp index 6d61e7b80f2..9a0da6d3d19 100644 --- a/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp +++ b/stan/math/prim/prob/bernoulli_logit_glm_rng.hpp @@ -51,7 +51,7 @@ inline typename VectorBuilder::type bernoulli_logit_glm_rng( const size_t N = x.cols(); const size_t M = x.rows(); - static const char* function = "bernoulli_logit_glm_rng"; + static constexpr const char* function = "bernoulli_logit_glm_rng"; check_consistent_size(function, "Weight vector", beta, N); check_consistent_size(function, "Vector of intercepts", alpha, M); T_x_ref x_ref = x; diff --git a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp index bace8fa75f1..abd904b946b 100644 --- a/stan/math/prim/prob/bernoulli_logit_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_logit_lpmf.hpp @@ -39,7 +39,7 @@ return_type_t bernoulli_logit_lpmf(const T_n& n, const T_prob& theta) { using std::exp; using T_n_ref = ref_type_if_t::value, T_n>; using T_theta_ref = ref_type_if_t::value, T_prob>; - static const char* function = "bernoulli_logit_lpmf"; + static constexpr const char* function = "bernoulli_logit_lpmf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); if (size_zero(n, theta)) { @@ -70,7 +70,7 @@ return_type_t bernoulli_logit_lpmf(const T_n& n, const T_prob& theta) { ntheta = T_partials_array::Constant(1, 1, ntheta_s); } T_partials_array exp_m_ntheta = exp(-ntheta); - static const double cutoff = 20.0; + static constexpr double cutoff = 20.0; T_partials_return logp = sum( (ntheta > cutoff) .select(-exp_m_ntheta, diff --git a/stan/math/prim/prob/bernoulli_lpmf.hpp b/stan/math/prim/prob/bernoulli_lpmf.hpp index 9b54f02d839..68e9ac6506d 100644 --- a/stan/math/prim/prob/bernoulli_lpmf.hpp +++ b/stan/math/prim/prob/bernoulli_lpmf.hpp @@ -36,7 +36,7 @@ return_type_t bernoulli_lpmf(const T_n& n, const T_prob& theta) { using T_theta_ref = ref_type_t; using T_n_ref = ref_type_t; using std::log; - static const char* function = "bernoulli_lpmf"; + static constexpr const char* function = "bernoulli_lpmf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); const T_n_ref n_ref = to_ref(n); diff --git a/stan/math/prim/prob/bernoulli_rng.hpp b/stan/math/prim/prob/bernoulli_rng.hpp index a234372acc8..49848f04ed2 100644 --- a/stan/math/prim/prob/bernoulli_rng.hpp +++ b/stan/math/prim/prob/bernoulli_rng.hpp @@ -30,7 +30,7 @@ inline typename VectorBuilder::type bernoulli_rng( const T_theta& theta, RNG& rng) { using boost::bernoulli_distribution; using boost::variate_generator; - static const char* function = "bernoulli_rng"; + static constexpr const char* function = "bernoulli_rng"; ref_type_t theta_ref = theta; check_bounded(function, "Probability parameter", value_of(theta_ref), 0.0, 1.0); diff --git a/stan/math/prim/prob/beta_binomial_cdf.hpp b/stan/math/prim/prob/beta_binomial_cdf.hpp index 41bb221fc3f..181f3e52849 100644 --- a/stan/math/prim/prob/beta_binomial_cdf.hpp +++ b/stan/math/prim/prob/beta_binomial_cdf.hpp @@ -48,7 +48,7 @@ return_type_t beta_binomial_cdf(const T_n& n, const T_N& N, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_binomial_cdf"; + static constexpr const char* function = "beta_binomial_cdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "First prior sample size parameter", alpha, diff --git a/stan/math/prim/prob/beta_binomial_lccdf.hpp b/stan/math/prim/prob/beta_binomial_lccdf.hpp index 4e8d95fab79..70ced401b7a 100644 --- a/stan/math/prim/prob/beta_binomial_lccdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lccdf.hpp @@ -50,7 +50,7 @@ return_type_t beta_binomial_lccdf(const T_n& n, const T_N& N, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_binomial_lccdf"; + static constexpr const char* function = "beta_binomial_lccdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "First prior sample size parameter", alpha, diff --git a/stan/math/prim/prob/beta_binomial_lcdf.hpp b/stan/math/prim/prob/beta_binomial_lcdf.hpp index 500db7aac2b..a56804aac54 100644 --- a/stan/math/prim/prob/beta_binomial_lcdf.hpp +++ b/stan/math/prim/prob/beta_binomial_lcdf.hpp @@ -50,7 +50,7 @@ return_type_t beta_binomial_lcdf(const T_n& n, const T_N& N, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_binomial_lcdf"; + static constexpr const char* function = "beta_binomial_lcdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "First prior sample size parameter", alpha, diff --git a/stan/math/prim/prob/beta_binomial_lpmf.hpp b/stan/math/prim/prob/beta_binomial_lpmf.hpp index 190785c78a1..e243254005d 100644 --- a/stan/math/prim/prob/beta_binomial_lpmf.hpp +++ b/stan/math/prim/prob/beta_binomial_lpmf.hpp @@ -48,7 +48,7 @@ return_type_t beta_binomial_lpmf(const T_n& n, const T_N& N, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_binomial_lpmf"; + static constexpr const char* function = "beta_binomial_lpmf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "First prior sample size parameter", alpha, diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index 29375d2c2d6..7445ae2d269 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char *function = "beta_binomial_rng"; + static constexpr const char* function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_cdf.hpp b/stan/math/prim/prob/beta_cdf.hpp index 4201f922ac0..6ec299c1117 100644 --- a/stan/math/prim/prob/beta_cdf.hpp +++ b/stan/math/prim/prob/beta_cdf.hpp @@ -39,7 +39,7 @@ return_type_t beta_cdf( using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_cdf"; + static constexpr const char* function = "beta_cdf"; check_consistent_sizes(function, "Random variable", y, "First shape parameter", alpha, "Second shape parameter", beta); diff --git a/stan/math/prim/prob/beta_lccdf.hpp b/stan/math/prim/prob/beta_lccdf.hpp index 207833b9663..15c0313e24e 100644 --- a/stan/math/prim/prob/beta_lccdf.hpp +++ b/stan/math/prim/prob/beta_lccdf.hpp @@ -47,7 +47,7 @@ return_type_t beta_lccdf( using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_lccdf"; + static constexpr const char* function = "beta_lccdf"; check_consistent_sizes(function, "Random variable", y, "First shape parameter", alpha, "Second shape parameter", beta_param); diff --git a/stan/math/prim/prob/beta_lcdf.hpp b/stan/math/prim/prob/beta_lcdf.hpp index 42a771fb84b..ff2e1fae3cd 100644 --- a/stan/math/prim/prob/beta_lcdf.hpp +++ b/stan/math/prim/prob/beta_lcdf.hpp @@ -47,7 +47,7 @@ return_type_t beta_lcdf( using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "beta_lcdf"; + static constexpr const char* function = "beta_lcdf"; check_consistent_sizes(function, "Random variable", y, "First shape parameter", alpha, "Second shape parameter", beta_param); diff --git a/stan/math/prim/prob/beta_lpdf.hpp b/stan/math/prim/prob/beta_lpdf.hpp index 5f03de1efbc..22504d32dea 100644 --- a/stan/math/prim/prob/beta_lpdf.hpp +++ b/stan/math/prim/prob/beta_lpdf.hpp @@ -52,7 +52,7 @@ return_type_t beta_lpdf( = ref_type_if_t::value, T_scale_succ>; using T_beta_ref = ref_type_if_t::value, T_scale_fail>; - static const char* function = "beta_lpdf"; + static constexpr const char* function = "beta_lpdf"; check_consistent_sizes(function, "Random variable", y, "First shape parameter", alpha, "Second shape parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_lccdf.hpp b/stan/math/prim/prob/beta_proportion_lccdf.hpp index ec0bd7b17a0..13c4d40772f 100644 --- a/stan/math/prim/prob/beta_proportion_lccdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lccdf.hpp @@ -51,7 +51,7 @@ return_type_t beta_proportion_lccdf(const T_y& y, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static const char* function = "beta_proportion_lccdf"; + static constexpr const char* function = "beta_proportion_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Precision parameter", kappa); if (size_zero(y, mu, kappa)) { diff --git a/stan/math/prim/prob/beta_proportion_lcdf.hpp b/stan/math/prim/prob/beta_proportion_lcdf.hpp index 9c3afd8fe09..0424a0b5a81 100644 --- a/stan/math/prim/prob/beta_proportion_lcdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lcdf.hpp @@ -52,7 +52,7 @@ return_type_t beta_proportion_lcdf(const T_y& y, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static const char* function = "beta_proportion_lcdf"; + static constexpr const char* function = "beta_proportion_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Precision parameter", kappa); if (size_zero(y, mu, kappa)) { diff --git a/stan/math/prim/prob/beta_proportion_lpdf.hpp b/stan/math/prim/prob/beta_proportion_lpdf.hpp index 523fdc1c138..cd4493cf908 100644 --- a/stan/math/prim/prob/beta_proportion_lpdf.hpp +++ b/stan/math/prim/prob/beta_proportion_lpdf.hpp @@ -56,7 +56,7 @@ return_type_t beta_proportion_lpdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_kappa_ref = ref_type_if_t::value, T_prec>; - static const char* function = "beta_proportion_lpdf"; + static constexpr const char* function = "beta_proportion_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Precision parameter", kappa); if (size_zero(y, mu, kappa)) { diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index f5a01f68b38..90ca685786a 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static const char *function = "beta_proportion_rng"; + static constexpr const char* function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index d31c104dbea..1f544c857f9 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char *function = "beta_rng"; + static constexpr const char* function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/binomial_cdf.hpp b/stan/math/prim/prob/binomial_cdf.hpp index 17f43d3a8f6..adc8ee5469c 100644 --- a/stan/math/prim/prob/binomial_cdf.hpp +++ b/stan/math/prim/prob/binomial_cdf.hpp @@ -41,7 +41,7 @@ return_type_t binomial_cdf(const T_n& n, const T_N& N, using T_theta_ref = ref_type_t; using std::exp; using std::pow; - static const char* function = "binomial_cdf"; + static constexpr const char* function = "binomial_cdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "Probability parameter", theta); diff --git a/stan/math/prim/prob/binomial_lccdf.hpp b/stan/math/prim/prob/binomial_lccdf.hpp index 709452788cc..1fceff8a986 100644 --- a/stan/math/prim/prob/binomial_lccdf.hpp +++ b/stan/math/prim/prob/binomial_lccdf.hpp @@ -44,7 +44,7 @@ return_type_t binomial_lccdf(const T_n& n, const T_N& N, using std::exp; using std::log; using std::pow; - static const char* function = "binomial_lccdf"; + static constexpr const char* function = "binomial_lccdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "Probability parameter", theta); diff --git a/stan/math/prim/prob/binomial_lcdf.hpp b/stan/math/prim/prob/binomial_lcdf.hpp index 28ec9a55972..511c85f3e4e 100644 --- a/stan/math/prim/prob/binomial_lcdf.hpp +++ b/stan/math/prim/prob/binomial_lcdf.hpp @@ -44,7 +44,7 @@ return_type_t binomial_lcdf(const T_n& n, const T_N& N, using std::exp; using std::log; using std::pow; - static const char* function = "binomial_lcdf"; + static constexpr const char* function = "binomial_lcdf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "Probability parameter", theta); diff --git a/stan/math/prim/prob/binomial_logit_lpmf.hpp b/stan/math/prim/prob/binomial_logit_lpmf.hpp index 08e42e2873a..d480f4bc264 100644 --- a/stan/math/prim/prob/binomial_logit_lpmf.hpp +++ b/stan/math/prim/prob/binomial_logit_lpmf.hpp @@ -43,7 +43,7 @@ return_type_t binomial_logit_lpmf(const T_n& n, const T_N& N, using T_n_ref = ref_type_if_t::value, T_n>; using T_N_ref = ref_type_if_t::value, T_N>; using T_alpha_ref = ref_type_if_t::value, T_prob>; - static const char* function = "binomial_logit_lpmf"; + static constexpr const char* function = "binomial_logit_lpmf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "Probability parameter", alpha); diff --git a/stan/math/prim/prob/binomial_lpmf.hpp b/stan/math/prim/prob/binomial_lpmf.hpp index ae19751db41..aaaaadd2387 100644 --- a/stan/math/prim/prob/binomial_lpmf.hpp +++ b/stan/math/prim/prob/binomial_lpmf.hpp @@ -42,7 +42,7 @@ return_type_t binomial_lpmf(const T_n& n, const T_N& N, using T_n_ref = ref_type_t; using T_N_ref = ref_type_t; using T_theta_ref = ref_type_t; - static const char* function = "binomial_lpmf"; + static constexpr const char* function = "binomial_lpmf"; check_consistent_sizes(function, "Successes variable", n, "Population size parameter", N, "Probability parameter", theta); diff --git a/stan/math/prim/prob/binomial_rng.hpp b/stan/math/prim/prob/binomial_rng.hpp index 588759767b5..3dab00a3649 100644 --- a/stan/math/prim/prob/binomial_rng.hpp +++ b/stan/math/prim/prob/binomial_rng.hpp @@ -35,7 +35,7 @@ inline typename VectorBuilder::type binomial_rng( using boost::variate_generator; using T_N_ref = ref_type_t; using T_theta_ref = ref_type_t; - static const char* function = "binomial_rng"; + static constexpr const char* function = "binomial_rng"; check_consistent_sizes(function, "Population size parameter", N, "Probability Parameter", theta); T_N_ref N_ref = N; diff --git a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp index 60ce24bf05b..c11098a99e7 100644 --- a/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_glm_lpmf.hpp @@ -61,7 +61,7 @@ return_type_t categorical_logit_glm_lpmf( const size_t N_attributes = x.cols(); const size_t N_classes = beta.cols(); - static const char* function = "categorical_logit_glm_lpmf"; + static constexpr const char* function = "categorical_logit_glm_lpmf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Intercept vector", alpha, N_classes); diff --git a/stan/math/prim/prob/categorical_logit_lpmf.hpp b/stan/math/prim/prob/categorical_logit_lpmf.hpp index 521cb6e89dc..766a299e92e 100644 --- a/stan/math/prim/prob/categorical_logit_lpmf.hpp +++ b/stan/math/prim/prob/categorical_logit_lpmf.hpp @@ -15,7 +15,7 @@ namespace math { // CategoricalLog(n|theta) [0 < n <= N, theta unconstrained], no checking template * = nullptr> return_type_t categorical_logit_lpmf(int n, const T_prob& beta) { - static const char* function = "categorical_logit_lpmf"; + static constexpr const char* function = "categorical_logit_lpmf"; check_bounded(function, "categorical outcome out of support", n, 1, beta.size()); ref_type_t beta_ref = beta; @@ -33,7 +33,7 @@ return_type_t categorical_logit_lpmf(int n, const T_prob& beta) { template * = nullptr> return_type_t categorical_logit_lpmf(const std::vector& ns, const T_prob& beta) { - static const char* function = "categorical_logit_lpmf"; + static constexpr const char* function = "categorical_logit_lpmf"; check_bounded(function, "categorical outcome out of support", ns, 1, beta.size()); diff --git a/stan/math/prim/prob/categorical_logit_rng.hpp b/stan/math/prim/prob/categorical_logit_rng.hpp index 463967de7c2..155cc80684b 100644 --- a/stan/math/prim/prob/categorical_logit_rng.hpp +++ b/stan/math/prim/prob/categorical_logit_rng.hpp @@ -29,7 +29,7 @@ template inline int categorical_logit_rng(const Eigen::VectorXd& beta, RNG& rng) { using boost::uniform_01; using boost::variate_generator; - static const char* function = "categorical_logit_rng"; + static constexpr const char* function = "categorical_logit_rng"; check_finite(function, "Log odds parameter", beta); variate_generator > uniform01_rng(rng, uniform_01<>()); diff --git a/stan/math/prim/prob/categorical_lpmf.hpp b/stan/math/prim/prob/categorical_lpmf.hpp index 68f5b33f09a..158000a1604 100644 --- a/stan/math/prim/prob/categorical_lpmf.hpp +++ b/stan/math/prim/prob/categorical_lpmf.hpp @@ -15,7 +15,7 @@ namespace math { template * = nullptr> return_type_t categorical_lpmf(int n, const T_prob& theta) { - static const char* function = "categorical_lpmf"; + static constexpr const char* function = "categorical_lpmf"; using std::log; check_bounded(function, "Number of categories", n, 1, theta.size()); @@ -32,7 +32,7 @@ template * = nullptr> return_type_t categorical_lpmf(const std::vector& ns, const T_prob& theta) { - static const char* function = "categorical_lpmf"; + static constexpr const char* function = "categorical_lpmf"; check_bounded(function, "element of outcome array", ns, 1, theta.size()); ref_type_t theta_ref = theta; diff --git a/stan/math/prim/prob/categorical_rng.hpp b/stan/math/prim/prob/categorical_rng.hpp index 56096d5e01d..fac6d198aea 100644 --- a/stan/math/prim/prob/categorical_rng.hpp +++ b/stan/math/prim/prob/categorical_rng.hpp @@ -15,7 +15,7 @@ inline int categorical_rng( const Eigen::Matrix& theta, RNG& rng) { using boost::uniform_01; using boost::variate_generator; - static const char* function = "categorical_rng"; + static constexpr const char* function = "categorical_rng"; check_simplex(function, "Probabilities parameter", theta); variate_generator > uniform01_rng(rng, uniform_01<>()); diff --git a/stan/math/prim/prob/cauchy_cdf.hpp b/stan/math/prim/prob/cauchy_cdf.hpp index eb91dc8b234..be845c31585 100644 --- a/stan/math/prim/prob/cauchy_cdf.hpp +++ b/stan/math/prim/prob/cauchy_cdf.hpp @@ -39,7 +39,7 @@ return_type_t cauchy_cdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "cauchy_cdf"; + static constexpr const char* function = "cauchy_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale Parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/cauchy_lccdf.hpp b/stan/math/prim/prob/cauchy_lccdf.hpp index 86728aad79a..6ee5418e92d 100644 --- a/stan/math/prim/prob/cauchy_lccdf.hpp +++ b/stan/math/prim/prob/cauchy_lccdf.hpp @@ -41,7 +41,7 @@ return_type_t cauchy_lccdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "cauchy_lccdf"; + static constexpr const char* function = "cauchy_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale Parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/cauchy_lcdf.hpp b/stan/math/prim/prob/cauchy_lcdf.hpp index 59ebed476a8..e53370e7531 100644 --- a/stan/math/prim/prob/cauchy_lcdf.hpp +++ b/stan/math/prim/prob/cauchy_lcdf.hpp @@ -41,7 +41,7 @@ return_type_t cauchy_lcdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "cauchy_lcdf"; + static constexpr const char* function = "cauchy_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale Parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/cauchy_lpdf.hpp b/stan/math/prim/prob/cauchy_lpdf.hpp index 6e16581e786..87549413f86 100644 --- a/stan/math/prim/prob/cauchy_lpdf.hpp +++ b/stan/math/prim/prob/cauchy_lpdf.hpp @@ -47,7 +47,7 @@ return_type_t cauchy_lpdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "cauchy_lpdf"; + static constexpr const char* function = "cauchy_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/cauchy_rng.hpp b/stan/math/prim/prob/cauchy_rng.hpp index 3a53abfa0d0..21ddc51d505 100644 --- a/stan/math/prim/prob/cauchy_rng.hpp +++ b/stan/math/prim/prob/cauchy_rng.hpp @@ -34,7 +34,7 @@ inline typename VectorBuilder::type cauchy_rng( const T_loc& mu, const T_scale& sigma, RNG& rng) { using boost::variate_generator; using boost::random::cauchy_distribution; - static const char* function = "cauchy_rng"; + static constexpr const char* function = "cauchy_rng"; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", diff --git a/stan/math/prim/prob/chi_square_cdf.hpp b/stan/math/prim/prob/chi_square_cdf.hpp index 8e8f6cf5148..313ae7c551b 100644 --- a/stan/math/prim/prob/chi_square_cdf.hpp +++ b/stan/math/prim/prob/chi_square_cdf.hpp @@ -40,7 +40,7 @@ return_type_t chi_square_cdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "chi_square_cdf"; + static constexpr const char* function = "chi_square_cdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/chi_square_lccdf.hpp b/stan/math/prim/prob/chi_square_lccdf.hpp index cb6bead9799..7abbb7770b8 100644 --- a/stan/math/prim/prob/chi_square_lccdf.hpp +++ b/stan/math/prim/prob/chi_square_lccdf.hpp @@ -42,7 +42,7 @@ return_type_t chi_square_lccdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "chi_square_lccdf"; + static constexpr const char* function = "chi_square_lccdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/chi_square_lcdf.hpp b/stan/math/prim/prob/chi_square_lcdf.hpp index 5fefad3fe3a..1dc229822de 100644 --- a/stan/math/prim/prob/chi_square_lcdf.hpp +++ b/stan/math/prim/prob/chi_square_lcdf.hpp @@ -42,7 +42,7 @@ return_type_t chi_square_lcdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "chi_square_lcdf"; + static constexpr const char* function = "chi_square_lcdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/chi_square_lpdf.hpp b/stan/math/prim/prob/chi_square_lpdf.hpp index 885d9a3c988..83ec52eabf5 100644 --- a/stan/math/prim/prob/chi_square_lpdf.hpp +++ b/stan/math/prim/prob/chi_square_lpdf.hpp @@ -47,7 +47,7 @@ return_type_t chi_square_lpdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using T_partials_array = Eigen::Array; using std::log; - static const char* function = "chi_square_lpdf"; + static constexpr const char* function = "chi_square_lpdf"; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; check_consistent_sizes(function, "Random variable", y, diff --git a/stan/math/prim/prob/chi_square_rng.hpp b/stan/math/prim/prob/chi_square_rng.hpp index 16c3f122eb0..559b67bd88e 100644 --- a/stan/math/prim/prob/chi_square_rng.hpp +++ b/stan/math/prim/prob/chi_square_rng.hpp @@ -30,7 +30,7 @@ inline typename VectorBuilder::type chi_square_rng( using boost::variate_generator; using boost::random::chi_squared_distribution; using T_nu_ref = ref_type_t; - static const char* function = "chi_square_rng"; + static constexpr const char* function = "chi_square_rng"; T_nu_ref nu_ref = nu; check_positive_finite(function, "Degrees of freedom parameter", nu_ref); diff --git a/stan/math/prim/prob/dirichlet_lpdf.hpp b/stan/math/prim/prob/dirichlet_lpdf.hpp index e19321d7c48..f14ae1def59 100644 --- a/stan/math/prim/prob/dirichlet_lpdf.hpp +++ b/stan/math/prim/prob/dirichlet_lpdf.hpp @@ -62,7 +62,7 @@ return_type_t dirichlet_lpdf(const T_prob& theta, using T_partials_array = typename Eigen::Array; using T_theta_ref = ref_type_t; using T_alpha_ref = ref_type_t; - static const char* function = "dirichlet_lpdf"; + static constexpr const char* function = "dirichlet_lpdf"; T_theta_ref theta_ref = theta; T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/discrete_range_cdf.hpp b/stan/math/prim/prob/discrete_range_cdf.hpp index f3672237339..49c18842244 100644 --- a/stan/math/prim/prob/discrete_range_cdf.hpp +++ b/stan/math/prim/prob/discrete_range_cdf.hpp @@ -37,7 +37,7 @@ namespace math { template double discrete_range_cdf(const T_y& y, const T_lower& lower, const T_upper& upper) { - static const char* function = "discrete_range_cdf"; + static constexpr const char* function = "discrete_range_cdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); check_greater_or_equal(function, "Upper bound parameter", upper, lower); diff --git a/stan/math/prim/prob/discrete_range_lccdf.hpp b/stan/math/prim/prob/discrete_range_lccdf.hpp index d58736fec1a..1c67cee0417 100644 --- a/stan/math/prim/prob/discrete_range_lccdf.hpp +++ b/stan/math/prim/prob/discrete_range_lccdf.hpp @@ -37,7 +37,7 @@ namespace math { template double discrete_range_lccdf(const T_y& y, const T_lower& lower, const T_upper& upper) { - static const char* function = "discrete_range_lccdf"; + static constexpr const char* function = "discrete_range_lccdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); check_greater_or_equal(function, "Upper bound parameter", upper, lower); diff --git a/stan/math/prim/prob/discrete_range_lcdf.hpp b/stan/math/prim/prob/discrete_range_lcdf.hpp index aa7d75fb7ca..8a64df8bc29 100644 --- a/stan/math/prim/prob/discrete_range_lcdf.hpp +++ b/stan/math/prim/prob/discrete_range_lcdf.hpp @@ -37,7 +37,7 @@ namespace math { template double discrete_range_lcdf(const T_y& y, const T_lower& lower, const T_upper& upper) { - static const char* function = "discrete_range_lcdf"; + static constexpr const char* function = "discrete_range_lcdf"; check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); check_greater_or_equal(function, "Upper bound parameter", upper, lower); diff --git a/stan/math/prim/prob/discrete_range_lpmf.hpp b/stan/math/prim/prob/discrete_range_lpmf.hpp index df153064672..1539a4caa71 100644 --- a/stan/math/prim/prob/discrete_range_lpmf.hpp +++ b/stan/math/prim/prob/discrete_range_lpmf.hpp @@ -46,7 +46,7 @@ template double discrete_range_lpmf(const T_y& y, const T_lower& lower, const T_upper& upper) { using std::log; - static const char* function = "discrete_range_lpmf"; + static constexpr const char* function = "discrete_range_lpmf"; check_not_nan(function, "Random variable", y); check_consistent_sizes(function, "Lower bound parameter", lower, "Upper bound parameter", upper); diff --git a/stan/math/prim/prob/discrete_range_rng.hpp b/stan/math/prim/prob/discrete_range_rng.hpp index 9f0bbb1f514..2dacf745339 100644 --- a/stan/math/prim/prob/discrete_range_rng.hpp +++ b/stan/math/prim/prob/discrete_range_rng.hpp @@ -34,7 +34,7 @@ namespace math { template inline typename VectorBuilder::type discrete_range_rng(const T_lower& lower, const T_upper& upper, RNG& rng) { - static const char* function = "discrete_range_rng"; + static constexpr const char* function = "discrete_range_rng"; using boost::variate_generator; using boost::random::uniform_int_distribution; check_consistent_sizes(function, "Lower bound parameter", lower, diff --git a/stan/math/prim/prob/double_exponential_cdf.hpp b/stan/math/prim/prob/double_exponential_cdf.hpp index 49424f8cfd1..ba1d816bf94 100644 --- a/stan/math/prim/prob/double_exponential_cdf.hpp +++ b/stan/math/prim/prob/double_exponential_cdf.hpp @@ -48,7 +48,7 @@ return_type_t double_exponential_cdf( using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "double_exponential_cdf"; + static constexpr const char* function = "double_exponential_cdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; T_sigma_ref sigma_ref = sigma; diff --git a/stan/math/prim/prob/double_exponential_lccdf.hpp b/stan/math/prim/prob/double_exponential_lccdf.hpp index 774e4223cb6..c8dc13114fa 100644 --- a/stan/math/prim/prob/double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/double_exponential_lccdf.hpp @@ -40,7 +40,7 @@ return_type_t double_exponential_lccdf( using T_partials_return = partials_return_t; using std::exp; using std::log; - static const char* function = "double_exponential_lccdf"; + static constexpr const char* function = "double_exponential_lccdf"; using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; diff --git a/stan/math/prim/prob/double_exponential_lcdf.hpp b/stan/math/prim/prob/double_exponential_lcdf.hpp index 1bf83bf6cc8..a5333e38978 100644 --- a/stan/math/prim/prob/double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/double_exponential_lcdf.hpp @@ -42,7 +42,7 @@ return_type_t double_exponential_lcdf( using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "double_exponential_lcdf"; + static constexpr const char* function = "double_exponential_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale Parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/double_exponential_lpdf.hpp b/stan/math/prim/prob/double_exponential_lpdf.hpp index 3db919362d2..efe31656e59 100644 --- a/stan/math/prim/prob/double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/double_exponential_lpdf.hpp @@ -45,7 +45,7 @@ return_type_t double_exponential_lpdf( using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "double_exponential_lpdf"; + static constexpr const char* function = "double_exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/double_exponential_rng.hpp b/stan/math/prim/prob/double_exponential_rng.hpp index 856ccc946b4..a5ee59a89ac 100644 --- a/stan/math/prim/prob/double_exponential_rng.hpp +++ b/stan/math/prim/prob/double_exponential_rng.hpp @@ -38,7 +38,7 @@ double_exponential_rng(const T_loc& mu, const T_scale& sigma, RNG& rng) { using boost::random::uniform_real_distribution; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "double_exponential_rng"; + static constexpr const char* function = "double_exponential_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/exp_mod_normal_cdf.hpp b/stan/math/prim/prob/exp_mod_normal_cdf.hpp index 368061eedbc..c851ea8e0c7 100644 --- a/stan/math/prim/prob/exp_mod_normal_cdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_cdf.hpp @@ -36,7 +36,7 @@ return_type_t exp_mod_normal_cdf( using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_lambda_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exp_mod_normal_cdf"; + static constexpr const char* function = "exp_mod_normal_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", lambda); diff --git a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp index 115eb02ee81..46cd8caec2f 100644 --- a/stan/math/prim/prob/exp_mod_normal_lccdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lccdf.hpp @@ -37,7 +37,7 @@ return_type_t exp_mod_normal_lccdf( using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_lambda_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exp_mod_normal_lccdf"; + static constexpr const char* function = "exp_mod_normal_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", lambda); diff --git a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp index ee2f0bd3438..00816a17382 100644 --- a/stan/math/prim/prob/exp_mod_normal_lcdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lcdf.hpp @@ -37,7 +37,7 @@ return_type_t exp_mod_normal_lcdf( using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_lambda_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exp_mod_normal_lcdf"; + static constexpr const char* function = "exp_mod_normal_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", lambda); diff --git a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp index ba3eddbcbde..783aa3058b6 100644 --- a/stan/math/prim/prob/exp_mod_normal_lpdf.hpp +++ b/stan/math/prim/prob/exp_mod_normal_lpdf.hpp @@ -35,7 +35,7 @@ return_type_t exp_mod_normal_lpdf( using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_lambda_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exp_mod_normal_lpdf"; + static constexpr const char* function = "exp_mod_normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Inv_scale paramter", lambda); diff --git a/stan/math/prim/prob/exp_mod_normal_rng.hpp b/stan/math/prim/prob/exp_mod_normal_rng.hpp index 07c4cffde2b..84df8fd1733 100644 --- a/stan/math/prim/prob/exp_mod_normal_rng.hpp +++ b/stan/math/prim/prob/exp_mod_normal_rng.hpp @@ -39,7 +39,7 @@ template inline typename VectorBuilder::type exp_mod_normal_rng(const T_loc& mu, const T_scale& sigma, const T_inv_scale& lambda, RNG& rng) { - static const char* function = "exp_mod_normal_rng"; + static constexpr const char* function = "exp_mod_normal_rng"; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; using T_lambda_ref = ref_type_t; diff --git a/stan/math/prim/prob/exponential_cdf.hpp b/stan/math/prim/prob/exponential_cdf.hpp index 3fe987a88f0..868b946da16 100644 --- a/stan/math/prim/prob/exponential_cdf.hpp +++ b/stan/math/prim/prob/exponential_cdf.hpp @@ -39,7 +39,7 @@ return_type_t exponential_cdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_beta_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exponential_cdf"; + static constexpr const char* function = "exponential_cdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lccdf.hpp b/stan/math/prim/prob/exponential_lccdf.hpp index c48c90ab9d3..2ea5b3bf9f1 100644 --- a/stan/math/prim/prob/exponential_lccdf.hpp +++ b/stan/math/prim/prob/exponential_lccdf.hpp @@ -24,7 +24,7 @@ return_type_t exponential_lccdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_beta_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exponential_lccdf"; + static constexpr const char* function = "exponential_lccdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lcdf.hpp b/stan/math/prim/prob/exponential_lcdf.hpp index 85142f9cfa0..1200a42cd1e 100644 --- a/stan/math/prim/prob/exponential_lcdf.hpp +++ b/stan/math/prim/prob/exponential_lcdf.hpp @@ -27,7 +27,7 @@ return_type_t exponential_lcdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_beta_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exponential_lcdf"; + static constexpr const char* function = "exponential_lcdf"; T_y_ref y_ref = y; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/exponential_lpdf.hpp b/stan/math/prim/prob/exponential_lpdf.hpp index 18f3bbfd0da..4d16fed2946 100644 --- a/stan/math/prim/prob/exponential_lpdf.hpp +++ b/stan/math/prim/prob/exponential_lpdf.hpp @@ -56,7 +56,7 @@ return_type_t exponential_lpdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_beta_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "exponential_lpdf"; + static constexpr const char* function = "exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Inverse scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/exponential_rng.hpp b/stan/math/prim/prob/exponential_rng.hpp index 981067e3d79..5d97ca02916 100644 --- a/stan/math/prim/prob/exponential_rng.hpp +++ b/stan/math/prim/prob/exponential_rng.hpp @@ -29,7 +29,7 @@ inline typename VectorBuilder::type exponential_rng( const T_inv& beta, RNG& rng) { using boost::exponential_distribution; using boost::variate_generator; - static const char* function = "exponential_rng"; + static constexpr const char* function = "exponential_rng"; using T_beta_ref = ref_type_t; T_beta_ref beta_ref = beta; check_positive_finite(function, "Inverse scale parameter", beta_ref); diff --git a/stan/math/prim/prob/frechet_cdf.hpp b/stan/math/prim/prob/frechet_cdf.hpp index a6545afed46..88c35879203 100644 --- a/stan/math/prim/prob/frechet_cdf.hpp +++ b/stan/math/prim/prob/frechet_cdf.hpp @@ -33,7 +33,7 @@ return_type_t frechet_cdf(const T_y& y, using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; using std::pow; - static const char* function = "frechet_cdf"; + static constexpr const char* function = "frechet_cdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; T_sigma_ref sigma_ref = sigma; diff --git a/stan/math/prim/prob/frechet_lccdf.hpp b/stan/math/prim/prob/frechet_lccdf.hpp index 16a984aefbb..10cbbdb4727 100644 --- a/stan/math/prim/prob/frechet_lccdf.hpp +++ b/stan/math/prim/prob/frechet_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t frechet_lccdf(const T_y& y, using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "frechet_lccdf"; + static constexpr const char* function = "frechet_lccdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; T_sigma_ref sigma_ref = sigma; diff --git a/stan/math/prim/prob/frechet_lcdf.hpp b/stan/math/prim/prob/frechet_lcdf.hpp index de48aaa57c4..09b4e4d657a 100644 --- a/stan/math/prim/prob/frechet_lcdf.hpp +++ b/stan/math/prim/prob/frechet_lcdf.hpp @@ -30,7 +30,7 @@ return_type_t frechet_lcdf(const T_y& y, using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "frechet_lcdf"; + static constexpr const char* function = "frechet_lcdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; T_sigma_ref sigma_ref = sigma; diff --git a/stan/math/prim/prob/frechet_lpdf.hpp b/stan/math/prim/prob/frechet_lpdf.hpp index b305f0a8f20..d5c8b3c86f4 100644 --- a/stan/math/prim/prob/frechet_lpdf.hpp +++ b/stan/math/prim/prob/frechet_lpdf.hpp @@ -35,7 +35,7 @@ return_type_t frechet_lpdf(const T_y& y, using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "frechet_lpdf"; + static constexpr const char* function = "frechet_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/frechet_rng.hpp b/stan/math/prim/prob/frechet_rng.hpp index 6cb91bc25e1..0c15df9bc35 100644 --- a/stan/math/prim/prob/frechet_rng.hpp +++ b/stan/math/prim/prob/frechet_rng.hpp @@ -35,7 +35,7 @@ inline typename VectorBuilder::type frechet_rng( using boost::random::weibull_distribution; using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "frechet_rng"; + static constexpr const char* function = "frechet_rng"; check_consistent_sizes(function, "Shape parameter", alpha, "Scale Parameter", sigma); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gamma_cdf.hpp b/stan/math/prim/prob/gamma_cdf.hpp index fb9f88f788c..32e404678af 100644 --- a/stan/math/prim/prob/gamma_cdf.hpp +++ b/stan/math/prim/prob/gamma_cdf.hpp @@ -46,7 +46,7 @@ return_type_t gamma_cdf(const T_y& y, using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; using std::exp; - static const char* function = "gamma_cdf"; + static constexpr const char* function = "gamma_cdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Inverse scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gamma_lccdf.hpp b/stan/math/prim/prob/gamma_lccdf.hpp index c031c1a7e63..aa0d4e13333 100644 --- a/stan/math/prim/prob/gamma_lccdf.hpp +++ b/stan/math/prim/prob/gamma_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t gamma_lccdf(const T_y& y, using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "gamma_lccdf"; + static constexpr const char* function = "gamma_lccdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Inverse scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gamma_lcdf.hpp b/stan/math/prim/prob/gamma_lcdf.hpp index b1295a756dc..57d23b230c7 100644 --- a/stan/math/prim/prob/gamma_lcdf.hpp +++ b/stan/math/prim/prob/gamma_lcdf.hpp @@ -32,7 +32,7 @@ return_type_t gamma_lcdf(const T_y& y, using T_y_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "gamma_lcdf"; + static constexpr const char* function = "gamma_lcdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Inverse scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gamma_lpdf.hpp b/stan/math/prim/prob/gamma_lpdf.hpp index 65871e075d4..1e46a9c2da1 100644 --- a/stan/math/prim/prob/gamma_lpdf.hpp +++ b/stan/math/prim/prob/gamma_lpdf.hpp @@ -57,7 +57,7 @@ return_type_t gamma_lpdf(const T_y& y, using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_beta_ref = ref_type_if_t::value, T_inv_scale>; - static const char* function = "gamma_lpdf"; + static constexpr const char* function = "gamma_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Inverse scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gamma_rng.hpp b/stan/math/prim/prob/gamma_rng.hpp index 7a1ac651b18..c609e34214e 100644 --- a/stan/math/prim/prob/gamma_rng.hpp +++ b/stan/math/prim/prob/gamma_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type gamma_rng( using boost::variate_generator; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "gamma_rng"; + static constexpr const char* function = "gamma_rng"; check_consistent_sizes(function, "Shape parameter", alpha, "Inverse scale Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_lpdf.hpp b/stan/math/prim/prob/gaussian_dlm_obs_lpdf.hpp index 0399cad5f81..f95db8537a3 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_lpdf.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_lpdf.hpp @@ -72,7 +72,7 @@ inline return_type_t gaussian_dlm_obs_lpdf( const T_m0& m0, const T_C0& C0) { using T_lp = return_type_t; using std::pow; - static const char* function = "gaussian_dlm_obs_lpdf"; + static constexpr const char* function = "gaussian_dlm_obs_lpdf"; check_size_match(function, "columns of F", F.cols(), "rows of y", y.rows()); check_size_match(function, "rows of F", F.rows(), "rows of G", G.rows()); check_size_match(function, "rows of V", V.rows(), "rows of y", y.rows()); @@ -197,7 +197,7 @@ inline return_type_t gaussian_dlm_obs_lpdf( const T_m0& m0, const T_C0& C0) { using T_lp = return_type_t; using std::log; - static const char* function = "gaussian_dlm_obs_lpdf"; + static constexpr const char* function = "gaussian_dlm_obs_lpdf"; check_size_match(function, "columns of F", F.cols(), "rows of y", y.rows()); check_size_match(function, "rows of F", F.rows(), "rows of G", G.rows()); check_size_match(function, "rows of G", G.rows(), "columns of G", G.cols()); diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 39e1af623dd..9ac4f2184c1 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static const char *function = "gaussian_dlm_obs_rng"; + static constexpr const char* function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/gumbel_cdf.hpp b/stan/math/prim/prob/gumbel_cdf.hpp index 17fc2021872..9b2bb0f575b 100644 --- a/stan/math/prim/prob/gumbel_cdf.hpp +++ b/stan/math/prim/prob/gumbel_cdf.hpp @@ -43,7 +43,7 @@ return_type_t gumbel_cdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_beta_ref = ref_type_if_t::value, T_scale>; - static const char* function = "gumbel_cdf"; + static constexpr const char* function = "gumbel_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gumbel_lccdf.hpp b/stan/math/prim/prob/gumbel_lccdf.hpp index 394a78c5113..fc325cf67c4 100644 --- a/stan/math/prim/prob/gumbel_lccdf.hpp +++ b/stan/math/prim/prob/gumbel_lccdf.hpp @@ -42,7 +42,7 @@ return_type_t gumbel_lccdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_beta_ref = ref_type_if_t::value, T_scale>; - static const char* function = "gumbel_lccdf"; + static constexpr const char* function = "gumbel_lccdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; T_beta_ref beta_ref = beta; diff --git a/stan/math/prim/prob/gumbel_lcdf.hpp b/stan/math/prim/prob/gumbel_lcdf.hpp index f91f2557898..ac7579f46ea 100644 --- a/stan/math/prim/prob/gumbel_lcdf.hpp +++ b/stan/math/prim/prob/gumbel_lcdf.hpp @@ -41,7 +41,7 @@ return_type_t gumbel_lcdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_beta_ref = ref_type_if_t::value, T_scale>; - static const char* function = "gumbel_lcdf"; + static constexpr const char* function = "gumbel_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gumbel_lpdf.hpp b/stan/math/prim/prob/gumbel_lpdf.hpp index 22814b8982b..a34c8908471 100644 --- a/stan/math/prim/prob/gumbel_lpdf.hpp +++ b/stan/math/prim/prob/gumbel_lpdf.hpp @@ -43,7 +43,7 @@ return_type_t gumbel_lpdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_beta_ref = ref_type_if_t::value, T_scale>; - static const char* function = "gumbel_lpdf"; + static constexpr const char* function = "gumbel_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/gumbel_rng.hpp b/stan/math/prim/prob/gumbel_rng.hpp index ff8b6ca4db1..b6ece64a4ec 100644 --- a/stan/math/prim/prob/gumbel_rng.hpp +++ b/stan/math/prim/prob/gumbel_rng.hpp @@ -37,7 +37,7 @@ inline typename VectorBuilder::type gumbel_rng( using boost::variate_generator; using T_mu_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "gumbel_rng"; + static constexpr const char* function = "gumbel_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", beta); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/hypergeometric_lpmf.hpp b/stan/math/prim/prob/hypergeometric_lpmf.hpp index adba7f41854..ce61d96d749 100644 --- a/stan/math/prim/prob/hypergeometric_lpmf.hpp +++ b/stan/math/prim/prob/hypergeometric_lpmf.hpp @@ -17,7 +17,7 @@ namespace math { template double hypergeometric_lpmf(const T_n& n, const T_N& N, const T_a& a, const T_b& b) { - static const char* function = "hypergeometric_lpmf"; + static constexpr const char* function = "hypergeometric_lpmf"; check_bounded(function, "Successes variable", value_of(n), 0, a); check_consistent_sizes(function, "Successes variable", n, "Draws parameter", N, "Successes in population parameter", a, diff --git a/stan/math/prim/prob/hypergeometric_rng.hpp b/stan/math/prim/prob/hypergeometric_rng.hpp index aa53734a231..b6d7e410f46 100644 --- a/stan/math/prim/prob/hypergeometric_rng.hpp +++ b/stan/math/prim/prob/hypergeometric_rng.hpp @@ -14,7 +14,7 @@ template inline int hypergeometric_rng(int N, int a, int b, RNG& rng) { using boost::variate_generator; using boost::math::hypergeometric_distribution; - static const char* function = "hypergeometric_rng"; + static constexpr const char* function = "hypergeometric_rng"; check_bounded(function, "Draws parameter", value_of(N), 0, a + b); check_positive(function, "Draws parameter", N); check_positive(function, "Successes in population parameter", a); diff --git a/stan/math/prim/prob/inv_chi_square_cdf.hpp b/stan/math/prim/prob/inv_chi_square_cdf.hpp index 429dbfadcc7..96a027e61f2 100644 --- a/stan/math/prim/prob/inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_cdf.hpp @@ -40,7 +40,7 @@ return_type_t inv_chi_square_cdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "inv_chi_square_cdf"; + static constexpr const char* function = "inv_chi_square_cdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/inv_chi_square_lccdf.hpp b/stan/math/prim/prob/inv_chi_square_lccdf.hpp index e7c6a1e9c88..defee8bd0d9 100644 --- a/stan/math/prim/prob/inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lccdf.hpp @@ -42,7 +42,7 @@ return_type_t inv_chi_square_lccdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "inv_chi_square_lccdf"; + static constexpr const char* function = "inv_chi_square_lccdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/inv_chi_square_lcdf.hpp b/stan/math/prim/prob/inv_chi_square_lcdf.hpp index b48922fbd63..a5152b8d977 100644 --- a/stan/math/prim/prob/inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lcdf.hpp @@ -42,7 +42,7 @@ return_type_t inv_chi_square_lcdf(const T_y& y, const T_dof& nu) { using std::pow; using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; - static const char* function = "inv_chi_square_lcdf"; + static constexpr const char* function = "inv_chi_square_lcdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/inv_chi_square_lpdf.hpp b/stan/math/prim/prob/inv_chi_square_lpdf.hpp index d47c4355017..05f5415ce5b 100644 --- a/stan/math/prim/prob/inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/inv_chi_square_lpdf.hpp @@ -50,7 +50,7 @@ return_type_t inv_chi_square_lpdf(const T_y& y, const T_dof& nu) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_nu_ref = ref_type_if_t::value, T_dof>; - static const char* function = "inv_chi_square_lpdf"; + static constexpr const char* function = "inv_chi_square_lpdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/inv_chi_square_rng.hpp b/stan/math/prim/prob/inv_chi_square_rng.hpp index b43b3c990b6..a15c23d323e 100644 --- a/stan/math/prim/prob/inv_chi_square_rng.hpp +++ b/stan/math/prim/prob/inv_chi_square_rng.hpp @@ -30,7 +30,7 @@ inline typename VectorBuilder::type inv_chi_square_rng( using boost::variate_generator; using boost::random::chi_squared_distribution; using T_nu_ref = ref_type_t; - static const char* function = "inv_chi_square_rng"; + static constexpr const char* function = "inv_chi_square_rng"; T_nu_ref nu_ref = nu; check_positive_finite(function, "Degrees of freedom parameter", nu_ref); diff --git a/stan/math/prim/prob/inv_gamma_cdf.hpp b/stan/math/prim/prob/inv_gamma_cdf.hpp index 3ac21f757d4..841fdcdf0a2 100644 --- a/stan/math/prim/prob/inv_gamma_cdf.hpp +++ b/stan/math/prim/prob/inv_gamma_cdf.hpp @@ -46,7 +46,7 @@ return_type_t inv_gamma_cdf(const T_y& y, using T_beta_ref = ref_type_t; using std::exp; using std::pow; - static const char* function = "inv_gamma_cdf"; + static constexpr const char* function = "inv_gamma_cdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale Parameter", beta); diff --git a/stan/math/prim/prob/inv_gamma_lccdf.hpp b/stan/math/prim/prob/inv_gamma_lccdf.hpp index c731eccd0e3..d1eb5c71324 100644 --- a/stan/math/prim/prob/inv_gamma_lccdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t inv_gamma_lccdf(const T_y& y, using std::exp; using std::log; using std::pow; - static const char* function = "inv_gamma_lccdf"; + static constexpr const char* function = "inv_gamma_lccdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale Parameter", beta); diff --git a/stan/math/prim/prob/inv_gamma_lcdf.hpp b/stan/math/prim/prob/inv_gamma_lcdf.hpp index 7ad55a35302..0d44afcf217 100644 --- a/stan/math/prim/prob/inv_gamma_lcdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lcdf.hpp @@ -32,7 +32,7 @@ return_type_t inv_gamma_lcdf(const T_y& y, using std::exp; using std::log; using std::pow; - static const char* function = "inv_gamma_lcdf"; + static constexpr const char* function = "inv_gamma_lcdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale Parameter", beta); diff --git a/stan/math/prim/prob/inv_gamma_lpdf.hpp b/stan/math/prim/prob/inv_gamma_lpdf.hpp index 0184a6ba572..308e7a7b089 100644 --- a/stan/math/prim/prob/inv_gamma_lpdf.hpp +++ b/stan/math/prim/prob/inv_gamma_lpdf.hpp @@ -48,7 +48,7 @@ return_type_t inv_gamma_lpdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_beta_ref = ref_type_if_t::value, T_scale>; - static const char* function = "inv_gamma_lpdf"; + static constexpr const char* function = "inv_gamma_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale parameter", beta); diff --git a/stan/math/prim/prob/inv_gamma_rng.hpp b/stan/math/prim/prob/inv_gamma_rng.hpp index 6923a934a00..cd7baeb7bc1 100644 --- a/stan/math/prim/prob/inv_gamma_rng.hpp +++ b/stan/math/prim/prob/inv_gamma_rng.hpp @@ -36,7 +36,7 @@ inv_gamma_rng(const T_shape& alpha, const T_scale& beta, RNG& rng) { using boost::random::gamma_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "inv_gamma_rng"; + static constexpr const char* function = "inv_gamma_rng"; check_consistent_sizes(function, "Shape parameter", alpha, "Scale Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp b/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp index ca5683511ad..8f9d324d281 100644 --- a/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/inv_wishart_cholesky_lpdf.hpp @@ -47,7 +47,7 @@ return_type_t inv_wishart_cholesky_lpdf( using T_nu_ref = ref_type_t; using T_L_S_ref = ref_type_t; using T_return = return_type_t; - static const char* function = "inv_wishart_cholesky_lpdf"; + static constexpr const char* function = "inv_wishart_cholesky_lpdf"; Eigen::Index k = L_Y.rows(); check_size_match(function, "Rows of Random variable", L_Y.rows(), "columns of scale parameter", L_S.rows()); diff --git a/stan/math/prim/prob/inv_wishart_cholesky_rng.hpp b/stan/math/prim/prob/inv_wishart_cholesky_rng.hpp index c4dadbb3108..a12c3a8fdbe 100644 --- a/stan/math/prim/prob/inv_wishart_cholesky_rng.hpp +++ b/stan/math/prim/prob/inv_wishart_cholesky_rng.hpp @@ -31,7 +31,7 @@ inline Eigen::MatrixXd inv_wishart_cholesky_rng(double nu, const Eigen::MatrixXd& L_S, RNG& rng) { using Eigen::MatrixXd; - static const char* function = "inv_wishart_cholesky_rng"; + static constexpr const char* function = "inv_wishart_cholesky_rng"; index_type_t k = L_S.rows(); check_greater(function, "degrees of freedom > dims - 1", nu, k - 1); check_positive(function, "Cholesky Scale matrix", L_S.diagonal()); diff --git a/stan/math/prim/prob/inv_wishart_lpdf.hpp b/stan/math/prim/prob/inv_wishart_lpdf.hpp index f830cc3f2f4..9169a0f3ab1 100644 --- a/stan/math/prim/prob/inv_wishart_lpdf.hpp +++ b/stan/math/prim/prob/inv_wishart_lpdf.hpp @@ -50,7 +50,7 @@ return_type_t inv_wishart_lpdf(const T_y& W, using T_W_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_S_ref = ref_type_t; - static const char* function = "inv_wishart_lpdf"; + static constexpr const char* function = "inv_wishart_lpdf"; check_size_match(function, "Rows of random variable", W.rows(), "columns of scale parameter", S.rows()); check_square(function, "random variable", W); diff --git a/stan/math/prim/prob/inv_wishart_rng.hpp b/stan/math/prim/prob/inv_wishart_rng.hpp index 56409b1359b..d4eb8f0f527 100644 --- a/stan/math/prim/prob/inv_wishart_rng.hpp +++ b/stan/math/prim/prob/inv_wishart_rng.hpp @@ -13,7 +13,7 @@ template inline Eigen::MatrixXd inv_wishart_rng(double nu, const Eigen::MatrixXd& S, RNG& rng) { using Eigen::MatrixXd; - static const char* function = "inv_wishart_rng"; + static constexpr const char* function = "inv_wishart_rng"; index_type_t k = S.rows(); check_greater(function, "degrees of freedom > dims - 1", nu, k - 1); check_square(function, "scale parameter", S); diff --git a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp index 878541a8502..00d1bdfe404 100644 --- a/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_cholesky_lpdf.hpp @@ -18,7 +18,7 @@ template return_type_t lkj_corr_cholesky_lpdf(const T_covar& L, const T_shape& eta) { using lp_ret = return_type_t; - static const char* function = "lkj_corr_cholesky_lpdf"; + static constexpr const char* function = "lkj_corr_cholesky_lpdf"; const auto& L_ref = to_ref(L); check_positive(function, "Shape parameter", eta); check_lower_triangular(function, "Random variable", L_ref); diff --git a/stan/math/prim/prob/lkj_corr_cholesky_rng.hpp b/stan/math/prim/prob/lkj_corr_cholesky_rng.hpp index 9cfa57c5981..170ee4314b8 100644 --- a/stan/math/prim/prob/lkj_corr_cholesky_rng.hpp +++ b/stan/math/prim/prob/lkj_corr_cholesky_rng.hpp @@ -11,7 +11,7 @@ namespace math { template inline Eigen::MatrixXd lkj_corr_cholesky_rng(size_t K, double eta, RNG& rng) { - static const char* function = "lkj_corr_cholesky_rng"; + static constexpr const char* function = "lkj_corr_cholesky_rng"; check_positive(function, "Shape parameter", eta); Eigen::ArrayXd CPCs((K * (K - 1)) / 2); diff --git a/stan/math/prim/prob/lkj_corr_lpdf.hpp b/stan/math/prim/prob/lkj_corr_lpdf.hpp index 678a6225c40..894d5030681 100644 --- a/stan/math/prim/prob/lkj_corr_lpdf.hpp +++ b/stan/math/prim/prob/lkj_corr_lpdf.hpp @@ -47,7 +47,7 @@ return_type_t do_lkj_constant(const T_shape& eta, // eta > 0; eta == 1 <-> uniform] template return_type_t lkj_corr_lpdf(const T_y& y, const T_shape& eta) { - static const char* function = "lkj_corr_lpdf"; + static constexpr const char* function = "lkj_corr_lpdf"; return_type_t lp(0.0); const auto& y_ref = to_ref(y); diff --git a/stan/math/prim/prob/lkj_corr_rng.hpp b/stan/math/prim/prob/lkj_corr_rng.hpp index 8e4717cb3f7..70a81889010 100644 --- a/stan/math/prim/prob/lkj_corr_rng.hpp +++ b/stan/math/prim/prob/lkj_corr_rng.hpp @@ -24,7 +24,7 @@ namespace math { */ template inline Eigen::MatrixXd lkj_corr_rng(size_t K, double eta, RNG& rng) { - static const char* function = "lkj_corr_rng"; + static constexpr const char* function = "lkj_corr_rng"; check_positive(function, "Shape parameter", eta); return multiply_lower_tri_self_transpose(lkj_corr_cholesky_rng(K, eta, rng)); } diff --git a/stan/math/prim/prob/lkj_cov_lpdf.hpp b/stan/math/prim/prob/lkj_cov_lpdf.hpp index fc2d8375da8..b8baceda960 100644 --- a/stan/math/prim/prob/lkj_cov_lpdf.hpp +++ b/stan/math/prim/prob/lkj_cov_lpdf.hpp @@ -22,7 +22,7 @@ return_type_t lkj_cov_lpdf(const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { - static const char* function = "lkj_cov_lpdf"; + static constexpr const char* function = "lkj_cov_lpdf"; check_size_match(function, "Rows of location parameter", mu.rows(), "columns of scale parameter", sigma.rows()); check_square(function, "random variable", y); @@ -67,7 +67,7 @@ return_type_t lkj_cov_lpdf(const T_y& y, const T_loc& mu, const T_scale& sigma, const T_shape& eta) { - static const char* function = "lkj_cov_lpdf"; + static constexpr const char* function = "lkj_cov_lpdf"; check_positive(function, "Shape parameter", eta); check_finite(function, "Location parameter", mu); check_finite(function, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/logistic_cdf.hpp b/stan/math/prim/prob/logistic_cdf.hpp index e085e18aa68..f4fa9811242 100644 --- a/stan/math/prim/prob/logistic_cdf.hpp +++ b/stan/math/prim/prob/logistic_cdf.hpp @@ -28,7 +28,7 @@ return_type_t logistic_cdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "logistic_cdf"; + static constexpr const char* function = "logistic_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/logistic_lccdf.hpp b/stan/math/prim/prob/logistic_lccdf.hpp index 58346bb1001..4c0b54d8ea0 100644 --- a/stan/math/prim/prob/logistic_lccdf.hpp +++ b/stan/math/prim/prob/logistic_lccdf.hpp @@ -29,7 +29,7 @@ return_type_t logistic_lccdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "logistic_lccdf"; + static constexpr const char* function = "logistic_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/logistic_lcdf.hpp b/stan/math/prim/prob/logistic_lcdf.hpp index 31b142d0e94..f954b2e8e0f 100644 --- a/stan/math/prim/prob/logistic_lcdf.hpp +++ b/stan/math/prim/prob/logistic_lcdf.hpp @@ -29,7 +29,7 @@ return_type_t logistic_lcdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "logistic_lcdf"; + static constexpr const char* function = "logistic_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/logistic_lpdf.hpp b/stan/math/prim/prob/logistic_lpdf.hpp index f6359a50142..c83cb2a9cb8 100644 --- a/stan/math/prim/prob/logistic_lpdf.hpp +++ b/stan/math/prim/prob/logistic_lpdf.hpp @@ -30,7 +30,7 @@ return_type_t logistic_lpdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "logistic_lpdf"; + static constexpr const char* function = "logistic_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/logistic_rng.hpp b/stan/math/prim/prob/logistic_rng.hpp index ffb3315d09d..9b7e94f1484 100644 --- a/stan/math/prim/prob/logistic_rng.hpp +++ b/stan/math/prim/prob/logistic_rng.hpp @@ -37,7 +37,7 @@ inline typename VectorBuilder::type logistic_rng( using boost::random::exponential_distribution; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "logistic_rng"; + static constexpr const char* function = "logistic_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/loglogistic_cdf.hpp b/stan/math/prim/prob/loglogistic_cdf.hpp index 33d4ebb161c..cea7131419d 100644 --- a/stan/math/prim/prob/loglogistic_cdf.hpp +++ b/stan/math/prim/prob/loglogistic_cdf.hpp @@ -51,7 +51,7 @@ return_type_t loglogistic_cdf(const T_y& y, using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; using std::pow; - static const char* function = "loglogistic_cdf"; + static constexpr const char* function = "loglogistic_cdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", alpha, "Shape parameter", beta); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/loglogistic_lpdf.hpp b/stan/math/prim/prob/loglogistic_lpdf.hpp index c7bed9512bf..e79627f8946 100644 --- a/stan/math/prim/prob/loglogistic_lpdf.hpp +++ b/stan/math/prim/prob/loglogistic_lpdf.hpp @@ -50,7 +50,7 @@ return_type_t loglogistic_lpdf(const T_y& y, using T_scale_ref = ref_type_if_t::value, T_scale>; using T_shape_ref = ref_type_if_t::value, T_shape>; using std::pow; - static const char* function = "loglogistic_lpdf"; + static constexpr const char* function = "loglogistic_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", alpha, "Shape parameter", beta); diff --git a/stan/math/prim/prob/loglogistic_rng.hpp b/stan/math/prim/prob/loglogistic_rng.hpp index 06b43e7e3a1..fa92d93826e 100644 --- a/stan/math/prim/prob/loglogistic_rng.hpp +++ b/stan/math/prim/prob/loglogistic_rng.hpp @@ -37,7 +37,7 @@ loglogistic_rng(const T_scale& alpha, const T_shape& beta, RNG& rng) { using std::pow; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "loglogistic_rng"; + static constexpr const char* function = "loglogistic_rng"; check_consistent_sizes(function, "Scale parameter", alpha, "Shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/lognormal_cdf.hpp b/stan/math/prim/prob/lognormal_cdf.hpp index e2918d69fa6..8f7e86b1a43 100644 --- a/stan/math/prim/prob/lognormal_cdf.hpp +++ b/stan/math/prim/prob/lognormal_cdf.hpp @@ -31,7 +31,7 @@ return_type_t lognormal_cdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "lognormal_cdf"; + static constexpr const char* function = "lognormal_cdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/lognormal_lccdf.hpp b/stan/math/prim/prob/lognormal_lccdf.hpp index b95c5e42553..1c4f4fcaa18 100644 --- a/stan/math/prim/prob/lognormal_lccdf.hpp +++ b/stan/math/prim/prob/lognormal_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t lognormal_lccdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "lognormal_lccdf"; + static constexpr const char* function = "lognormal_lccdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/lognormal_lcdf.hpp b/stan/math/prim/prob/lognormal_lcdf.hpp index 25d22911ede..3bed38b9e9e 100644 --- a/stan/math/prim/prob/lognormal_lcdf.hpp +++ b/stan/math/prim/prob/lognormal_lcdf.hpp @@ -31,7 +31,7 @@ return_type_t lognormal_lcdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "lognormal_lcdf"; + static constexpr const char* function = "lognormal_lcdf"; T_y_ref y_ref = y; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/lognormal_lpdf.hpp b/stan/math/prim/prob/lognormal_lpdf.hpp index 422b19d65d6..a52cf1aad7a 100644 --- a/stan/math/prim/prob/lognormal_lpdf.hpp +++ b/stan/math/prim/prob/lognormal_lpdf.hpp @@ -31,7 +31,7 @@ return_type_t lognormal_lpdf(const T_y& y, const T_loc& mu, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "lognormal_lpdf"; + static constexpr const char* function = "lognormal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/lognormal_rng.hpp b/stan/math/prim/prob/lognormal_rng.hpp index d6e9c600bff..64adc0516c5 100644 --- a/stan/math/prim/prob/lognormal_rng.hpp +++ b/stan/math/prim/prob/lognormal_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type lognormal_rng( using boost::random::lognormal_distribution; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "lognormal_rng"; + static constexpr const char* function = "lognormal_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp b/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp index 5934363c209..7641f804997 100644 --- a/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_lpdf.hpp @@ -35,7 +35,7 @@ template * = nullptr> return_type_t matrix_normal_prec_lpdf( const T_y& y, const T_Mu& Mu, const T_Sigma& Sigma, const T_D& D) { - static const char* function = "matrix_normal_prec_lpdf"; + static constexpr const char* function = "matrix_normal_prec_lpdf"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index 8b814a33a68..b3d508060a8 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static const char *function = "matrix_normal_prec_rng"; + static constexpr const char* function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp index 5221afe9392..d250b2d2f96 100644 --- a/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_gp_cholesky_lpdf.hpp @@ -42,7 +42,7 @@ return_type_t multi_gp_cholesky_lpdf(const T_y& y, const T_covar& L, const T_w& w) { using T_lp = return_type_t; - static const char* function = "multi_gp_cholesky_lpdf"; + static constexpr const char* function = "multi_gp_cholesky_lpdf"; check_size_match(function, "Size of random variable (rows y)", y.rows(), "Size of kernel scales (w)", w.size()); check_size_match(function, "Size of random variable", y.cols(), diff --git a/stan/math/prim/prob/multi_gp_lpdf.hpp b/stan/math/prim/prob/multi_gp_lpdf.hpp index c416375873d..272aa6d1941 100644 --- a/stan/math/prim/prob/multi_gp_lpdf.hpp +++ b/stan/math/prim/prob/multi_gp_lpdf.hpp @@ -37,7 +37,7 @@ return_type_t multi_gp_lpdf(const T_y& y, const T_covar& Sigma, const T_w& w) { using T_lp = return_type_t; - static const char* function = "multi_gp_lpdf"; + static constexpr const char* function = "multi_gp_lpdf"; check_size_match(function, "Size of random variable (rows y)", y.rows(), "Size of kernel scales (w)", w.size()); check_size_match(function, "Size of random variable", y.cols(), diff --git a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp index 57af4c70056..079677011f9 100644 --- a/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_cholesky_lpdf.hpp @@ -47,7 +47,7 @@ template * = nullptr> return_type_t multi_normal_cholesky_lpdf( const T_y& y, const T_loc& mu, const T_covar& L) { - static const char* function = "multi_normal_cholesky_lpdf"; + static constexpr const char* function = "multi_normal_cholesky_lpdf"; using T_covar_elem = typename scalar_type::type; using T_return = return_type_t; using T_partials_return = partials_return_t; @@ -206,7 +206,7 @@ template * = nullptr> return_type_t multi_normal_cholesky_lpdf( const T_y& y, const T_loc& mu, const T_covar& L) { - static const char* function = "multi_normal_cholesky_lpdf"; + static constexpr const char* function = "multi_normal_cholesky_lpdf"; using T_covar_elem = typename scalar_type::type; using T_return = return_type_t; using T_partials_return = partials_return_t; diff --git a/stan/math/prim/prob/multi_normal_cholesky_rng.hpp b/stan/math/prim/prob/multi_normal_cholesky_rng.hpp index 2b8fa15209a..3f0872e4c2d 100644 --- a/stan/math/prim/prob/multi_normal_cholesky_rng.hpp +++ b/stan/math/prim/prob/multi_normal_cholesky_rng.hpp @@ -37,7 +37,7 @@ multi_normal_cholesky_rng( using boost::normal_distribution; using boost::variate_generator; - static const char* function = "multi_normal_cholesky_rng"; + static constexpr const char* function = "multi_normal_cholesky_rng"; vector_seq_view mu_vec(mu); size_t size_mu = mu_vec[0].size(); diff --git a/stan/math/prim/prob/multi_normal_lpdf.hpp b/stan/math/prim/prob/multi_normal_lpdf.hpp index 38f3f41da82..abad728f116 100644 --- a/stan/math/prim/prob/multi_normal_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_lpdf.hpp @@ -22,7 +22,7 @@ return_type_t multi_normal_lpdf(const T_y& y, using T_covar_elem = typename scalar_type::type; using lp_type = return_type_t; using Eigen::Dynamic; - static const char* function = "multi_normal_lpdf"; + static constexpr const char* function = "multi_normal_lpdf"; check_positive(function, "Covariance matrix rows", Sigma.rows()); check_consistent_sizes_mvt(function, "y", y, "mu", mu); diff --git a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp index 256e0160989..a12c9589a80 100644 --- a/stan/math/prim/prob/multi_normal_prec_lpdf.hpp +++ b/stan/math/prim/prob/multi_normal_prec_lpdf.hpp @@ -23,7 +23,7 @@ return_type_t multi_normal_prec_lpdf( using lp_type = return_type_t; using Eigen::Matrix; using std::vector; - static const char* function = "multi_normal_prec_lpdf"; + static constexpr const char* function = "multi_normal_prec_lpdf"; check_positive(function, "Precision matrix rows", Sigma.rows()); size_t number_of_y = size_mvt(y); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index 01831d284f8..a206fa79ea5 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static const char *function = "multi_normal_prec_rng"; + static constexpr const char* function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/prim/prob/multi_normal_rng.hpp b/stan/math/prim/prob/multi_normal_rng.hpp index 8f342306164..b30d5e1ae3a 100644 --- a/stan/math/prim/prob/multi_normal_rng.hpp +++ b/stan/math/prim/prob/multi_normal_rng.hpp @@ -36,7 +36,7 @@ multi_normal_rng(const T_loc& mu, RNG& rng) { using boost::normal_distribution; using boost::variate_generator; - static const char* function = "multi_normal_rng"; + static constexpr const char* function = "multi_normal_rng"; check_positive(function, "Covariance matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp b/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp index 6c116c994a5..04ba2f3f610 100644 --- a/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_cholesky_lpdf.hpp @@ -55,7 +55,7 @@ return_type_t multi_student_t_cholesky_lpdf( using T_mu_ref = ref_type_t; using T_L_ref = ref_type_t; - static const char* function = "multi_student_t_cholesky"; + static constexpr const char* function = "multi_student_t_cholesky"; check_not_nan(function, "Degrees of freedom parameter", nu); check_positive(function, "Degrees of freedom parameter", nu); check_finite(function, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/multi_student_t_cholesky_rng.hpp b/stan/math/prim/prob/multi_student_t_cholesky_rng.hpp index 13d8c69584e..074f14f337a 100644 --- a/stan/math/prim/prob/multi_student_t_cholesky_rng.hpp +++ b/stan/math/prim/prob/multi_student_t_cholesky_rng.hpp @@ -45,7 +45,7 @@ multi_student_t_cholesky_rng(double nu, const T_loc& mu, using boost::variate_generator; using boost::random::gamma_distribution; - static const char* function = "multi_student_t_cholesky_rng"; + static constexpr const char* function = "multi_student_t_cholesky_rng"; check_not_nan(function, "Degrees of freedom parameter", nu); check_positive(function, "Degrees of freedom parameter", nu); check_positive(function, "Scale matrix rows", L.rows()); diff --git a/stan/math/prim/prob/multi_student_t_lpdf.hpp b/stan/math/prim/prob/multi_student_t_lpdf.hpp index ea0257a8619..bbecf48e269 100644 --- a/stan/math/prim/prob/multi_student_t_lpdf.hpp +++ b/stan/math/prim/prob/multi_student_t_lpdf.hpp @@ -48,7 +48,7 @@ return_type_t multi_student_t_lpdf( using Eigen::Matrix; using std::log; using std::vector; - static const char* function = "multi_student_t"; + static constexpr const char* function = "multi_student_t"; check_not_nan(function, "Degrees of freedom parameter", nu); check_positive(function, "Degrees of freedom parameter", nu); check_finite(function, "Degrees of freedom parameter", nu); diff --git a/stan/math/prim/prob/multi_student_t_rng.hpp b/stan/math/prim/prob/multi_student_t_rng.hpp index 22fe07b4cb9..cffb45338eb 100644 --- a/stan/math/prim/prob/multi_student_t_rng.hpp +++ b/stan/math/prim/prob/multi_student_t_rng.hpp @@ -46,7 +46,7 @@ multi_student_t_rng( using boost::variate_generator; using boost::random::gamma_distribution; - static const char* function = "multi_student_t_rng"; + static constexpr const char* function = "multi_student_t_rng"; check_not_nan(function, "Degrees of freedom parameter", nu); check_positive(function, "Degrees of freedom parameter", nu); check_positive(function, "Covariance matrix rows", S.rows()); diff --git a/stan/math/prim/prob/multinomial_logit_lpmf.hpp b/stan/math/prim/prob/multinomial_logit_lpmf.hpp index bda441dadf3..e72d52c2e9b 100644 --- a/stan/math/prim/prob/multinomial_logit_lpmf.hpp +++ b/stan/math/prim/prob/multinomial_logit_lpmf.hpp @@ -24,7 +24,7 @@ template , require_eigen_col_vector_t* = nullptr> return_type_t multinomial_logit_lpmf(const std::vector& ns, const T_beta& beta) { - static const char* function = "multinomial_logit_lpmf"; + static constexpr const char* function = "multinomial_logit_lpmf"; check_size_match(function, "Size of number of trials variable", ns.size(), "rows of log-probabilities parameter", beta.rows()); check_nonnegative(function, "Number of trials variable", ns); diff --git a/stan/math/prim/prob/multinomial_logit_rng.hpp b/stan/math/prim/prob/multinomial_logit_rng.hpp index 64da0645910..969c007bd1f 100644 --- a/stan/math/prim/prob/multinomial_logit_rng.hpp +++ b/stan/math/prim/prob/multinomial_logit_rng.hpp @@ -26,7 +26,7 @@ template * = nullptr> inline std::vector multinomial_logit_rng(const T_beta& beta, int N, RNG& rng) { - static const char* function = "multinomial_logit_rng"; + static constexpr const char* function = "multinomial_logit_rng"; const auto& beta_ref = to_ref(beta); check_finite(function, "Log-probabilities parameter", beta_ref); check_positive(function, "number of trials variables", N); diff --git a/stan/math/prim/prob/multinomial_lpmf.hpp b/stan/math/prim/prob/multinomial_lpmf.hpp index 3ebb42a9549..87ad024032e 100644 --- a/stan/math/prim/prob/multinomial_lpmf.hpp +++ b/stan/math/prim/prob/multinomial_lpmf.hpp @@ -16,7 +16,7 @@ template * = nullptr> return_type_t multinomial_lpmf(const std::vector& ns, const T_prob& theta) { - static const char* function = "multinomial_lpmf"; + static constexpr const char* function = "multinomial_lpmf"; check_size_match(function, "Size of number of trials variable", ns.size(), "rows of probabilities parameter", theta.rows()); check_nonnegative(function, "Number of trials variable", ns); diff --git a/stan/math/prim/prob/multinomial_rng.hpp b/stan/math/prim/prob/multinomial_rng.hpp index 0a8e2f3bdf8..86edf66beb6 100644 --- a/stan/math/prim/prob/multinomial_rng.hpp +++ b/stan/math/prim/prob/multinomial_rng.hpp @@ -13,7 +13,7 @@ namespace math { template * = nullptr> inline std::vector multinomial_rng(const T_theta& theta, int N, RNG& rng) { - static const char* function = "multinomial_rng"; + static constexpr const char* function = "multinomial_rng"; const auto& theta_ref = to_ref(theta); check_simplex(function, "Probabilities parameter", theta_ref); check_positive(function, "number of trials variables", N); diff --git a/stan/math/prim/prob/neg_binomial_2_cdf.hpp b/stan/math/prim/prob/neg_binomial_2_cdf.hpp index ecf85cb91ee..b2f754708db 100644 --- a/stan/math/prim/prob/neg_binomial_2_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_cdf.hpp @@ -27,7 +27,7 @@ return_type_t neg_binomial_2_cdf( using T_n_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_cdf"; + static constexpr const char* function = "neg_binomial_2_cdf"; check_consistent_sizes(function, "Random variable", n, "Location parameter", mu, "Precision Parameter", phi); diff --git a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp index d7575ba64b8..2154e96a44d 100644 --- a/stan/math/prim/prob/neg_binomial_2_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lccdf.hpp @@ -18,7 +18,7 @@ return_type_t neg_binomial_2_lccdf( const T_n& n, const T_location& mu, const T_precision& phi) { using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_lccdf"; + static constexpr const char* function = "neg_binomial_2_lccdf"; check_consistent_sizes(function, "Random variable", n, "Location parameter", mu, "Precision Parameter", phi); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp index fa0a1302994..86eee78c5de 100644 --- a/stan/math/prim/prob/neg_binomial_2_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lcdf.hpp @@ -21,7 +21,7 @@ return_type_t neg_binomial_2_lcdf( using T_n_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_lcdf"; + static constexpr const char* function = "neg_binomial_2_lcdf"; check_consistent_sizes(function, "Random variable", n, "Location parameter", mu, "Precision Parameter", phi); diff --git a/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp index 42694d69f6c..8a21bd8b0ae 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_glm_lpmf.hpp @@ -94,7 +94,7 @@ return_type_t neg_binomial_2_log_glm_lpmf( const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); - static const char* function = "neg_binomial_2_log_glm_lpmf"; + static constexpr const char* function = "neg_binomial_2_log_glm_lpmf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Weight vector", beta, N_attributes); diff --git a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp index b950b84420c..029a0d0ca47 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_lpmf.hpp @@ -33,7 +33,7 @@ return_type_t neg_binomial_2_log_lpmf( using T_n_ref = ref_type_t; using T_eta_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_log_lpmf"; + static constexpr const char* function = "neg_binomial_2_log_lpmf"; check_consistent_sizes(function, "Failures variable", n, "Log location parameter", eta, "Precision parameter", phi); diff --git a/stan/math/prim/prob/neg_binomial_2_log_rng.hpp b/stan/math/prim/prob/neg_binomial_2_log_rng.hpp index 7cfa3b068cd..aefce01d132 100644 --- a/stan/math/prim/prob/neg_binomial_2_log_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_2_log_rng.hpp @@ -40,7 +40,7 @@ neg_binomial_2_log_rng(const T_loc& eta, const T_inv& phi, RNG& rng) { using boost::random::poisson_distribution; using T_eta_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_log_rng"; + static constexpr const char* function = "neg_binomial_2_log_rng"; check_consistent_sizes(function, "Log-location parameter", eta, "Inverse dispersion parameter", phi); T_eta_ref eta_ref = eta; diff --git a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp index 474aed2fabc..7815ca1015f 100644 --- a/stan/math/prim/prob/neg_binomial_2_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_2_lpmf.hpp @@ -29,7 +29,7 @@ return_type_t neg_binomial_2_lpmf( using T_n_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_lpmf"; + static constexpr const char* function = "neg_binomial_2_lpmf"; check_consistent_sizes(function, "Failures variable", n, "Location parameter", mu, "Precision parameter", phi); diff --git a/stan/math/prim/prob/neg_binomial_2_rng.hpp b/stan/math/prim/prob/neg_binomial_2_rng.hpp index 8c23c634471..67f6b69687d 100644 --- a/stan/math/prim/prob/neg_binomial_2_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_2_rng.hpp @@ -39,7 +39,7 @@ neg_binomial_2_rng(const T_loc& mu, const T_prec& phi, RNG& rng) { using boost::random::poisson_distribution; using T_mu_ref = ref_type_t; using T_phi_ref = ref_type_t; - static const char* function = "neg_binomial_2_rng"; + static constexpr const char* function = "neg_binomial_2_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", phi); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/neg_binomial_cdf.hpp b/stan/math/prim/prob/neg_binomial_cdf.hpp index 835c7689bc3..1e1c1683dab 100644 --- a/stan/math/prim/prob/neg_binomial_cdf.hpp +++ b/stan/math/prim/prob/neg_binomial_cdf.hpp @@ -29,7 +29,7 @@ return_type_t neg_binomial_cdf(const T_n& n, using T_n_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "neg_binomial_cdf"; + static constexpr const char* function = "neg_binomial_cdf"; check_consistent_sizes(function, "Failures variable", n, "Shape parameter", alpha, "Inverse scale parameter", beta); T_n_ref n_ref = n; diff --git a/stan/math/prim/prob/neg_binomial_lccdf.hpp b/stan/math/prim/prob/neg_binomial_lccdf.hpp index a9536686468..ca630a9824c 100644 --- a/stan/math/prim/prob/neg_binomial_lccdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t neg_binomial_lccdf( using std::pow; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "neg_binomial_lccdf"; + static constexpr const char* function = "neg_binomial_lccdf"; check_consistent_sizes(function, "Failures variable", n, "Shape parameter", alpha, "Inverse scale parameter", beta_param); diff --git a/stan/math/prim/prob/neg_binomial_lcdf.hpp b/stan/math/prim/prob/neg_binomial_lcdf.hpp index 0f4d8052158..17b7de14857 100644 --- a/stan/math/prim/prob/neg_binomial_lcdf.hpp +++ b/stan/math/prim/prob/neg_binomial_lcdf.hpp @@ -33,7 +33,7 @@ return_type_t neg_binomial_lcdf( using T_n_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "neg_binomial_lcdf"; + static constexpr const char* function = "neg_binomial_lcdf"; check_consistent_sizes(function, "Failures variable", n, "Shape parameter", alpha, "Inverse scale parameter", beta_param); T_n_ref n_ref = n; diff --git a/stan/math/prim/prob/neg_binomial_lpmf.hpp b/stan/math/prim/prob/neg_binomial_lpmf.hpp index 6be061c99a2..59e1097de5c 100644 --- a/stan/math/prim/prob/neg_binomial_lpmf.hpp +++ b/stan/math/prim/prob/neg_binomial_lpmf.hpp @@ -38,7 +38,7 @@ return_type_t neg_binomial_lpmf(const T_n& n, using T_n_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "neg_binomial_lpmf"; + static constexpr const char* function = "neg_binomial_lpmf"; check_consistent_sizes(function, "Failures variable", n, "Shape parameter", alpha, "Inverse scale parameter", beta); T_n_ref n_ref = n; diff --git a/stan/math/prim/prob/neg_binomial_rng.hpp b/stan/math/prim/prob/neg_binomial_rng.hpp index 0eb772092c6..0e01f6693c8 100644 --- a/stan/math/prim/prob/neg_binomial_rng.hpp +++ b/stan/math/prim/prob/neg_binomial_rng.hpp @@ -39,7 +39,7 @@ inline typename VectorBuilder::type neg_binomial_rng( using boost::random::poisson_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static const char* function = "neg_binomial_rng"; + static constexpr const char* function = "neg_binomial_rng"; check_consistent_sizes(function, "Shape parameter", alpha, "Inverse scale Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/normal_cdf.hpp b/stan/math/prim/prob/normal_cdf.hpp index 8ff8e8c5cae..1f34875c2df 100644 --- a/stan/math/prim/prob/normal_cdf.hpp +++ b/stan/math/prim/prob/normal_cdf.hpp @@ -43,7 +43,7 @@ inline return_type_t normal_cdf(const T_y& y, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "normal_cdf"; + static constexpr const char* function = "normal_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/normal_id_glm_lpdf.hpp b/stan/math/prim/prob/normal_id_glm_lpdf.hpp index 8901a098e1a..b42c3202983 100644 --- a/stan/math/prim/prob/normal_id_glm_lpdf.hpp +++ b/stan/math/prim/prob/normal_id_glm_lpdf.hpp @@ -78,7 +78,7 @@ return_type_t normal_id_glm_lpdf( const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); - static const char* function = "normal_id_glm_lpdf"; + static constexpr const char* function = "normal_id_glm_lpdf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Weight vector", beta, N_attributes); diff --git a/stan/math/prim/prob/normal_lccdf.hpp b/stan/math/prim/prob/normal_lccdf.hpp index e5b7275dba5..40b88cdc4a9 100644 --- a/stan/math/prim/prob/normal_lccdf.hpp +++ b/stan/math/prim/prob/normal_lccdf.hpp @@ -30,7 +30,7 @@ inline return_type_t normal_lccdf(const T_y& y, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "normal_lccdf"; + static constexpr const char* function = "normal_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/normal_lcdf.hpp b/stan/math/prim/prob/normal_lcdf.hpp index 7d2655e010f..d4895454d67 100644 --- a/stan/math/prim/prob/normal_lcdf.hpp +++ b/stan/math/prim/prob/normal_lcdf.hpp @@ -36,7 +36,7 @@ inline return_type_t normal_lcdf(const T_y& y, using T_y_ref = ref_type_t; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "normal_lcdf"; + static constexpr const char* function = "normal_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/normal_lpdf.hpp b/stan/math/prim/prob/normal_lpdf.hpp index 5d688964549..9918c090682 100644 --- a/stan/math/prim/prob/normal_lpdf.hpp +++ b/stan/math/prim/prob/normal_lpdf.hpp @@ -48,7 +48,7 @@ inline return_type_t normal_lpdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "normal_lpdf"; + static constexpr const char* function = "normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/normal_rng.hpp b/stan/math/prim/prob/normal_rng.hpp index 65536fd93d1..73c328eb9e4 100644 --- a/stan/math/prim/prob/normal_rng.hpp +++ b/stan/math/prim/prob/normal_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type normal_rng( using boost::variate_generator; using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "normal_rng"; + static constexpr const char* function = "normal_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/normal_sufficient_lpdf.hpp b/stan/math/prim/prob/normal_sufficient_lpdf.hpp index abf5924b75d..b1cdf59343d 100644 --- a/stan/math/prim/prob/normal_sufficient_lpdf.hpp +++ b/stan/math/prim/prob/normal_sufficient_lpdf.hpp @@ -60,7 +60,7 @@ return_type_t normal_sufficient_lpdf( using T_n_ref = ref_type_if_t::value, T_n>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "normal_sufficient_lpdf"; + static constexpr const char* function = "normal_sufficient_lpdf"; check_consistent_sizes(function, "Location parameter sufficient statistic", y_bar, "Scale parameter sufficient statistic", s_squared, "Number of observations", n_obs, diff --git a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp index 6709dc43993..dadd74291a0 100644 --- a/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_glm_lpmf.hpp @@ -66,7 +66,7 @@ return_type_t ordered_logistic_glm_lpmf( const size_t N_attributes = x.cols(); const size_t N_classes = stan::math::size(cuts) + 1; - static const char* function = "ordered_logistic_glm_lpmf"; + static constexpr const char* function = "ordered_logistic_glm_lpmf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Weight vector", beta, N_attributes); diff --git a/stan/math/prim/prob/ordered_logistic_lpmf.hpp b/stan/math/prim/prob/ordered_logistic_lpmf.hpp index 858c6c720ce..fc77d08d693 100644 --- a/stan/math/prim/prob/ordered_logistic_lpmf.hpp +++ b/stan/math/prim/prob/ordered_logistic_lpmf.hpp @@ -82,7 +82,7 @@ return_type_t ordered_logistic_lpmf(const T_y& y, using T_cut_ref = ref_type_if_t::value, T_cut>; using Eigen::Array; using Eigen::Dynamic; - static const char* function = "ordered_logistic"; + static constexpr const char* function = "ordered_logistic"; T_cut_ref c_ref = c; vector_seq_view c_vec(c_ref); diff --git a/stan/math/prim/prob/ordered_logistic_rng.hpp b/stan/math/prim/prob/ordered_logistic_rng.hpp index b8b054670fe..59921364a26 100644 --- a/stan/math/prim/prob/ordered_logistic_rng.hpp +++ b/stan/math/prim/prob/ordered_logistic_rng.hpp @@ -14,7 +14,7 @@ template inline int ordered_logistic_rng( double eta, const Eigen::Matrix& c, RNG& rng) { using boost::variate_generator; - static const char* function = "ordered_logistic"; + static constexpr const char* function = "ordered_logistic"; check_finite(function, "Location parameter", eta); check_greater(function, "Size of cut points parameter", c.size(), 0); check_ordered(function, "Cut points parameter", c); diff --git a/stan/math/prim/prob/ordered_probit_lpmf.hpp b/stan/math/prim/prob/ordered_probit_lpmf.hpp index 18bbfdd0174..0ba3dcfd71b 100644 --- a/stan/math/prim/prob/ordered_probit_lpmf.hpp +++ b/stan/math/prim/prob/ordered_probit_lpmf.hpp @@ -51,7 +51,7 @@ return_type_t ordered_probit_lpmf(const T_y& y, using std::exp; using std::log; using T_lambda_ref = ref_type_t; - static const char* function = "ordered_probit"; + static constexpr const char* function = "ordered_probit"; check_nonzero_size(function, "Cut-points", c); int N = math::size(lambda); diff --git a/stan/math/prim/prob/ordered_probit_rng.hpp b/stan/math/prim/prob/ordered_probit_rng.hpp index c46790177db..1f11cebea27 100644 --- a/stan/math/prim/prob/ordered_probit_rng.hpp +++ b/stan/math/prim/prob/ordered_probit_rng.hpp @@ -11,7 +11,7 @@ namespace math { template inline int ordered_probit_rng(double eta, const Eigen::VectorXd& c, RNG& rng) { - static const char* function = "ordered_probit"; + static constexpr const char* function = "ordered_probit"; check_finite(function, "Location parameter", eta); check_greater(function, "Size of cut points parameter", c.size(), 0); check_ordered(function, "Cut points vector", c); diff --git a/stan/math/prim/prob/pareto_cdf.hpp b/stan/math/prim/prob/pareto_cdf.hpp index 06c555dad30..2f88425498a 100644 --- a/stan/math/prim/prob/pareto_cdf.hpp +++ b/stan/math/prim/prob/pareto_cdf.hpp @@ -29,7 +29,7 @@ return_type_t pareto_cdf(const T_y& y, using T_alpha_ref = ref_type_t; using std::exp; using std::log; - static const char* function = "pareto_cdf"; + static constexpr const char* function = "pareto_cdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", y_min, "Shape parameter", alpha); if (size_zero(y, y_min, alpha)) { diff --git a/stan/math/prim/prob/pareto_lccdf.hpp b/stan/math/prim/prob/pareto_lccdf.hpp index aa3388369f1..4d59b674df4 100644 --- a/stan/math/prim/prob/pareto_lccdf.hpp +++ b/stan/math/prim/prob/pareto_lccdf.hpp @@ -32,7 +32,7 @@ return_type_t pareto_lccdf(const T_y& y, using T_y_min_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; using std::isinf; - static const char* function = "pareto_lccdf"; + static constexpr const char* function = "pareto_lccdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", y_min, "Shape parameter", alpha); if (size_zero(y, y_min, alpha)) { diff --git a/stan/math/prim/prob/pareto_lcdf.hpp b/stan/math/prim/prob/pareto_lcdf.hpp index ba74b4d040f..4cea9d78c9b 100644 --- a/stan/math/prim/prob/pareto_lcdf.hpp +++ b/stan/math/prim/prob/pareto_lcdf.hpp @@ -32,7 +32,7 @@ return_type_t pareto_lcdf(const T_y& y, using T_y_min_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; using std::isinf; - static const char* function = "pareto_lcdf"; + static constexpr const char* function = "pareto_lcdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", y_min, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_lpdf.hpp b/stan/math/prim/prob/pareto_lpdf.hpp index e003450d7d7..c91db557e55 100644 --- a/stan/math/prim/prob/pareto_lpdf.hpp +++ b/stan/math/prim/prob/pareto_lpdf.hpp @@ -31,7 +31,7 @@ return_type_t pareto_lpdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_y_min_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "pareto_lpdf"; + static constexpr const char* function = "pareto_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", y_min, "Shape parameter", alpha); if (size_zero(y, y_min, alpha)) { diff --git a/stan/math/prim/prob/pareto_rng.hpp b/stan/math/prim/prob/pareto_rng.hpp index 6cbb121d001..aac348d7c0e 100644 --- a/stan/math/prim/prob/pareto_rng.hpp +++ b/stan/math/prim/prob/pareto_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type pareto_rng( const T_scale& y_min, const T_shape& alpha, RNG& rng) { using boost::exponential_distribution; using boost::variate_generator; - static const char* function = "pareto_rng"; + static constexpr const char* function = "pareto_rng"; check_consistent_sizes(function, "Scale Parameter", y_min, "Shape parameter", alpha); const auto& y_min_ref = to_ref(y_min); diff --git a/stan/math/prim/prob/pareto_type_2_cdf.hpp b/stan/math/prim/prob/pareto_type_2_cdf.hpp index 29140d1dc6b..940e06bbe49 100644 --- a/stan/math/prim/prob/pareto_type_2_cdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_cdf.hpp @@ -30,7 +30,7 @@ return_type_t pareto_type_2_cdf( using T_lambda_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; using std::pow; - static const char* function = "pareto_type_2_cdf"; + static constexpr const char* function = "pareto_type_2_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_type_2_lccdf.hpp b/stan/math/prim/prob/pareto_type_2_lccdf.hpp index 2b038c12478..56ae0c6cb17 100644 --- a/stan/math/prim/prob/pareto_type_2_lccdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lccdf.hpp @@ -29,7 +29,7 @@ return_type_t pareto_type_2_lccdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_lambda_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "pareto_type_2_lccdf"; + static constexpr const char* function = "pareto_type_2_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_type_2_lcdf.hpp b/stan/math/prim/prob/pareto_type_2_lcdf.hpp index eb8530fec89..7ae902d81aa 100644 --- a/stan/math/prim/prob/pareto_type_2_lcdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lcdf.hpp @@ -30,7 +30,7 @@ return_type_t pareto_type_2_lcdf( using T_lambda_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; using std::pow; - static const char* function = "pareto_type_2_lcdf"; + static constexpr const char* function = "pareto_type_2_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_type_2_lpdf.hpp b/stan/math/prim/prob/pareto_type_2_lpdf.hpp index 37500c11fd8..fc09a369e1d 100644 --- a/stan/math/prim/prob/pareto_type_2_lpdf.hpp +++ b/stan/math/prim/prob/pareto_type_2_lpdf.hpp @@ -32,7 +32,7 @@ return_type_t pareto_type_2_lpdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_lambda_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "pareto_type_2_lpdf"; + static constexpr const char* function = "pareto_type_2_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", lambda, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/pareto_type_2_rng.hpp b/stan/math/prim/prob/pareto_type_2_rng.hpp index a1ab4af97d4..e2bcd5f0db8 100644 --- a/stan/math/prim/prob/pareto_type_2_rng.hpp +++ b/stan/math/prim/prob/pareto_type_2_rng.hpp @@ -43,7 +43,7 @@ pareto_type_2_rng(const T_loc& mu, const T_scale& lambda, const T_shape& alpha, RNG& rng) { using boost::variate_generator; using boost::random::uniform_real_distribution; - static const char* function = "pareto_type_2_rng"; + static constexpr const char* function = "pareto_type_2_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", lambda, "Shape Parameter", alpha); const auto& mu_ref = to_ref(mu); diff --git a/stan/math/prim/prob/poisson_binomial_cdf.hpp b/stan/math/prim/prob/poisson_binomial_cdf.hpp index 47ef2eca983..0c4f647e835 100644 --- a/stan/math/prim/prob/poisson_binomial_cdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_cdf.hpp @@ -35,7 +35,7 @@ namespace math { template return_type_t poisson_binomial_cdf(const T_y& y, const T_theta& theta) { - static const char* function = "poisson_binomial_cdf"; + static constexpr const char* function = "poisson_binomial_cdf"; size_t size_theta = size_mvt(theta); if (size_theta > 1) { diff --git a/stan/math/prim/prob/poisson_binomial_lccdf.hpp b/stan/math/prim/prob/poisson_binomial_lccdf.hpp index f700c4795ef..2f07bdb60e6 100644 --- a/stan/math/prim/prob/poisson_binomial_lccdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lccdf.hpp @@ -36,7 +36,7 @@ namespace math { template return_type_t poisson_binomial_lccdf(const T_y& y, const T_theta& theta) { - static const char* function = "poisson_binomial_lccdf"; + static constexpr const char* function = "poisson_binomial_lccdf"; size_t size_theta = size_mvt(theta); if (size_theta > 1) { diff --git a/stan/math/prim/prob/poisson_binomial_lcdf.hpp b/stan/math/prim/prob/poisson_binomial_lcdf.hpp index d3006865707..de5e91a32ce 100644 --- a/stan/math/prim/prob/poisson_binomial_lcdf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lcdf.hpp @@ -35,7 +35,7 @@ namespace math { template return_type_t poisson_binomial_lcdf(const T_y& y, const T_theta& theta) { - static const char* function = "poisson_binomial_lcdf"; + static constexpr const char* function = "poisson_binomial_lcdf"; size_t size_theta = size_mvt(theta); if (size_theta > 1) { diff --git a/stan/math/prim/prob/poisson_binomial_lpmf.hpp b/stan/math/prim/prob/poisson_binomial_lpmf.hpp index bca1f7680de..ac8b8a80c46 100644 --- a/stan/math/prim/prob/poisson_binomial_lpmf.hpp +++ b/stan/math/prim/prob/poisson_binomial_lpmf.hpp @@ -27,7 +27,7 @@ namespace math { template return_type_t poisson_binomial_lpmf(const T_y& y, const T_theta& theta) { - static const char* function = "poisson_binomial_lpmf"; + static constexpr const char* function = "poisson_binomial_lpmf"; size_t size_theta = size_mvt(theta); if (size_theta > 1) { diff --git a/stan/math/prim/prob/poisson_binomial_rng.hpp b/stan/math/prim/prob/poisson_binomial_rng.hpp index d5d0a5b9244..768dc79dea3 100644 --- a/stan/math/prim/prob/poisson_binomial_rng.hpp +++ b/stan/math/prim/prob/poisson_binomial_rng.hpp @@ -24,7 +24,7 @@ namespace math { template * = nullptr> inline int poisson_binomial_rng(const T_theta& theta, RNG& rng) { - static const char* function = "poisson_binomial_rng"; + static constexpr const char* function = "poisson_binomial_rng"; check_finite(function, "Probability parameters", theta); check_bounded(function, "Probability parameters", value_of(theta), 0.0, 1.0); diff --git a/stan/math/prim/prob/poisson_cdf.hpp b/stan/math/prim/prob/poisson_cdf.hpp index 313f7968494..28aba74321a 100644 --- a/stan/math/prim/prob/poisson_cdf.hpp +++ b/stan/math/prim/prob/poisson_cdf.hpp @@ -29,7 +29,7 @@ return_type_t poisson_cdf(const T_n& n, const T_rate& lambda) { using T_n_ref = ref_type_if_t::value, T_n>; using T_lambda_ref = ref_type_if_t::value, T_rate>; using std::pow; - static const char* function = "poisson_cdf"; + static constexpr const char* function = "poisson_cdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_lccdf.hpp b/stan/math/prim/prob/poisson_lccdf.hpp index 22b326b9e18..d619e4ca363 100644 --- a/stan/math/prim/prob/poisson_lccdf.hpp +++ b/stan/math/prim/prob/poisson_lccdf.hpp @@ -29,7 +29,7 @@ return_type_t poisson_lccdf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_t::value, T_n>; using T_lambda_ref = ref_type_if_t::value, T_rate>; - static const char* function = "poisson_lccdf"; + static constexpr const char* function = "poisson_lccdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_lcdf.hpp b/stan/math/prim/prob/poisson_lcdf.hpp index fb732b5d696..82b4ad38a00 100644 --- a/stan/math/prim/prob/poisson_lcdf.hpp +++ b/stan/math/prim/prob/poisson_lcdf.hpp @@ -29,7 +29,7 @@ return_type_t poisson_lcdf(const T_n& n, const T_rate& lambda) { using T_partials_return = partials_return_t; using T_n_ref = ref_type_if_t::value, T_n>; using T_lambda_ref = ref_type_if_t::value, T_rate>; - static const char* function = "poisson_lcdf"; + static constexpr const char* function = "poisson_lcdf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp index 5a621129200..ca3b377a94e 100644 --- a/stan/math/prim/prob/poisson_log_glm_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_glm_lpmf.hpp @@ -69,7 +69,7 @@ return_type_t poisson_log_glm_lpmf(const T_y& y, const size_t N_instances = T_x_rows == 1 ? stan::math::size(y) : x.rows(); const size_t N_attributes = x.cols(); - static const char* function = "poisson_log_glm_lpmf"; + static constexpr const char* function = "poisson_log_glm_lpmf"; check_consistent_size(function, "Vector of dependent variables", y, N_instances); check_consistent_size(function, "Weight vector", beta, N_attributes); diff --git a/stan/math/prim/prob/poisson_log_lpmf.hpp b/stan/math/prim/prob/poisson_log_lpmf.hpp index 85be278124c..f05d7423d54 100644 --- a/stan/math/prim/prob/poisson_log_lpmf.hpp +++ b/stan/math/prim/prob/poisson_log_lpmf.hpp @@ -33,7 +33,7 @@ return_type_t poisson_log_lpmf(const T_n& n, using T_alpha_ref = ref_type_if_t::value, T_log_rate>; using std::isinf; - static const char* function = "poisson_log_lpmf"; + static constexpr const char* function = "poisson_log_lpmf"; check_consistent_sizes(function, "Random variable", n, "Log rate parameter", alpha); diff --git a/stan/math/prim/prob/poisson_log_rng.hpp b/stan/math/prim/prob/poisson_log_rng.hpp index 8e7a8daa7dc..262bccb25b2 100644 --- a/stan/math/prim/prob/poisson_log_rng.hpp +++ b/stan/math/prim/prob/poisson_log_rng.hpp @@ -32,8 +32,8 @@ inline typename VectorBuilder::type poisson_log_rng( const T_rate& alpha, RNG& rng) { using boost::variate_generator; using boost::random::poisson_distribution; - static const char* function = "poisson_log_rng"; - static const double POISSON_MAX_LOG_RATE = 30 * LOG_TWO; + static constexpr const char* function = "poisson_log_rng"; + static constexpr double POISSON_MAX_LOG_RATE = 30 * LOG_TWO; const auto& alpha_ref = to_ref(alpha); check_finite(function, "Log rate parameter", alpha_ref); check_less(function, "Log rate parameter", alpha_ref, POISSON_MAX_LOG_RATE); diff --git a/stan/math/prim/prob/poisson_lpmf.hpp b/stan/math/prim/prob/poisson_lpmf.hpp index 01ab3832a95..63a8fef91bd 100644 --- a/stan/math/prim/prob/poisson_lpmf.hpp +++ b/stan/math/prim/prob/poisson_lpmf.hpp @@ -31,7 +31,7 @@ return_type_t poisson_lpmf(const T_n& n, const T_rate& lambda) { using T_n_ref = ref_type_if_t::value, T_n>; using T_lambda_ref = ref_type_if_t::value, T_rate>; using std::isinf; - static const char* function = "poisson_lpmf"; + static constexpr const char* function = "poisson_lpmf"; check_consistent_sizes(function, "Random variable", n, "Rate parameter", lambda); diff --git a/stan/math/prim/prob/poisson_rng.hpp b/stan/math/prim/prob/poisson_rng.hpp index 7ec96d678b1..83052699ee2 100644 --- a/stan/math/prim/prob/poisson_rng.hpp +++ b/stan/math/prim/prob/poisson_rng.hpp @@ -31,7 +31,7 @@ inline typename VectorBuilder::type poisson_rng( const T_rate& lambda, RNG& rng) { using boost::variate_generator; using boost::random::poisson_distribution; - static const char* function = "poisson_rng"; + static constexpr const char* function = "poisson_rng"; const auto& lambda_ref = to_ref(lambda); check_positive(function, "Rate parameter", lambda_ref); check_less(function, "Rate parameter", lambda_ref, POISSON_MAX_RATE); diff --git a/stan/math/prim/prob/rayleigh_cdf.hpp b/stan/math/prim/prob/rayleigh_cdf.hpp index 344a3b9cb2b..b23160cf8e2 100644 --- a/stan/math/prim/prob/rayleigh_cdf.hpp +++ b/stan/math/prim/prob/rayleigh_cdf.hpp @@ -26,7 +26,7 @@ return_type_t rayleigh_cdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "rayleigh_cdf"; + static constexpr const char* function = "rayleigh_cdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lccdf.hpp b/stan/math/prim/prob/rayleigh_lccdf.hpp index 8eb7f4e9584..05420a04dbe 100644 --- a/stan/math/prim/prob/rayleigh_lccdf.hpp +++ b/stan/math/prim/prob/rayleigh_lccdf.hpp @@ -24,7 +24,7 @@ return_type_t rayleigh_lccdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "rayleigh_lccdf"; + static constexpr const char* function = "rayleigh_lccdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lcdf.hpp b/stan/math/prim/prob/rayleigh_lcdf.hpp index 9cc28c73f5f..a8bd24dadb8 100644 --- a/stan/math/prim/prob/rayleigh_lcdf.hpp +++ b/stan/math/prim/prob/rayleigh_lcdf.hpp @@ -26,7 +26,7 @@ return_type_t rayleigh_lcdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "rayleigh_lcdf"; + static constexpr const char* function = "rayleigh_lcdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_lpdf.hpp b/stan/math/prim/prob/rayleigh_lpdf.hpp index 1e447b33956..fca80b0b37d 100644 --- a/stan/math/prim/prob/rayleigh_lpdf.hpp +++ b/stan/math/prim/prob/rayleigh_lpdf.hpp @@ -26,7 +26,7 @@ return_type_t rayleigh_lpdf(const T_y& y, const T_scale& sigma) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_if_t::value, T_y>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "rayleigh_lpdf"; + static constexpr const char* function = "rayleigh_lpdf"; check_consistent_sizes(function, "Random variable", y, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/rayleigh_rng.hpp b/stan/math/prim/prob/rayleigh_rng.hpp index 58868567273..55b382be7fc 100644 --- a/stan/math/prim/prob/rayleigh_rng.hpp +++ b/stan/math/prim/prob/rayleigh_rng.hpp @@ -31,7 +31,7 @@ inline typename VectorBuilder::type rayleigh_rng( const T_scale& sigma, RNG& rng) { using boost::variate_generator; using boost::random::uniform_real_distribution; - static const char* function = "rayleigh_rng"; + static constexpr const char* function = "rayleigh_rng"; const auto& sigma_ref = to_ref(sigma); check_positive_finite(function, "Scale parameter", sigma_ref); diff --git a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp index 7ec39b46e56..a09f7e2e3b6 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_cdf.hpp @@ -44,7 +44,7 @@ return_type_t scaled_inv_chi_square_cdf(const T_y& y, using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_s_ref = ref_type_t; - static const char* function = "scaled_inv_chi_square_cdf"; + static constexpr const char* function = "scaled_inv_chi_square_cdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, "Scale parameter", s); diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp index 52c122b6f4a..2af9c453d22 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lccdf.hpp @@ -31,7 +31,7 @@ return_type_t scaled_inv_chi_square_lccdf( using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_s_ref = ref_type_t; - static const char* function = "scaled_inv_chi_square_lccdf"; + static constexpr const char* function = "scaled_inv_chi_square_lccdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, "Scale parameter", s); diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp index a5f480a438c..5898b15eebf 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lcdf.hpp @@ -31,7 +31,7 @@ return_type_t scaled_inv_chi_square_lcdf( using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_s_ref = ref_type_t; - static const char* function = "scaled_inv_chi_square_lcdf"; + static constexpr const char* function = "scaled_inv_chi_square_lcdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, "Scale parameter", s); diff --git a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp index 8c03961ed3f..a80d0e038c2 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_lpdf.hpp @@ -51,7 +51,7 @@ return_type_t scaled_inv_chi_square_lpdf( using T_y_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_s_ref = ref_type_t; - static const char* function = "scaled_inv_chi_square_lpdf"; + static constexpr const char* function = "scaled_inv_chi_square_lpdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, "Scale parameter", s); diff --git a/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp b/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp index 1b3abcb9776..819255a94a1 100644 --- a/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp +++ b/stan/math/prim/prob/scaled_inv_chi_square_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type scaled_inv_chi_square_rng(const T_deg& nu, const T_scale& s, RNG& rng) { using boost::variate_generator; using boost::random::chi_squared_distribution; - static const char* function = "scaled_inv_chi_square_rng"; + static constexpr const char* function = "scaled_inv_chi_square_rng"; check_consistent_sizes(function, "Location parameter", nu, "Scale Parameter", s); const auto& nu_ref = to_ref(nu); diff --git a/stan/math/prim/prob/skew_double_exponential_cdf.hpp b/stan/math/prim/prob/skew_double_exponential_cdf.hpp index a0eeb266691..b6750362f67 100644 --- a/stan/math/prim/prob/skew_double_exponential_cdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_cdf.hpp @@ -42,7 +42,7 @@ return_type_t skew_double_exponential_cdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_skewness& tau) { using T_partials_return = partials_return_t; - static const char* function = "skew_double_exponential_lcdf"; + static constexpr const char* function = "skew_double_exponential_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma, "Skewness parameter", tau); diff --git a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp index 3bf19e9e3ea..80d6ba44e08 100644 --- a/stan/math/prim/prob/skew_double_exponential_lccdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lccdf.hpp @@ -40,7 +40,7 @@ template skew_double_exponential_lccdf( const T_y& y, const T_loc& mu, const T_scale& sigma, const T_skewness& tau) { - static const char* function = "skew_double_exponential_lccdf"; + static constexpr const char* function = "skew_double_exponential_lccdf"; using T_partials_return = partials_return_t; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma, "Skewness parameter", diff --git a/stan/math/prim/prob/skew_double_exponential_lcdf.hpp b/stan/math/prim/prob/skew_double_exponential_lcdf.hpp index 387534632e2..73c34bc961a 100644 --- a/stan/math/prim/prob/skew_double_exponential_lcdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lcdf.hpp @@ -44,7 +44,7 @@ return_type_t skew_double_exponential_lcdf( using std::exp; using std::log; using T_partials_return = partials_return_t; - static const char* function = "skew_double_exponential_lcdf"; + static constexpr const char* function = "skew_double_exponential_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma, "Skewness parameter", tau); diff --git a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp index d3b6d5cea3e..8d2dd535393 100644 --- a/stan/math/prim/prob/skew_double_exponential_lpdf.hpp +++ b/stan/math/prim/prob/skew_double_exponential_lpdf.hpp @@ -48,7 +48,7 @@ return_type_t skew_double_exponential_lpdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_tau_ref = ref_type_if_t::value, T_skewness>; - static const char* function = "skew_double_exponential_lpdf"; + static constexpr const char* function = "skew_double_exponential_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Shape parameter", sigma, "Skewness parameter", tau); diff --git a/stan/math/prim/prob/skew_double_exponential_rng.hpp b/stan/math/prim/prob/skew_double_exponential_rng.hpp index 0b3f2fd1e5d..7b238d71189 100644 --- a/stan/math/prim/prob/skew_double_exponential_rng.hpp +++ b/stan/math/prim/prob/skew_double_exponential_rng.hpp @@ -42,7 +42,7 @@ skew_double_exponential_rng(const T_loc& mu, const T_scale& sigma, using T_mu_ref = ref_type_t; using T_sigma_ref = ref_type_t; using T_tau_ref = ref_type_t; - static const char* function = "skew_double_exponential_rng"; + static constexpr const char* function = "skew_double_exponential_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma, "Skewness Parameter", tau); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/skew_normal_cdf.hpp b/stan/math/prim/prob/skew_normal_cdf.hpp index 0e238a64b89..5279b0b6f90 100644 --- a/stan/math/prim/prob/skew_normal_cdf.hpp +++ b/stan/math/prim/prob/skew_normal_cdf.hpp @@ -32,7 +32,7 @@ return_type_t skew_normal_cdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "skew_normal_cdf"; + static constexpr const char* function = "skew_normal_cdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/skew_normal_lccdf.hpp b/stan/math/prim/prob/skew_normal_lccdf.hpp index b4fb3bf44d3..781079ddc26 100644 --- a/stan/math/prim/prob/skew_normal_lccdf.hpp +++ b/stan/math/prim/prob/skew_normal_lccdf.hpp @@ -30,7 +30,7 @@ return_type_t skew_normal_lccdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "skew_normal_lccdf"; + static constexpr const char* function = "skew_normal_lccdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/skew_normal_lcdf.hpp b/stan/math/prim/prob/skew_normal_lcdf.hpp index e713447abcb..78620f4f7f0 100644 --- a/stan/math/prim/prob/skew_normal_lcdf.hpp +++ b/stan/math/prim/prob/skew_normal_lcdf.hpp @@ -32,7 +32,7 @@ return_type_t skew_normal_lcdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "skew_normal_lcdf"; + static constexpr const char* function = "skew_normal_lcdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape parameter", alpha); diff --git a/stan/math/prim/prob/skew_normal_lpdf.hpp b/stan/math/prim/prob/skew_normal_lpdf.hpp index d811f507ae5..7e2fb94343e 100644 --- a/stan/math/prim/prob/skew_normal_lpdf.hpp +++ b/stan/math/prim/prob/skew_normal_lpdf.hpp @@ -33,7 +33,7 @@ return_type_t skew_normal_lpdf( using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using T_alpha_ref = ref_type_if_t::value, T_shape>; - static const char* function = "skew_normal_lpdf"; + static constexpr const char* function = "skew_normal_lpdf"; check_consistent_sizes(function, "Random variable", y, "Location parameter", mu, "Scale parameter", sigma, "Shape paramter", alpha); T_y_ref y_ref = y; diff --git a/stan/math/prim/prob/skew_normal_rng.hpp b/stan/math/prim/prob/skew_normal_rng.hpp index 6758a6bcd69..d4cc8590de7 100644 --- a/stan/math/prim/prob/skew_normal_rng.hpp +++ b/stan/math/prim/prob/skew_normal_rng.hpp @@ -41,7 +41,7 @@ skew_normal_rng(const T_loc& mu, const T_scale& sigma, const T_shape& alpha, RNG& rng) { using boost::variate_generator; using boost::random::normal_distribution; - static const char* function = "skew_normal_rng"; + static constexpr const char* function = "skew_normal_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale Parameter", sigma, "Shape Parameter", alpha); const auto& mu_ref = to_ref(mu); diff --git a/stan/math/prim/prob/std_normal_cdf.hpp b/stan/math/prim/prob/std_normal_cdf.hpp index 88cd54c3be4..1a212bef4b1 100644 --- a/stan/math/prim/prob/std_normal_cdf.hpp +++ b/stan/math/prim/prob/std_normal_cdf.hpp @@ -34,7 +34,7 @@ inline return_type_t std_normal_cdf(const T_y& y) { using T_partials_return = partials_return_t; using std::exp; using T_y_ref = ref_type_t; - static const char* function = "std_normal_cdf"; + static constexpr const char* function = "std_normal_cdf"; T_y_ref y_ref = y; check_not_nan(function, "Random variable", y_ref); diff --git a/stan/math/prim/prob/std_normal_lccdf.hpp b/stan/math/prim/prob/std_normal_lccdf.hpp index 74321a09390..163e81a2a28 100644 --- a/stan/math/prim/prob/std_normal_lccdf.hpp +++ b/stan/math/prim/prob/std_normal_lccdf.hpp @@ -26,7 +26,7 @@ inline return_type_t std_normal_lccdf(const T_y& y) { using std::exp; using std::log; using T_y_ref = ref_type_t; - static const char* function = "std_normal_lccdf"; + static constexpr const char* function = "std_normal_lccdf"; T_y_ref y_ref = y; check_not_nan(function, "Random variable", y_ref); diff --git a/stan/math/prim/prob/std_normal_lcdf.hpp b/stan/math/prim/prob/std_normal_lcdf.hpp index 4c61a5f61e0..9fed4d53b36 100644 --- a/stan/math/prim/prob/std_normal_lcdf.hpp +++ b/stan/math/prim/prob/std_normal_lcdf.hpp @@ -31,7 +31,7 @@ inline return_type_t std_normal_lcdf(const T_y& y) { using std::log; using std::pow; using T_y_ref = ref_type_t; - static const char* function = "std_normal_lcdf"; + static constexpr const char* function = "std_normal_lcdf"; T_y_ref y_ref = y; check_not_nan(function, "Random variable", y_ref); diff --git a/stan/math/prim/prob/std_normal_log_qf.hpp b/stan/math/prim/prob/std_normal_log_qf.hpp index 6bdef9dd602..bb8cbc06928 100644 --- a/stan/math/prim/prob/std_normal_log_qf.hpp +++ b/stan/math/prim/prob/std_normal_log_qf.hpp @@ -34,11 +34,11 @@ inline double std_normal_log_qf(double log_p) { return INFTY; } - static const double log_a[8] + static constexpr double log_a[8] = {1.2199838032983212, 4.8914137334471356, 7.5865960847956080, 9.5274618535358388, 10.734698580862359, 11.116406781896242, 10.417226196842595, 7.8276718012189362}; - static const double log_b[8] = {0., + static constexpr double log_b[8] = {0., 3.7451021830139207, 6.5326064640478618, 8.5930788436817044, @@ -46,11 +46,11 @@ inline double std_normal_log_qf(double log_p) { 10.579180688621286, 10.265665328832871, 8.5614962136628454}; - static const double log_c[8] + static constexpr double log_c[8] = {0.3530744474482423, 1.5326298343683388, 1.7525849400614634, 1.2941374937060454, 0.2393776640901312, -1.419724057885092, -3.784340465764968, -7.163234779359426}; - static const double log_d[8] = {0., + static constexpr double log_d[8] = {0., 0.7193954734947205, 0.5166395879845317, -0.371400933927844, @@ -58,11 +58,11 @@ inline double std_normal_log_qf(double log_p) { -4.186547581055928, -7.509976771225415, -20.67376157385924}; - static const double log_e[8] + static constexpr double log_e[8] = {1.8958048169567149, 1.6981417567726154, 0.5793212339927351, -1.215503791936417, -3.629396584023968, -6.690500273261249, -10.51540298415323, -15.41979457491781}; - static const double log_f[8] = {0., + static constexpr double log_f[8] = {0., -0.511105318617135, -1.988286302259815, -4.208049039384857, diff --git a/stan/math/prim/prob/std_normal_lpdf.hpp b/stan/math/prim/prob/std_normal_lpdf.hpp index bfbcf590146..a036ba9d580 100644 --- a/stan/math/prim/prob/std_normal_lpdf.hpp +++ b/stan/math/prim/prob/std_normal_lpdf.hpp @@ -32,7 +32,7 @@ template < return_type_t std_normal_lpdf(const T_y& y) { using T_partials_return = partials_return_t; using T_y_ref = ref_type_t; - static const char* function = "std_normal_lpdf"; + static constexpr const char* function = "std_normal_lpdf"; T_y_ref y_ref = y; check_not_nan(function, "Random variable", y_ref); diff --git a/stan/math/prim/prob/student_t_cdf.hpp b/stan/math/prim/prob/student_t_cdf.hpp index 87c50cccf44..a35e319e2eb 100644 --- a/stan/math/prim/prob/student_t_cdf.hpp +++ b/stan/math/prim/prob/student_t_cdf.hpp @@ -31,7 +31,7 @@ return_type_t student_t_cdf(const T_y& y, using T_sigma_ref = ref_type_t; using std::exp; using std::pow; - static const char* function = "student_t_cdf"; + static constexpr const char* function = "student_t_cdf"; T_y_ref y_ref = y; T_nu_ref nu_ref = nu; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/student_t_lccdf.hpp b/stan/math/prim/prob/student_t_lccdf.hpp index cfc6e5608ef..6303cd1b869 100644 --- a/stan/math/prim/prob/student_t_lccdf.hpp +++ b/stan/math/prim/prob/student_t_lccdf.hpp @@ -31,7 +31,7 @@ return_type_t student_t_lccdf( using std::exp; using std::log; using std::pow; - static const char* function = "student_t_lccdf"; + static constexpr const char* function = "student_t_lccdf"; T_y_ref y_ref = y; T_nu_ref nu_ref = nu; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/student_t_lcdf.hpp b/stan/math/prim/prob/student_t_lcdf.hpp index 84158993b47..0402591ab3d 100644 --- a/stan/math/prim/prob/student_t_lcdf.hpp +++ b/stan/math/prim/prob/student_t_lcdf.hpp @@ -33,7 +33,7 @@ return_type_t student_t_lcdf(const T_y& y, using std::exp; using std::log; using std::pow; - static const char* function = "student_t_lcdf"; + static constexpr const char* function = "student_t_lcdf"; T_y_ref y_ref = y; T_nu_ref nu_ref = nu; T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/student_t_lpdf.hpp b/stan/math/prim/prob/student_t_lpdf.hpp index b6ee5f3f176..53011c8fdbc 100644 --- a/stan/math/prim/prob/student_t_lpdf.hpp +++ b/stan/math/prim/prob/student_t_lpdf.hpp @@ -65,7 +65,7 @@ return_type_t student_t_lpdf(const T_y& y, using T_nu_ref = ref_type_if_t::value, T_dof>; using T_mu_ref = ref_type_if_t::value, T_loc>; using T_sigma_ref = ref_type_if_t::value, T_scale>; - static const char* function = "student_t_lpdf"; + static constexpr const char* function = "student_t_lpdf"; check_consistent_sizes(function, "Random variable", y, "Degrees of freedom parameter", nu, "Location parameter", mu, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/student_t_rng.hpp b/stan/math/prim/prob/student_t_rng.hpp index c47c8d2672e..ce7d271ef30 100644 --- a/stan/math/prim/prob/student_t_rng.hpp +++ b/stan/math/prim/prob/student_t_rng.hpp @@ -42,7 +42,7 @@ student_t_rng(const T_deg& nu, const T_loc& mu, const T_scale& sigma, using T_sigma_ref = ref_type_t; using boost::variate_generator; using boost::random::student_t_distribution; - static const char* function = "student_t_rng"; + static constexpr const char* function = "student_t_rng"; check_consistent_sizes(function, "Degrees of freedom parameter", nu, "Location parameter", mu, "Scale Parameter", sigma); T_nu_ref nu_ref = nu; diff --git a/stan/math/prim/prob/uniform_cdf.hpp b/stan/math/prim/prob/uniform_cdf.hpp index 3b7f36e9538..6563bc6003a 100644 --- a/stan/math/prim/prob/uniform_cdf.hpp +++ b/stan/math/prim/prob/uniform_cdf.hpp @@ -26,7 +26,7 @@ return_type_t uniform_cdf(const T_y& y, const T_low& alpha, using T_y_ref = ref_type_if_t::value, T_y>; using T_alpha_ref = ref_type_if_t::value, T_low>; using T_beta_ref = ref_type_if_t::value, T_high>; - static const char* function = "uniform_cdf"; + static constexpr const char* function = "uniform_cdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, "Upper bound parameter", beta); diff --git a/stan/math/prim/prob/uniform_lccdf.hpp b/stan/math/prim/prob/uniform_lccdf.hpp index 91b868cf4f2..f5659f4e06a 100644 --- a/stan/math/prim/prob/uniform_lccdf.hpp +++ b/stan/math/prim/prob/uniform_lccdf.hpp @@ -29,7 +29,7 @@ return_type_t uniform_lccdf(const T_y& y, using T_y_ref = ref_type_if_t::value, T_y>; using T_alpha_ref = ref_type_if_t::value, T_low>; using T_beta_ref = ref_type_if_t::value, T_high>; - static const char* function = "uniform_lccdf"; + static constexpr const char* function = "uniform_lccdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, "Upper bound parameter", beta); diff --git a/stan/math/prim/prob/uniform_lcdf.hpp b/stan/math/prim/prob/uniform_lcdf.hpp index 83e8b22e0d8..8e14764ae16 100644 --- a/stan/math/prim/prob/uniform_lcdf.hpp +++ b/stan/math/prim/prob/uniform_lcdf.hpp @@ -28,7 +28,7 @@ return_type_t uniform_lcdf(const T_y& y, const T_low& alpha, using T_y_ref = ref_type_if_t::value, T_y>; using T_alpha_ref = ref_type_if_t::value, T_low>; using T_beta_ref = ref_type_if_t::value, T_high>; - static const char* function = "uniform_lcdf"; + static constexpr const char* function = "uniform_lcdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, "Upper bound parameter", beta); diff --git a/stan/math/prim/prob/uniform_lpdf.hpp b/stan/math/prim/prob/uniform_lpdf.hpp index e19290bad1c..ea2cb6db075 100644 --- a/stan/math/prim/prob/uniform_lpdf.hpp +++ b/stan/math/prim/prob/uniform_lpdf.hpp @@ -50,7 +50,7 @@ return_type_t uniform_lpdf(const T_y& y, const T_low& alpha, using T_y_ref = ref_type_if_t::value, T_y>; using T_alpha_ref = ref_type_if_t::value, T_low>; using T_beta_ref = ref_type_if_t::value, T_high>; - static const char* function = "uniform_lpdf"; + static constexpr const char* function = "uniform_lpdf"; check_consistent_sizes(function, "Random variable", y, "Lower bound parameter", alpha, "Upper bound parameter", beta); diff --git a/stan/math/prim/prob/uniform_rng.hpp b/stan/math/prim/prob/uniform_rng.hpp index b2591c1245b..ad18cf1add3 100644 --- a/stan/math/prim/prob/uniform_rng.hpp +++ b/stan/math/prim/prob/uniform_rng.hpp @@ -38,7 +38,7 @@ inline typename VectorBuilder::type uniform_rng( using T_beta_ref = ref_type_t; using boost::variate_generator; using boost::random::uniform_real_distribution; - static const char* function = "uniform_rng"; + static constexpr const char* function = "uniform_rng"; check_consistent_sizes(function, "Lower bound parameter", alpha, "Upper bound parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/von_mises_rng.hpp b/stan/math/prim/prob/von_mises_rng.hpp index da51770c18f..c68a6227f74 100644 --- a/stan/math/prim/prob/von_mises_rng.hpp +++ b/stan/math/prim/prob/von_mises_rng.hpp @@ -49,7 +49,7 @@ inline typename VectorBuilder::type von_mises_rng( using boost::random::uniform_real_distribution; using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static const char* function = "von_mises_rng"; + static constexpr const char* function = "von_mises_rng"; check_consistent_sizes(function, "Location parameter", mu, "Scale parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/weibull_cdf.hpp b/stan/math/prim/prob/weibull_cdf.hpp index 1baa65629f4..09bb6d992ed 100644 --- a/stan/math/prim/prob/weibull_cdf.hpp +++ b/stan/math/prim/prob/weibull_cdf.hpp @@ -44,7 +44,7 @@ return_type_t weibull_cdf(const T_y& y, using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using std::pow; - static const char* function = "weibull_cdf"; + static constexpr const char* function = "weibull_cdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/weibull_lccdf.hpp b/stan/math/prim/prob/weibull_lccdf.hpp index 3657e45e294..efe6aa923ea 100644 --- a/stan/math/prim/prob/weibull_lccdf.hpp +++ b/stan/math/prim/prob/weibull_lccdf.hpp @@ -42,7 +42,7 @@ return_type_t weibull_lccdf(const T_y& y, using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using std::pow; - static const char* function = "weibull_lccdf"; + static constexpr const char* function = "weibull_lccdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/weibull_lcdf.hpp b/stan/math/prim/prob/weibull_lcdf.hpp index 2fcd24c7bce..92d89301a32 100644 --- a/stan/math/prim/prob/weibull_lcdf.hpp +++ b/stan/math/prim/prob/weibull_lcdf.hpp @@ -43,7 +43,7 @@ return_type_t weibull_lcdf(const T_y& y, using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using std::pow; - static const char* function = "weibull_lcdf"; + static constexpr const char* function = "weibull_lcdf"; T_y_ref y_ref = y; T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/weibull_lpdf.hpp b/stan/math/prim/prob/weibull_lpdf.hpp index b0eeeb43ea7..7ef1a08928a 100644 --- a/stan/math/prim/prob/weibull_lpdf.hpp +++ b/stan/math/prim/prob/weibull_lpdf.hpp @@ -45,7 +45,7 @@ return_type_t weibull_lpdf(const T_y& y, using T_alpha_ref = ref_type_if_t::value, T_shape>; using T_sigma_ref = ref_type_if_t::value, T_scale>; using std::pow; - static const char* function = "weibull_lpdf"; + static constexpr const char* function = "weibull_lpdf"; check_consistent_sizes(function, "Random variable", y, "Shape parameter", alpha, "Scale parameter", sigma); diff --git a/stan/math/prim/prob/weibull_rng.hpp b/stan/math/prim/prob/weibull_rng.hpp index 3ae4dc64a6a..0626add9fd8 100644 --- a/stan/math/prim/prob/weibull_rng.hpp +++ b/stan/math/prim/prob/weibull_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type weibull_rng( using boost::random::weibull_distribution; using T_alpha_ref = ref_type_t; using T_sigma_ref = ref_type_t; - static const char* function = "weibull_rng"; + static constexpr const char* function = "weibull_rng"; check_consistent_sizes(function, "Shape parameter", alpha, "Scale Parameter", sigma); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index e274254637b..8e34e3c71fa 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -89,7 +89,7 @@ return_type_t wiener_lpdf( using std::log; using std::sin; using std::sqrt; - static const char* function = "wiener_lpdf"; + static constexpr const char* function = "wiener_lpdf"; check_consistent_sizes(function, "Random variable", y, "Boundary separation", alpha, "A-priori bias", beta, "Nondecision time", tau, "Drift rate", delta); @@ -138,15 +138,16 @@ return_type_t wiener_lpdf( return 0; } - static const double WIENER_ERR = 0.000001; - static const double PI_TIMES_WIENER_ERR = pi() * WIENER_ERR; - static const double LOG_PI_LOG_WIENER_ERR = LOG_PI + log(WIENER_ERR); - static const double TWO_TIMES_SQRT_TWO_PI_TIMES_WIENER_ERR + static constexpr double WIENER_ERR = 0.000001; + static constexpr double PI_TIMES_WIENER_ERR = pi() * WIENER_ERR; + static constexpr double LOG_PI_LOG_WIENER_ERR = LOG_PI + log(WIENER_ERR); + static constexpr double TWO_TIMES_SQRT_TWO_PI_TIMES_WIENER_ERR = 2.0 * SQRT_TWO_PI * WIENER_ERR; - static const double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI + static constexpr double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI = LOG_TWO / 2 + LOG_SQRT_PI; - static const double SQUARE_PI_OVER_TWO = square(pi()) * 0.5; - static const double TWO_TIMES_LOG_SQRT_PI = 2.0 * LOG_SQRT_PI; + // square(pi()) * 0.5 + static constexpr double SQUARE_PI_OVER_TWO = 9.869604401089358618834490999876151135 * 0.5; + static constexpr double TWO_TIMES_LOG_SQRT_PI = 2.0 * LOG_SQRT_PI; for (size_t i = 0; i < N; i++) { typename scalar_type::type one_minus_beta = 1.0 - beta_vec[i]; diff --git a/stan/math/prim/prob/wishart_cholesky_lpdf.hpp b/stan/math/prim/prob/wishart_cholesky_lpdf.hpp index d7d25cb297b..766503f9657 100644 --- a/stan/math/prim/prob/wishart_cholesky_lpdf.hpp +++ b/stan/math/prim/prob/wishart_cholesky_lpdf.hpp @@ -47,7 +47,7 @@ return_type_t wishart_cholesky_lpdf(const T_y& L_Y, using T_nu_ref = ref_type_t; using T_L_S_ref = ref_type_t; using T_return = return_type_t; - static const char* function = "wishart_cholesky_lpdf"; + static constexpr const char* function = "wishart_cholesky_lpdf"; Eigen::Index k = L_Y.rows(); check_size_match(function, "Rows of RSandom variable", L_Y.rows(), "columns of scale parameter", L_S.rows()); diff --git a/stan/math/prim/prob/wishart_cholesky_rng.hpp b/stan/math/prim/prob/wishart_cholesky_rng.hpp index 9070d7ee6dd..4bbe6ecbf16 100644 --- a/stan/math/prim/prob/wishart_cholesky_rng.hpp +++ b/stan/math/prim/prob/wishart_cholesky_rng.hpp @@ -32,7 +32,7 @@ inline Eigen::MatrixXd wishart_cholesky_rng(double nu, const Eigen::MatrixXd& L_S, RNG& rng) { using Eigen::MatrixXd; - static const char* function = "wishart_cholesky_rng"; + static constexpr const char* function = "wishart_cholesky_rng"; index_type_t k = L_S.rows(); check_greater(function, "degrees of freedom > dims - 1", nu, k - 1); check_positive(function, "Cholesky Scale matrix", L_S.diagonal()); diff --git a/stan/math/prim/prob/wishart_lpdf.hpp b/stan/math/prim/prob/wishart_lpdf.hpp index 2e89001ce8a..89c0c9e8bcd 100644 --- a/stan/math/prim/prob/wishart_lpdf.hpp +++ b/stan/math/prim/prob/wishart_lpdf.hpp @@ -54,7 +54,7 @@ return_type_t wishart_lpdf(const T_y& W, const T_dof& nu, using T_W_ref = ref_type_t; using T_nu_ref = ref_type_t; using T_S_ref = ref_type_t; - static const char* function = "wishart_lpdf"; + static constexpr const char* function = "wishart_lpdf"; Eigen::Index k = W.rows(); check_size_match(function, "Rows of random variable", W.rows(), "columns of scale parameter", S.rows()); diff --git a/stan/math/prim/prob/wishart_rng.hpp b/stan/math/prim/prob/wishart_rng.hpp index 509b3f8ddde..b039a6ed633 100644 --- a/stan/math/prim/prob/wishart_rng.hpp +++ b/stan/math/prim/prob/wishart_rng.hpp @@ -15,7 +15,7 @@ template inline Eigen::MatrixXd wishart_rng(double nu, const Eigen::MatrixXd& S, RNG& rng) { using Eigen::MatrixXd; - static const char* function = "wishart_rng"; + static constexpr const char* function = "wishart_rng"; index_type_t k = S.rows(); check_square(function, "scale parameter", S); check_symmetric(function, "scale parameter", S); diff --git a/stan/math/rev/fun/accumulator.hpp b/stan/math/rev/fun/accumulator.hpp index bbbf1ac7bf4..a1cdf36ea63 100644 --- a/stan/math/rev/fun/accumulator.hpp +++ b/stan/math/rev/fun/accumulator.hpp @@ -24,7 +24,7 @@ namespace math { template class accumulator> { private: - static const int max_size_ = 128; + static constexpr int max_size_ = 128; std::vector> buf_; /** diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 754415ec337..19488d6befc 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); From dbe2429b32a4cbf86157bc75b20f43a8d2a331f5 Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 20 Oct 2022 12:08:18 -0400 Subject: [PATCH 02/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- .../kernel_generator/multi_result_kernel.hpp | 11 +- stan/math/opencl/kernels/indexing_rev.hpp | 95 ++-- .../kernels/neg_rect_lower_tri_multiply.hpp | 200 +++---- .../opencl/kernels/tridiagonalization.hpp | 524 +++++++++--------- .../prim/skew_double_exponential_lccdf.hpp | 3 +- .../prim/skew_double_exponential_lcdf.hpp | 3 +- .../prim/skew_double_exponential_lpdf.hpp | 3 +- stan/math/prim/fun/constants.hpp | 6 +- .../fun/log_modified_bessel_first_kind.hpp | 7 +- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- .../math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/std_normal_log_qf.hpp | 42 +- stan/math/prim/prob/wiener_lpdf.hpp | 3 +- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +- 18 files changed, 473 insertions(+), 442 deletions(-) diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index d5c58bcd233..deee4ea7cca 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -376,7 +376,9 @@ class results_cl { using impl = typename internal::multi_result_kernel_internal< std::tuple_size>::value - 1, T_res...>::template inner; - static constexpr bool require_specific_local_size = stan::math::disjunction::Deriv::require_specific_local_size...>::value; + static constexpr bool require_specific_local_size + = stan::math::disjunction::Deriv::require_specific_local_size...>::value; name_generator ng; std::map generated; @@ -441,12 +443,15 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; - static constexpr bool any_output = stan::math::disjunction>::value...>::value; + static constexpr bool any_output = stan::math::disjunction< + !is_without_output>::value...>::value; if (!any_output) { return; } - static constexpr bool require_specific_local_size = stan::math::disjunction::Deriv::require_specific_local_size...>::value; + static constexpr bool require_specific_local_size + = stan::math::disjunction::Deriv::require_specific_local_size...>::value; int n_rows = std::get<0>(assignment_pairs).second.thread_rows(); int n_cols = std::get<0>(assignment_pairs).second.thread_cols(); diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 3c4e67f3439..687076c3ff3 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -102,54 +102,55 @@ const kernel_clconst char* held in - * add_batch_kernel_code. - */ - __kernel void indexing_rev(__global double* adj, const __global int* index, - const __global double* res, - __local double* adj_loc, int index_size, - int adj_size) { - const int gid = get_global_id(0); - const int lid = get_local_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - for (int i = lid; i < adj_size * lsize; i += lsize) { - adj_loc[i] = 0; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = gid; i < index_size; i += gsize) { - adj_loc[index[i] + lid * adj_size] += res[i]; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - double p = adj_loc[i + adj_size]; - for (int j = 2; j < lsize; j++) { - p += adj_loc[i + j * adj_size]; +static constexpr std::string indexing_rev_local_independent_kernel_code + = STRINGIFY( + // \endcond + /** \ingroup opencl_kernels + * + * Increments adjoint of the indexing operation argument given the + * indices and adjoints of the indexing result. + * + * This kernel makes each thread build its own copy of the adjoints + * before combining them. It is the fastest (and only works for) small + * size of the indexed matrix. + * + * @param[in,out] adj adjoint to increment + * @param index + * @param res adjoint of the result of indexing + * @param batch_size Number of matrices in the batch. + * @note Code is a const char* held in + * add_batch_kernel_code. + */ + __kernel void indexing_rev( + __global double* adj, const __global int* index, + const __global double* res, __local double* adj_loc, int index_size, + int adj_size) { + const int gid = get_global_id(0); + const int lid = get_local_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + for (int i = lid; i < adj_size * lsize; i += lsize) { + adj_loc[i] = 0; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = gid; i < index_size; i += gsize) { + adj_loc[index[i] + lid * adj_size] += res[i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + double p = adj_loc[i + adj_size]; + for (int j = 2; j < lsize; j++) { + p += adj_loc[i + j * adj_size]; + } + adj_loc[i] += p; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + atomic_add_double(adj + i, adj_loc[i]); + } } - adj_loc[i] += p; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - atomic_add_double(adj + i, adj_loc[i]); - } - } - // \cond -); + // \cond + ); // \endcond /** \ingroup opencl_kernels diff --git a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp index 2f8aeb8a82d..7b9ad07489a 100644 --- a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp +++ b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp @@ -10,109 +10,119 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string neg_rect_lower_tri_multiply_kernel_code = STRINGIFY( - // \endcond - /** \ingroup opencl_kernels - * Calculates C = -B * A where B is rectangular and A is a lower - * triangular. - * For a full guide to the inverse lower triangular kernels see the link - * here. - * - * ![Inverse Calculation](https://goo.gl/6jBjEG) - * - * Graphically, this kernel calculates `-temp * C1` where temp is the - * C2 * A3 calculation from - * \link kernels/inv_lower_tri_multiply.hpp inv_lower_tri_multiply() - \endlink - * The kernel is executed using (N, N, m) threads, where N is the size of - * the input matrices. +static constexpr std::string neg_rect_lower_tri_multiply_kernel_code + = STRINGIFY( + // \endcond + /** \ingroup opencl_kernels + * Calculates C = -B * A where B is rectangular and A is a lower + * triangular. + * For a full guide to the inverse lower triangular kernels see the + link + * here. + * + * ![Inverse Calculation](https://goo.gl/6jBjEG) + * + * Graphically, this kernel calculates `-temp * C1` where temp is the + * C2 * A3 calculation from + * \link kernels/inv_lower_tri_multiply.hpp inv_lower_tri_multiply() + \endlink + * The kernel is executed using (N, N, m) threads, where N is the size + of + * the input matrices. - * @param[in, out] A Input matrix that is being inverted. - * @param[in] temp Temporary matrix with the intermediate results. - * @param A_rows Number of rows for A. - * @param rows The number of rows in a single matrix of the batch - * @note Code is a const char* held in - * neg_rect_lower_tri_multiply_kernel_code - * Used in math/opencl/tri_inverse.hpp. - * This kernel uses the helper macros available in helpers.cl. - */ - __kernel void neg_rect_lower_tri_multiply( - __global double* A, const __global double* temp, const int A_rows, - const int rows) { - int result_matrix_id = get_global_id(2); - int offset = result_matrix_id * rows * 2; - const int thread_block_row = get_local_id(0); - const int thread_block_col = get_local_id(1); - const int i = THREAD_BLOCK_SIZE * get_group_id(0) + thread_block_row; - const int j = THREAD_BLOCK_SIZE * get_group_id(1) + thread_block_col; + * @param[in, out] A Input matrix that is being inverted. + * @param[in] temp Temporary matrix with the intermediate results. + * @param A_rows Number of rows for A. + * @param rows The number of rows in a single matrix of the batch + * @note Code is a const char* held in + * neg_rect_lower_tri_multiply_kernel_code + * Used in math/opencl/tri_inverse.hpp. + * This kernel uses the helper macros available in helpers.cl. + */ + __kernel void neg_rect_lower_tri_multiply( + __global double* A, const __global double* temp, const int A_rows, + const int rows) { + int result_matrix_id = get_global_id(2); + int offset = result_matrix_id * rows * 2; + const int thread_block_row = get_local_id(0); + const int thread_block_col = get_local_id(1); + const int i = THREAD_BLOCK_SIZE * get_group_id(0) + thread_block_row; + const int j = THREAD_BLOCK_SIZE * get_group_id(1) + thread_block_col; - __local double temp_local[THREAD_BLOCK_SIZE][THREAD_BLOCK_SIZE]; - __local double C1_local[THREAD_BLOCK_SIZE][THREAD_BLOCK_SIZE]; + __local double temp_local[THREAD_BLOCK_SIZE][THREAD_BLOCK_SIZE]; + __local double C1_local[THREAD_BLOCK_SIZE][THREAD_BLOCK_SIZE]; - double acc[WORK_PER_THREAD] = {0}; + double acc[WORK_PER_THREAD] = {0}; - const int num_tiles = (rows + THREAD_BLOCK_SIZE - 1) / THREAD_BLOCK_SIZE; - for (int tile_ind = 0; tile_ind < num_tiles; tile_ind++) { - // each thread copies WORK_PER_THREAD values to the local - // memory - for (int w = 0; w < WORK_PER_THREAD; w++) { - const int tiled_i = THREAD_BLOCK_SIZE * tile_ind + thread_block_row; - const int tiled_j = THREAD_BLOCK_SIZE * tile_ind + thread_block_col; - const int temp_global_col = tiled_j + w * THREAD_BLOCK_SIZE_COL; - // {C2}{A2}_global_{col}{row} specifies which global element for each - // matrix the thread is in charge of moving to local memory. - const int C1_global_col = offset + j + w * THREAD_BLOCK_SIZE_COL; - const int C1_global_row = tiled_i + offset; - // Which {col}{row} location in the local memory the thread is in - // charge of. - const int local_col = thread_block_col + w * THREAD_BLOCK_SIZE_COL; - const int local_row = thread_block_row; - if ((temp_global_col) < rows && i < rows) { - temp_local[local_col][local_row] - = temp[result_matrix_id * rows * rows + temp_global_col * rows - + i]; - } else { - temp_local[local_col][local_row] = 0.0; + const int num_tiles + = (rows + THREAD_BLOCK_SIZE - 1) / THREAD_BLOCK_SIZE; + for (int tile_ind = 0; tile_ind < num_tiles; tile_ind++) { + // each thread copies WORK_PER_THREAD values to the local + // memory + for (int w = 0; w < WORK_PER_THREAD; w++) { + const int tiled_i + = THREAD_BLOCK_SIZE * tile_ind + thread_block_row; + const int tiled_j + = THREAD_BLOCK_SIZE * tile_ind + thread_block_col; + const int temp_global_col = tiled_j + w * THREAD_BLOCK_SIZE_COL; + // {C2}{A2}_global_{col}{row} specifies which global element for + // each matrix the thread is in charge of moving to local memory. + const int C1_global_col = offset + j + w * THREAD_BLOCK_SIZE_COL; + const int C1_global_row = tiled_i + offset; + // Which {col}{row} location in the local memory the thread is in + // charge of. + const int local_col + = thread_block_col + w * THREAD_BLOCK_SIZE_COL; + const int local_row = thread_block_row; + if ((temp_global_col) < rows && i < rows) { + temp_local[local_col][local_row] + = temp[result_matrix_id * rows * rows + + temp_global_col * rows + i]; + } else { + temp_local[local_col][local_row] = 0.0; + } + // Element above the diagonal will not be transferred. + if (C1_global_col <= C1_global_row && C1_global_col < A_rows + && C1_global_row < A_rows) { + C1_local[local_col][local_row] + = A[C1_global_col * A_rows + C1_global_row]; + } else { + C1_local[local_col][local_row] = 0; + } + } + // wait until all tile values are loaded to the local memory + barrier(CLK_LOCAL_MEM_FENCE); + for (int block_ind = 0; block_ind < THREAD_BLOCK_SIZE; + block_ind++) { + for (int w = 0; w < WORK_PER_THREAD; w++) { + // Which {col}{row} location in the local memory the thread is + // in + // charge of. + const int local_col + = thread_block_col + w * THREAD_BLOCK_SIZE_COL; + const int local_row = thread_block_row; + acc[w] += temp_local[block_ind][local_row] + * C1_local[local_col][block_ind]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); } - // Element above the diagonal will not be transferred. - if (C1_global_col <= C1_global_row && C1_global_col < A_rows - && C1_global_row < A_rows) { - C1_local[local_col][local_row] - = A[C1_global_col * A_rows + C1_global_row]; - } else { - C1_local[local_col][local_row] = 0; - } - } - // wait until all tile values are loaded to the local memory - barrier(CLK_LOCAL_MEM_FENCE); - for (int block_ind = 0; block_ind < THREAD_BLOCK_SIZE; block_ind++) { + // A_global_{row}{col} tells the thread which local memory it needs + // to move to the final output + const int A_global_row = i + rows + offset; + const int A_global_col_offset = offset + j; + // each thread saves WORK_PER_THREAD values for (int w = 0; w < WORK_PER_THREAD; w++) { - // Which {col}{row} location in the local memory the thread is in - // charge of. - const int local_col = thread_block_col + w * THREAD_BLOCK_SIZE_COL; - const int local_row = thread_block_row; - acc[w] += temp_local[block_ind][local_row] - * C1_local[local_col][block_ind]; + const int A_global_col + = A_global_col_offset + w * THREAD_BLOCK_SIZE_COL; + if (A_global_col < A_rows && (i + rows + offset) < A_rows) { + A[A_global_col * A_rows + i + rows + offset] = -acc[w]; + } } } - barrier(CLK_LOCAL_MEM_FENCE); - } - // A_global_{row}{col} tells the thread which local memory it needs - // to move to the final output - const int A_global_row = i + rows + offset; - const int A_global_col_offset = offset + j; - // each thread saves WORK_PER_THREAD values - for (int w = 0; w < WORK_PER_THREAD; w++) { - const int A_global_col - = A_global_col_offset + w * THREAD_BLOCK_SIZE_COL; - if (A_global_col < A_rows && (i + rows + offset) < A_rows) { - A[A_global_col * A_rows + i + rows + offset] = -acc[w]; - } - } - } - // \cond -); + // \cond + ); // \endcond /** \ingroup opencl_kernels diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index 130467cb30f..84cb7de065a 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -10,292 +10,300 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* tridiagonalization_householder_kernel_code = STRINGIFY( - // \endcond - /** - * Calculates householder vector and first element of the vector v. - * Must be run with 1 workgroup of LOCAL_SIZE_ threads. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q_glob q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param j Start column of the block to work on - * @param k Index of the householder vector in the block to create - */ - __kernel void tridiagonalization_householder( - __global double* P, __global double* V, __global double* q_glob, - const int P_rows, const int V_rows, const int j, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_householder_kernel_code + = STRINGIFY( + // \endcond + /** + * Calculates householder vector and first element of the vector v. + * Must be run with 1 workgroup of LOCAL_SIZE_ threads. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q_glob q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param j Start column of the block to work on + * @param k Index of the householder vector in the block to create + */ + __kernel void tridiagonalization_householder( + __global double* P, __global double* V, __global double* q_glob, + const int P_rows, const int V_rows, const int j, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - double q = 0; + double q = 0; - const int P_start = P_rows * (k + j) + k + j; - const int P_span = P_rows * (k + j + 1) - P_start; - for (int i = lid; i < P_span; i += lsize) { - double acc = 0; - // apply previous householder reflections from current block to the - // column we are making the Householder vector from - for (int l = 0; l < j; l++) { - acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] - + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; - } - double tmp = P[P_start + i] - acc; - P[P_start + i] = tmp; - if (i != 0) { - q += tmp * tmp; - } - } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; + const int P_start = P_rows * (k + j) + k + j; + const int P_span = P_rows * (k + j + 1) - P_start; + for (int i = lid; i < P_span; i += lsize) { + double acc = 0; + // apply previous householder reflections from current block to the + // column we are making the Householder vector from + for (int l = 0; l < j; l++) { + acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] + + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; + } + double tmp = P[P_start + i] - acc; + P[P_start + i] = tmp; + if (i != 0) { + q += tmp * tmp; + } + } + // calculate column norm between threads + __local double q_local[LOCAL_SIZE_]; + q_local[lid] = q; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + q_local[lid] += q_local[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = sqrt(2.) / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; + double alpha; + if (lid == 0) { + q = q_local[0]; + double p1 = P[P_start + 1]; + // make Householder vector + alpha = -copysign(sqrt(q), P[P_start]); + q -= p1 * p1; + p1 -= alpha; + P[P_start + 1] = p1; + q += p1 * p1; + q = sqrt(q); + q_local[0] = q; + q_local[1] = alpha; + *q_glob = q; + } + barrier(CLK_LOCAL_MEM_FENCE); + q = q_local[0]; + alpha = q_local[1]; + if (q != 0) { + double multi = sqrt(2.) / q; + // normalize the Householder vector + for (int i = lid + 1; i < P_span; i += lsize) { + P[P_start + i] *= multi; + } + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] + = P[P_rows * (k + j) + k + j + 1] * q / sqrt(2.) + alpha; + } } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / sqrt(2.) + alpha; - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_1_kernel_code = STRINGIFY( - // \endcond - /** - * Calculates first part of constructing the vector v: Uu = Pb * u and Vu = - * Vl * u. Pb is a block of packed matrix, Vl is left part of matrix V and u - * is householder vector. Must be run with number of work groups equal to - * size of resulting vectors and 64 threads per work group. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param[out] Uu First resulting vector. - * @param[out] Vu Second resulting vector. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - */ - __kernel void tridiagonalization_v_step_1( - const __global double* P, const __global double* V, __global double* Uu, - __global double* Vu, const int P_rows, const int V_rows, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_1_kernel_code + = STRINGIFY( + // \endcond + /** + * Calculates first part of constructing the vector v: Uu = Pb * u and + * Vu = Vl * u. Pb is a block of packed matrix, Vl is left part of + * matrix V and u is householder vector. Must be run with number of work + * groups equal to size of resulting vectors and 64 threads per work + * group. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param[out] Uu First resulting vector. + * @param[out] Vu Second resulting vector. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as input + */ + __kernel void tridiagonalization_v_step_1( + const __global double* P, const __global double* V, + __global double* Uu, __global double* Vu, const int P_rows, + const int V_rows, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __local double res_loc1[LOCAL_SIZE_]; - __local double res_loc2[LOCAL_SIZE_]; - double acc1 = 0; - double acc2 = 0; + __local double res_loc1[LOCAL_SIZE_]; + __local double res_loc2[LOCAL_SIZE_]; + double acc1 = 0; + double acc2 = 0; - const __global double* vec = P + P_rows * (k + ngroups) + k + ngroups + 1; - const __global double* M1 = P + P_rows * (k + wgid) + k + ngroups + 1; - const __global double* M2 = V + V_rows * wgid + ngroups; - for (int i = lid; i < P_rows - k - ngroups - 1; - i += LOCAL_SIZE_) { // go over column of the matrix in steps of 64 - double v = vec[i]; - acc1 += M1[i] * v; - acc2 += M2[i] * v; - } - res_loc1[lid] = acc1; - res_loc2[lid] = acc2; - barrier(CLK_LOCAL_MEM_FENCE); + const __global double* vec + = P + P_rows * (k + ngroups) + k + ngroups + 1; + const __global double* M1 = P + P_rows * (k + wgid) + k + ngroups + 1; + const __global double* M2 = V + V_rows * wgid + ngroups; + for (int i = lid; i < P_rows - k - ngroups - 1; + i + += LOCAL_SIZE_) { // go over column of the matrix in steps of 64 + double v = vec[i]; + acc1 += M1[i] * v; + acc2 += M2[i] * v; + } + res_loc1[lid] = acc1; + res_loc2[lid] = acc2; + barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc1[lid] += res_loc1[lid + step * i]; - res_loc2[lid] += res_loc2[lid + step * i]; + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc1[lid] += res_loc1[lid + step * i]; + res_loc2[lid] += res_loc2[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + Uu[wgid] = res_loc1[0]; + Vu[wgid] = res_loc2[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - Uu[wgid] = res_loc1[0]; - Vu[wgid] = res_loc2[0]; - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( - // \endcond - /** - * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. Pb is - * a block of packed matrix and U is householder vector. Pb is symmetric - * with only lower triangle having values. That is why two columns of V are - * written that must be added to obtain the vector v. Must be run with 64 - * threads per work group and total number of threads equal or greater than - * size of result vector. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param Uu Uu from previous kernel. - * @param Vu Vu from previous kernel. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_2( - const __global double* P, __global double* V, const __global double* Uu, - const __global double* Vu, const int P_rows, const int V_rows, - const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_2_kernel_code + = STRINGIFY( + // \endcond + /** + * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. + * Pb is a block of packed matrix and U is householder vector. Pb is + * symmetric with only lower triangle having values. That is why two + * columns of V are written that must be added to obtain the vector v. + * Must be run with 64 threads per work group and total number of + * threads equal or greater than size of result vector. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param Uu Uu from previous kernel. + * @param Vu Vu from previous kernel. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as input + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_2( + const __global double* P, __global double* V, + const __global double* Uu, const __global double* Vu, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - int work = P_rows - k - j - 1; - double acc = 0; + int work = P_rows - k - j - 1; + double acc = 0; - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; - } - V[V_rows * j + gid + j] = acc; - } - float work_per_group - = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; - } - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + const __global double* vec = P + P_rows * (k + j) + k + j + 1; + const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; + const __global double* M2 = P + P_rows * k + k + j + 1; + const __global double* M3 = V + j; + int i; + if (gid < work) { + for (i = 0; i <= gid; i++) { + acc += M1[P_rows * i + gid] * vec[i]; } + for (int i = 0; i < j; i++) { + acc -= M2[P_rows * i + gid] * Vu[i]; + acc -= M3[V_rows * i + gid] * Uu[i]; + } + V[V_rows * j + gid + j] = acc; + } + float work_per_group + = (float)work / ngroups; // NOLINT(readability/casting) + int start = work_per_group * wgid; + int end = work_per_group * (wgid + 1); + __local double res_loc[LOCAL_SIZE_]; + for (int i = start; i < end; i += 1) { + acc = 0; + for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { + acc += M1[P_rows * i + l] * vec[l]; + } + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + V[V_rows * (j + 1) + i + j] = res_loc[lid]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - V[V_rows * (j + 1) + i + j] = res_loc[lid]; } - barrier(CLK_LOCAL_MEM_FENCE); - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_3_kernel_code = STRINGIFY( - // \endcond - /** - * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the - * householder vector. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block to create - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_3( - __global double* P, __global double* V, __global double* q, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_3_kernel_code + = STRINGIFY( + // \endcond + /** + * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the + * householder vector. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block to create + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_3( + __global double* P, __global double* V, __global double* q, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __global double* u = P + P_rows * (k + j) + k + j + 1; - __global double* v = V + V_rows * j + j; - double acc = 0; + __global double* u = P + P_rows * (k + j) + k + j + 1; + __global double* v = V + V_rows * j + j; + double acc = 0; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - double vi = v[i] + v[i + V_rows]; - v[i] = vi; - acc += u[i] * vi; - } - __local double res_loc[LOCAL_SIZE_]; - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + double vi = v[i] + v[i + V_rows]; + v[i] = vi; + acc += u[i] * vi; + } + __local double res_loc[LOCAL_SIZE_]; + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + acc = res_loc[0] * 0.5; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + v[i] -= acc * u[i]; + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] -= *q / sqrt(2.) * u[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - acc = res_loc[0] * 0.5; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - v[i] -= acc * u[i]; - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] -= *q / sqrt(2.) * u[0]; - } - } - // \cond -); + // \cond + ); // \endcond const kernel_cl diff --git a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp index e9937280919..aa2919898f4 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lccdf.hpp @@ -37,7 +37,8 @@ return_type_t skew_double_exponential_lccdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static constexpr const char* function = "skew_double_exponential_lccdf(OpenCL)"; + static constexpr const char* function + = "skew_double_exponential_lccdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp index af07bb52f4a..1f6b4fbe1fa 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lcdf.hpp @@ -37,7 +37,8 @@ return_type_t skew_double_exponential_lcdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static constexpr const char* function = "skew_double_exponential_lcdf(OpenCL)"; + static constexpr const char* function + = "skew_double_exponential_lcdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp index 3d5096714e2..4f86be1578c 100644 --- a/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp +++ b/stan/math/opencl/prim/skew_double_exponential_lpdf.hpp @@ -40,7 +40,8 @@ return_type_t skew_double_exponential_lpdf(const T_y_cl& y, const T_loc_cl& mu, const T_scale_cl& sigma, const T_skewness_cl& tau) { - static constexpr const char* function = "skew_double_exponential_lpdf(OpenCL)"; + static constexpr const char* function + = "skew_double_exponential_lpdf(OpenCL)"; using T_partials_return = partials_return_t; using std::isfinite; diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index 0edf7de085b..f88653ea585 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -77,7 +77,8 @@ const double LOG_EPSILON = std::log(EPSILON); * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. */ -static constexpr double LOG_PI = 1.14472988584940017414342735135305871164729481291531157151362; +static constexpr double LOG_PI + = 1.14472988584940017414342735135305871164729481291531157151362; /** * The natural logarithm of 2, @@ -107,7 +108,8 @@ static constexpr double LOG_PI_OVER_FOUR = 0.25 * LOG_PI; * The natural logarithm of the square root of \f$ \pi \f$, * \f$ \log(sqrt{\pi}) \f$. */ -static constexpr double LOG_SQRT_PI = 0.5723649429247000870717136756765293558236474064576557857568115357; +static constexpr double LOG_SQRT_PI + = 0.5723649429247000870717136756765293558236474064576557857568115357; /** * The natural logarithm of 10, diff --git a/stan/math/prim/fun/log_modified_bessel_first_kind.hpp b/stan/math/prim/fun/log_modified_bessel_first_kind.hpp index aa6b3b98d1f..cbd2aba5c3c 100644 --- a/stan/math/prim/fun/log_modified_bessel_first_kind.hpp +++ b/stan/math/prim/fun/log_modified_bessel_first_kind.hpp @@ -123,9 +123,10 @@ inline return_type_t log_modified_bessel_first_kind( } // Max error in interpolated form : 2.437e-18 // Max Error found at double precision = Poly : 1.216719e-16 - static constexpr double P[5] = {3.98942280401432905e-01, 4.98677850491434560e-02, - 2.80506308916506102e-02, 2.92179096853915176e-02, - 4.53371208762579442e-02}; + static constexpr double P[5] + = {3.98942280401432905e-01, 4.98677850491434560e-02, + 2.80506308916506102e-02, 2.92179096853915176e-02, + 4.53371208762579442e-02}; return z + log(evaluate_polynomial(P, inv(z))) - multiply_log(0.5, z); } if (v == 1) { // WARNING: will not autodiff for v = 1 correctly diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index 7445ae2d269..a96ecfd5c3c 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_binomial_rng"; + static constexpr const char *function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 90ca685786a..61bb114f00f 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static constexpr const char* function = "beta_proportion_rng"; + static constexpr const char *function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index 1f544c857f9..9fdc839bf4e 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_rng"; + static constexpr const char *function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 9ac4f2184c1..9417ec6317a 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static constexpr const char* function = "gaussian_dlm_obs_rng"; + static constexpr const char *function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index b3d508060a8..e7a1d275fb2 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "matrix_normal_prec_rng"; + static constexpr const char *function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index a206fa79ea5..b3c7c63f518 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "multi_normal_prec_rng"; + static constexpr const char *function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/prim/prob/std_normal_log_qf.hpp b/stan/math/prim/prob/std_normal_log_qf.hpp index bb8cbc06928..bc306b6ac8a 100644 --- a/stan/math/prim/prob/std_normal_log_qf.hpp +++ b/stan/math/prim/prob/std_normal_log_qf.hpp @@ -39,37 +39,37 @@ inline double std_normal_log_qf(double log_p) { 9.5274618535358388, 10.734698580862359, 11.116406781896242, 10.417226196842595, 7.8276718012189362}; static constexpr double log_b[8] = {0., - 3.7451021830139207, - 6.5326064640478618, - 8.5930788436817044, - 9.9624069236663077, - 10.579180688621286, - 10.265665328832871, - 8.5614962136628454}; + 3.7451021830139207, + 6.5326064640478618, + 8.5930788436817044, + 9.9624069236663077, + 10.579180688621286, + 10.265665328832871, + 8.5614962136628454}; static constexpr double log_c[8] = {0.3530744474482423, 1.5326298343683388, 1.7525849400614634, 1.2941374937060454, 0.2393776640901312, -1.419724057885092, -3.784340465764968, -7.163234779359426}; static constexpr double log_d[8] = {0., - 0.7193954734947205, - 0.5166395879845317, - -0.371400933927844, - -1.909840708457214, - -4.186547581055928, - -7.509976771225415, - -20.67376157385924}; + 0.7193954734947205, + 0.5166395879845317, + -0.371400933927844, + -1.909840708457214, + -4.186547581055928, + -7.509976771225415, + -20.67376157385924}; static constexpr double log_e[8] = {1.8958048169567149, 1.6981417567726154, 0.5793212339927351, -1.215503791936417, -3.629396584023968, -6.690500273261249, -10.51540298415323, -15.41979457491781}; static constexpr double log_f[8] = {0., - -0.511105318617135, - -1.988286302259815, - -4.208049039384857, - -7.147448611626374, - -10.89973190740069, - -15.76637472711685, - -33.82373901099482}; + -0.511105318617135, + -1.988286302259815, + -4.208049039384857, + -7.147448611626374, + -10.89973190740069, + -15.76637472711685, + -33.82373901099482}; double val; double log_q = log_p <= LOG_HALF ? log_diff_exp(LOG_HALF, log_p) diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index 8e34e3c71fa..ba64d74317a 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -146,7 +146,8 @@ return_type_t wiener_lpdf( static constexpr double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI = LOG_TWO / 2 + LOG_SQRT_PI; // square(pi()) * 0.5 - static constexpr double SQUARE_PI_OVER_TWO = 9.869604401089358618834490999876151135 * 0.5; + static constexpr double SQUARE_PI_OVER_TWO + = 9.869604401089358618834490999876151135 * 0.5; static constexpr double TWO_TIMES_LOG_SQRT_PI = 2.0 * LOG_SQRT_PI; for (size_t i = 0; i < N; i++) { diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 19488d6befc..58a4486235c 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); From ca0ca56d76f1e17170724e31895fc82f96345095 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 14:08:45 -0400 Subject: [PATCH 03/35] change static const strings to static constexpr const char* --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/batch_identity.hpp | 2 +- stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cholesky_decompose.hpp | 2 +- stan/math/opencl/kernels/diag_inv.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/opencl/kernels/fill_strict_tri.hpp | 2 +- stan/math/opencl/kernels/gp_exp_quad_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_exponential_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_matern32_cov.hpp | 4 ++-- stan/math/opencl/kernels/gp_matern52_cov.hpp | 4 ++-- stan/math/opencl/kernels/indexing_rev.hpp | 6 +++--- stan/math/opencl/kernels/inv_lower_tri_multiply.hpp | 2 +- stan/math/opencl/kernels/matrix_multiply.hpp | 4 ++-- stan/math/opencl/kernels/multiply_transpose.hpp | 2 +- stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp | 2 +- stan/math/opencl/kernels/pack.hpp | 2 +- stan/math/opencl/kernels/rep_matrix.hpp | 2 +- stan/math/opencl/kernels/unpack.hpp | 2 +- 20 files changed, 27 insertions(+), 27 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 169b2528cd1..81f4c94f440 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr std::string add_batch_kernel_code = STRINGIFY( +static constexpr const char* add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/batch_identity.hpp b/stan/math/opencl/kernels/batch_identity.hpp index 0b38a6bea3d..dda23be8b0f 100644 --- a/stan/math/opencl/kernels/batch_identity.hpp +++ b/stan/math/opencl/kernels/batch_identity.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string batch_identity_kernel_code = STRINGIFY( +static constexpr const char* batch_identity_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels diff --git a/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp b/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp index 33d23af00d9..8af85009a73 100644 --- a/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp +++ b/stan/math/opencl/kernels/categorical_logit_glm_lpmf.hpp @@ -10,7 +10,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr std::string categorical_logit_glm_kernel_code = STRINGIFY( +static constexpr const char* categorical_logit_glm_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU implementation of Generalized Linear Model (GLM) diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 5c93bf3b525..5a2cf62e666 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string is_symmetric_kernel_code = STRINGIFY( +static constexpr const char* is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cholesky_decompose.hpp b/stan/math/opencl/kernels/cholesky_decompose.hpp index 31f6f2caf61..c9f0a6a067f 100644 --- a/stan/math/opencl/kernels/cholesky_decompose.hpp +++ b/stan/math/opencl/kernels/cholesky_decompose.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string cholesky_decompose_kernel_code = STRINGIFY( +static constexpr const char* cholesky_decompose_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Calculates the Cholesky Decomposition of a matrix on an OpenCL diff --git a/stan/math/opencl/kernels/diag_inv.hpp b/stan/math/opencl/kernels/diag_inv.hpp index a4368f20ea8..b8af6a9aa5e 100644 --- a/stan/math/opencl/kernels/diag_inv.hpp +++ b/stan/math/opencl/kernels/diag_inv.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string diag_inv_kernel_code = STRINGIFY( +static constexpr const char* diag_inv_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Calculates inplace submatrix inversions along the matrix diagonal. diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 2d8728fbef2..95f006c53d4 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string divide_columns_kernel_code = STRINGIFY( +static constexpr const char* divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/opencl/kernels/fill_strict_tri.hpp b/stan/math/opencl/kernels/fill_strict_tri.hpp index dca81dc9360..ee059e2226d 100644 --- a/stan/math/opencl/kernels/fill_strict_tri.hpp +++ b/stan/math/opencl/kernels/fill_strict_tri.hpp @@ -11,7 +11,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string fill_strict_tri_kernel_code = STRINGIFY( +static constexpr const char* fill_strict_tri_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Stores constant in the triangular part of a matrix diff --git a/stan/math/opencl/kernels/gp_exp_quad_cov.hpp b/stan/math/opencl/kernels/gp_exp_quad_cov.hpp index f647ef160f5..8e6d47f6b81 100644 --- a/stan/math/opencl/kernels/gp_exp_quad_cov.hpp +++ b/stan/math/opencl/kernels/gp_exp_quad_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string gp_exp_quad_cov_kernel_code = STRINGIFY( +static constexpr const char* gp_exp_quad_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of squared exponential kernel. @@ -51,7 +51,7 @@ const kernel_cl gp_exp_quad_cov("gp_exp_quad_cov", {gp_exp_quad_cov_kernel_code}); // \cond -static constexpr std::string gp_exp_quad_cov_cross_kernel_code = STRINGIFY( +static constexpr const char* gp_exp_quad_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of squared exponential kernel. diff --git a/stan/math/opencl/kernels/gp_exponential_cov.hpp b/stan/math/opencl/kernels/gp_exponential_cov.hpp index 1ec3163c7fe..722d50cb11b 100644 --- a/stan/math/opencl/kernels/gp_exponential_cov.hpp +++ b/stan/math/opencl/kernels/gp_exponential_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string gp_exponential_cov_kernel_code = STRINGIFY( +static constexpr const char* gp_exponential_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern exponential kernel. @@ -53,7 +53,7 @@ const kernel_cl gp_exponential_cov("gp_exponential_cov", {gp_exponential_cov_kernel_code}); // \cond -static constexpr std::string gp_exponential_cov_cross_kernel_code = STRINGIFY( +static constexpr const char* gp_exponential_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern exponential kernel. diff --git a/stan/math/opencl/kernels/gp_matern32_cov.hpp b/stan/math/opencl/kernels/gp_matern32_cov.hpp index ae44d64b39f..973e58a6670 100644 --- a/stan/math/opencl/kernels/gp_matern32_cov.hpp +++ b/stan/math/opencl/kernels/gp_matern32_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string gp_matern32_cov_kernel_code = STRINGIFY( +static constexpr const char* gp_matern32_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 3/2 kernel. @@ -54,7 +54,7 @@ const kernel_cl gp_matern32_cov("gp_matern32_cov", {gp_matern32_cov_kernel_code}); // \cond -static constexpr std::string gp_matern32_cov_cross_kernel_code = STRINGIFY( +static constexpr const char* gp_matern32_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 3/2 kernel. diff --git a/stan/math/opencl/kernels/gp_matern52_cov.hpp b/stan/math/opencl/kernels/gp_matern52_cov.hpp index 334ba9d25c3..75d229872cf 100644 --- a/stan/math/opencl/kernels/gp_matern52_cov.hpp +++ b/stan/math/opencl/kernels/gp_matern52_cov.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr std::string gp_matern52_cov_kernel_code = STRINGIFY( +static constexpr const char* gp_matern52_cov_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 5/2 kernel. @@ -56,7 +56,7 @@ const kernel_cl gp_matern52_cov("gp_matern52_cov", {gp_matern52_cov_kernel_code}); // \cond -static constexpr std::string gp_matern52_cov_cross_kernel_code = STRINGIFY( +static constexpr const char* gp_matern52_cov_cross_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * GPU part of calculation of Matern 5/2 kernel. diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 3c4e67f3439..c866128900e 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -13,7 +13,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr std::string indexing_rev_global_atomic_kernel_code = STRINGIFY( +static constexpr const char* indexing_rev_global_atomic_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * @@ -51,7 +51,7 @@ const kernel_cl indexing_rev_global_atomic_kernel_code}); // \cond -static constexpr std::string indexing_rev_local_atomic_kernel_code = STRINGIFY( +static constexpr const char* indexing_rev_local_atomic_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * @@ -102,7 +102,7 @@ const kernel_cl Date: Thu, 20 Oct 2022 14:10:17 -0400 Subject: [PATCH 04/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- .../opencl/kernels/cholesky_decompose.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/opencl/kernels/indexing_rev.hpp | 58 +++++++++---------- .../kernels/neg_rect_lower_tri_multiply.hpp | 55 +++++++++--------- 6 files changed, 62 insertions(+), 59 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 81f4c94f440..e37e2b21cdc 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* add_batch_kernel_code = STRINGIFY( +static constexpr const char *add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 5a2cf62e666..81efa9f5d9c 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* is_symmetric_kernel_code = STRINGIFY( +static constexpr const char *is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cholesky_decompose.hpp b/stan/math/opencl/kernels/cholesky_decompose.hpp index c9f0a6a067f..cac42c651bd 100644 --- a/stan/math/opencl/kernels/cholesky_decompose.hpp +++ b/stan/math/opencl/kernels/cholesky_decompose.hpp @@ -30,7 +30,7 @@ static constexpr const char* cholesky_decompose_kernel_code = STRINGIFY( * This kernel uses the helper macros available in helpers.cl. * */ - __kernel void cholesky_decompose(__global double *A, int rows) { + __kernel void cholesky_decompose(__global double* A, int rows) { const int local_index = get_local_id(0); // The following code is the sequential version of the inplace // cholesky decomposition. Only the innermost loops are parallelized. The diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 95f006c53d4..9bad330ebaa 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* divide_columns_kernel_code = STRINGIFY( +static constexpr const char *divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index d9408b95b3a..deaeb008edf 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -124,37 +124,37 @@ static constexpr const char* indexing_rev_local_independent_kernel_code = STRING const __global double* res, __local double* adj_loc, int index_size, int adj_size) { - const int gid = get_global_id(0); - const int lid = get_local_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - for (int i = lid; i < adj_size * lsize; i += lsize) { - adj_loc[i] = 0; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = gid; i < index_size; i += gsize) { - adj_loc[index[i] + lid * adj_size] += res[i]; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - double p = adj_loc[i + adj_size]; - for (int j = 2; j < lsize; j++) { - p += adj_loc[i + j * adj_size]; - } - // \cond + const int gid = get_global_id(0); + const int lid = get_local_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + for (int i = lid; i < adj_size * lsize; i += lsize) { + adj_loc[i] = 0; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = gid; i < index_size; i += gsize) { + adj_loc[index[i] + lid * adj_size] += res[i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + double p = adj_loc[i + adj_size]; + for (int j = 2; j < lsize; j++) { + p += adj_loc[i + j * adj_size]; + } + // \cond ); -// \endcond + // \endcond -/** \ingroup opencl_kernels - * See the docs for \link kernels/add.hpp add_batch() \endlink - */ -const kernel_cl - indexing_rev_local_independent( - "indexing_rev", {atomic_add_double_device_function, - indexing_rev_local_independent_kernel_code}); -} // namespace opencl_kernels + /** \ingroup opencl_kernels + * See the docs for \link kernels/add.hpp add_batch() \endlink + */ + const kernel_cl + indexing_rev_local_independent( + "indexing_rev", {atomic_add_double_device_function, + indexing_rev_local_independent_kernel_code}); + } // namespace opencl_kernels } // namespace math -} // namespace stan +} // namespace opencl_kernels #endif #endif diff --git a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp index 116ba8d4aa0..c4d09a399cb 100644 --- a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp +++ b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp @@ -10,33 +10,36 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* neg_rect_lower_tri_multiply_kernel_code = STRINGIFY( - // \endcond - /** \ingroup opencl_kernels - * Calculates C = -B * A where B is rectangular and A is a lower - * triangular. - * For a full guide to the inverse lower triangular kernels see the link - * here. - * - * ![Inverse Calculation](https://goo.gl/6jBjEG) - * - * Graphically, this kernel calculates `-temp * C1` where temp is the - * C2 * A3 calculation from - * \link kernels/inv_lower_tri_multiply.hpp inv_lower_tri_multiply() - \endlink - * The kernel is executed using (N, N, m) threads, where N is the size of - * the input matrices. +static constexpr const char* neg_rect_lower_tri_multiply_kernel_code + = STRINGIFY( + // \endcond + /** \ingroup opencl_kernels + * Calculates C = -B * A where B is rectangular and A is a lower + * triangular. + * For a full guide to the inverse lower triangular kernels see the + link + * here. + * + * ![Inverse Calculation](https://goo.gl/6jBjEG) + * + * Graphically, this kernel calculates `-temp * C1` where temp is the + * C2 * A3 calculation from + * \link kernels/inv_lower_tri_multiply.hpp inv_lower_tri_multiply() + \endlink + * The kernel is executed using (N, N, m) threads, where N is the size + of + * the input matrices. - * @param[in, out] A Input matrix that is being inverted. - * @param[in] temp Temporary matrix with the intermediate results. - * @param A_rows Number of rows for A. - * @param rows The number of rows in a single matrix of the batch - * @note Code is a const char* held in - * neg_rect_lower_tri_multiply_kernel_code - * Used in math/opencl/tri_inverse.hpp. - * This kernel uses the helper macros available in helpers.cl. - */ + * @param[in, out] A Input matrix that is being inverted. + * @param[in] temp Temporary matrix with the intermediate results. + * @param A_rows Number of rows for A. + * @param rows The number of rows in a single matrix of the batch + * @note Code is a const char* held in + * neg_rect_lower_tri_multiply_kernel_code + * Used in math/opencl/tri_inverse.hpp. + * This kernel uses the helper macros available in helpers.cl. + */ __kernel void neg_rect_lower_tri_multiply( __global double* A, const __global double* temp, const int A_rows, const int rows) { From f200221aaad11302ca7f5512135edf28c3db6dc1 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 14:53:16 -0400 Subject: [PATCH 05/35] update --- .../opencl/kernel_generator/multi_result_kernel.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index deee4ea7cca..ddb117d081f 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -71,7 +71,7 @@ struct multi_result_kernel_internal { next::check_assign_dimensions(n_rows, n_cols, assignment_pairs); const auto& expression = std::get(assignment_pairs).second; const auto& result = std::get(assignment_pairs).first; - constexpr char* function = "results.operator="; + constexpr const char* function = "results.operator="; int expression_rows = expression.rows(); int expression_cols = expression.cols(); @@ -377,8 +377,8 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; static constexpr bool require_specific_local_size - = stan::math::disjunction::Deriv::require_specific_local_size...>::value; + = stan::math::disjunction::Deriv::require_specific_local_size>...>::value; name_generator ng; std::map generated; @@ -444,14 +444,14 @@ class results_cl { T_res...>::template inner; static constexpr bool any_output = stan::math::disjunction< - !is_without_output>::value...>::value; + stan::math::bool_constant>::value>...>::value; if (!any_output) { return; } static constexpr bool require_specific_local_size - = stan::math::disjunction::Deriv::require_specific_local_size...>::value; + = stan::math::disjunction::Deriv::require_specific_local_size>...>::value; int n_rows = std::get<0>(assignment_pairs).second.thread_rows(); int n_cols = std::get<0>(assignment_pairs).second.thread_cols(); From f6b5c5246ecb0800a1e8d63dbae86f03523f5f5e Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 20 Oct 2022 14:54:00 -0400 Subject: [PATCH 06/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernel_generator/multi_result_kernel.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index ddb117d081f..a1bb6b19b33 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -443,8 +443,9 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; - static constexpr bool any_output = stan::math::disjunction< - stan::math::bool_constant>::value>...>::value; + static constexpr bool any_output + = stan::math::disjunction>::value>...>::value; if (!any_output) { return; } From b8f8a604a88600ba02c2ebf61fc76cf50dcd5cc1 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 15:52:30 -0400 Subject: [PATCH 07/35] Fix namespace for bool_constant --- stan/math/opencl/kernel_generator/multi_result_kernel.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index ddb117d081f..7d225f13cd4 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -377,7 +377,7 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; static constexpr bool require_specific_local_size - = stan::math::disjunction::Deriv::require_specific_local_size>...>::value; name_generator ng; @@ -444,13 +444,13 @@ class results_cl { T_res...>::template inner; static constexpr bool any_output = stan::math::disjunction< - stan::math::bool_constant>::value>...>::value; + stan::bool_constant>::value>...>::value; if (!any_output) { return; } static constexpr bool require_specific_local_size - = stan::math::disjunction::Deriv::require_specific_local_size>...>::value; int n_rows = std::get<0>(assignment_pairs).second.thread_rows(); From e21588ec357e98665db4c2d4cac6fbab33519bdc Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 20 Oct 2022 15:53:37 -0400 Subject: [PATCH 08/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernel_generator/multi_result_kernel.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp index 7d225f13cd4..f315f86ad95 100644 --- a/stan/math/opencl/kernel_generator/multi_result_kernel.hpp +++ b/stan/math/opencl/kernel_generator/multi_result_kernel.hpp @@ -443,8 +443,9 @@ class results_cl { std::tuple_size>::value - 1, T_res...>::template inner; - static constexpr bool any_output = stan::math::disjunction< - stan::bool_constant>::value>...>::value; + static constexpr bool any_output + = stan::math::disjunction>::value>...>::value; if (!any_output) { return; } From 265f0cfdba2d6e3a45fe7c98089ad0a0985b5b38 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 17:23:41 -0400 Subject: [PATCH 09/35] remove constexpr from opencl double_d type --- stan/math/opencl/mrrr.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stan/math/opencl/mrrr.hpp b/stan/math/opencl/mrrr.hpp index 0d15cde8ac5..ec9e565e57f 100644 --- a/stan/math/opencl/mrrr.hpp +++ b/stan/math/opencl/mrrr.hpp @@ -21,7 +21,7 @@ namespace internal { using VectorXdd = Eigen::Matrix; using MatrixXdd = Eigen::Matrix; -static constexpr double_d perturbation_range = 1e-20; +static const double_d perturbation_range = 1e-20; /** * Generates a random number for perturbing a relatively robust representation @@ -29,8 +29,8 @@ static constexpr double_d perturbation_range = 1e-20; * / 2` and `1 + perturbation_range / 2`. */ inline double_d get_random_perturbation_multiplier() { - static constexpr double_d rand_norm = perturbation_range / RAND_MAX; - static constexpr double_d almost_one = 1 - perturbation_range * 0.5; + static const double_d rand_norm = perturbation_range / RAND_MAX; + static const double_d almost_one = 1 - perturbation_range * 0.5; return almost_one + std::rand() * rand_norm; } From 9af36593fdf9c5d70e2bfe4266584de9203961b9 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 17:56:20 -0400 Subject: [PATCH 10/35] cpplint fixes --- stan/math/opencl/kernels/indexing_rev.hpp | 5 +++-- stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp | 2 +- stan/math/opencl/kernels/tridiagonalization.hpp | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index deaeb008edf..2cc453d3516 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -102,7 +102,8 @@ const kernel_cl From ca927a18368136bfbf82c9b2fcaed87a60012c7d Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 20 Oct 2022 17:56:57 -0400 Subject: [PATCH 11/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp | 2 +- stan/math/opencl/kernels/tridiagonalization.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp index a2299a29e78..4864f025220 100644 --- a/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp +++ b/stan/math/opencl/kernels/neg_rect_lower_tri_multiply.hpp @@ -122,7 +122,7 @@ static constexpr const char* neg_rect_lower_tri_multiply_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond /** \ingroup opencl_kernels diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index acf1050dd0f..1bd5e927b80 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -97,7 +97,7 @@ static constexpr const char* tridiagonalization_householder_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond // \cond @@ -165,7 +165,7 @@ static constexpr const char* tridiagonalization_v_step_1_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond // \cond @@ -245,7 +245,7 @@ static constexpr const char* tridiagonalization_v_step_2_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond // \cond @@ -303,7 +303,7 @@ static constexpr const char* tridiagonalization_v_step_3_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond const kernel_cl From 0bc2be0c2eb73441ec49533022e0f1403e869784 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 20 Oct 2022 23:08:55 -0400 Subject: [PATCH 12/35] fix weiner_lpdf --- stan/math/prim/prob/wiener_lpdf.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index ba64d74317a..79b623dd840 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -140,7 +140,7 @@ return_type_t wiener_lpdf( static constexpr double WIENER_ERR = 0.000001; static constexpr double PI_TIMES_WIENER_ERR = pi() * WIENER_ERR; - static constexpr double LOG_PI_LOG_WIENER_ERR = LOG_PI + log(WIENER_ERR); + static constexpr double LOG_PI_LOG_WIENER_ERR = LOG_PI + -13.81551055796427410410794872810618524; static constexpr double TWO_TIMES_SQRT_TWO_PI_TIMES_WIENER_ERR = 2.0 * SQRT_TWO_PI * WIENER_ERR; static constexpr double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI From 1d2d4aa42ae4bb0707b1bbd2275671386ed4ebd2 Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 20 Oct 2022 23:09:54 -0400 Subject: [PATCH 13/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/prim/prob/wiener_lpdf.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index 79b623dd840..540c590d428 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -140,7 +140,8 @@ return_type_t wiener_lpdf( static constexpr double WIENER_ERR = 0.000001; static constexpr double PI_TIMES_WIENER_ERR = pi() * WIENER_ERR; - static constexpr double LOG_PI_LOG_WIENER_ERR = LOG_PI + -13.81551055796427410410794872810618524; + static constexpr double LOG_PI_LOG_WIENER_ERR + = LOG_PI + -13.81551055796427410410794872810618524; static constexpr double TWO_TIMES_SQRT_TWO_PI_TIMES_WIENER_ERR = 2.0 * SQRT_TWO_PI * WIENER_ERR; static constexpr double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI From 67d3781522fa6f50bbde840cb87577760ee0b8fb Mon Sep 17 00:00:00 2001 From: stevebronder Date: Tue, 25 Oct 2022 10:04:39 -0400 Subject: [PATCH 14/35] header fix for hypergeometric_2F1 --- stan/math/prim/fun/hypergeometric_2F1.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stan/math/prim/fun/hypergeometric_2F1.hpp b/stan/math/prim/fun/hypergeometric_2F1.hpp index d66f14f1ac8..2dbae6bc418 100644 --- a/stan/math/prim/fun/hypergeometric_2F1.hpp +++ b/stan/math/prim/fun/hypergeometric_2F1.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include From fa56ba8c50a4440061925264e0ba58db387cd418 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 3 Nov 2022 10:44:32 -0400 Subject: [PATCH 15/35] fix index_rev missing } --- stan/math/opencl/kernels/indexing_rev.hpp | 65 +++++++++++++---------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 2cc453d3516..834f2eb02b3 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -103,7 +103,7 @@ const kernel_cl - indexing_rev_local_independent( - "indexing_rev", {atomic_add_double_device_function, - indexing_rev_local_independent_kernel_code}); - } // namespace opencl_kernels -} // namespace math +/** \ingroup opencl_kernels + * See the docs for \link kernels/add.hpp add_batch() \endlink + */ +const kernel_cl + indexing_rev_local_independent( + "indexing_rev", {atomic_add_double_device_function, + indexing_rev_local_independent_kernel_code}); } // namespace opencl_kernels +} // namespace math +} // namespace stan #endif #endif From 184978f52b3ef78e2916fe624f7844758b6aeaed Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 3 Nov 2022 10:46:03 -0400 Subject: [PATCH 16/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/indexing_rev.hpp | 96 +++++++++++------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 834f2eb02b3..c95eecce95e 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -102,55 +102,55 @@ const kernel_clconst char* held in - * add_batch_kernel_code. - */ - __kernel void indexing_rev(__global double* adj, const __global int* index, - const __global double* res, - __local double* adj_loc, int index_size, - int adj_size) { - const int gid = get_global_id(0); - const int lid = get_local_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - for (int i = lid; i < adj_size * lsize; i += lsize) { - adj_loc[i] = 0; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = gid; i < index_size; i += gsize) { - adj_loc[index[i] + lid * adj_size] += res[i]; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - double p = adj_loc[i + adj_size]; - for (int j = 2; j < lsize; j++) { - p += adj_loc[i + j * adj_size]; +static constexpr const char* indexing_rev_local_independent_kernel_code + = STRINGIFY( + // \endcond + /** \ingroup opencl_kernels + * + * Increments adjoint of the indexing operation argument given the + * indices and adjoints of the indexing result. + * + * This kernel makes each thread build its own copy of the adjoints + * before combining them. It is the fastest (and only works for) small + * size of the indexed matrix. + * + * @param[in,out] adj adjoint to increment + * @param index + * @param res adjoint of the result of indexing + * @param batch_size Number of matrices in the batch. + * @note Code is a const char* held in + * add_batch_kernel_code. + */ + __kernel void indexing_rev( + __global double* adj, const __global int* index, + const __global double* res, __local double* adj_loc, int index_size, + int adj_size) { + const int gid = get_global_id(0); + const int lid = get_local_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + for (int i = lid; i < adj_size * lsize; i += lsize) { + adj_loc[i] = 0; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = gid; i < index_size; i += gsize) { + adj_loc[index[i] + lid * adj_size] += res[i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + double p = adj_loc[i + adj_size]; + for (int j = 2; j < lsize; j++) { + p += adj_loc[i + j * adj_size]; + } + adj_loc[i] += p; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + atomic_add_double(adj + i, adj_loc[i]); + } } - adj_loc[i] += p; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - atomic_add_double(adj + i, adj_loc[i]); - } - } - // \cond -); + // \cond + ); // \endcond /** \ingroup opencl_kernels From 88c421101fcfa3eb2996c73f4cf459d53a3346a5 Mon Sep 17 00:00:00 2001 From: stevebronder Date: Thu, 3 Nov 2022 11:54:13 -0400 Subject: [PATCH 17/35] ignore whitespace cpplint for opencl kernel --- stan/math/opencl/kernels/indexing_rev.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index c95eecce95e..34b87abdafd 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -150,7 +150,7 @@ static constexpr const char* indexing_rev_local_independent_kernel_code } } // \cond - ); + ); // NOLINT(whitespace/parens) // \endcond /** \ingroup opencl_kernels From 1a9b1c14b1bd44fd7c3fa581d3e852b002925115 Mon Sep 17 00:00:00 2001 From: Stan BuildBot Date: Thu, 3 Nov 2022 11:55:06 -0400 Subject: [PATCH 18/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/indexing_rev.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 34b87abdafd..292dcdd5a3f 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -150,7 +150,7 @@ static constexpr const char* indexing_rev_local_independent_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond /** \ingroup opencl_kernels From 8779172932690d72a7df1e1398bf055d0a1bf8dc Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Fri, 26 May 2023 04:27:34 -0400 Subject: [PATCH 19/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/indexing_rev.hpp | 98 +++++++++++------------ 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index cb2c598f951..d6657ae6657 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -103,56 +103,56 @@ const kernel_clconst char* held in - * add_batch_kernel_code. - */ - __kernel void indexing_rev(__global double* adj, const __global int* index, - const __global double* res, - __local double* adj_loc, int index_size, - int adj_size) { - const int gid = get_global_id(0); - const int lid = get_local_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - for (int i = lid; i < adj_size * lsize; i += lsize) { - adj_loc[i] = 0; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = gid; i < index_size; i += gsize) { - adj_loc[index[i] + lid * adj_size] += res[i]; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - double p = adj_loc[i + adj_size]; - for (int j = 2; j < lsize; j++) { - p += adj_loc[i + j * adj_size]; + = STRINGIFY( + // \endcond + /** \ingroup opencl_kernels + * + * Increments adjoint of the indexing operation argument given the + * indices and adjoints of the indexing result. + * + * This kernel makes each thread build its own copy of the adjoints + * before combining them. It is the fastest (and only works for) small + * size of the indexed matrix. + * + * @param[in,out] adj adjoint to increment + * @param index int array index + * @param res adjoint of the result of indexing + * @param adj_loc + * @param index_size number of elements in index + * @param adj_size + * @note Code is a const char* held in + * add_batch_kernel_code. + */ + __kernel void indexing_rev( + __global double* adj, const __global int* index, + const __global double* res, __local double* adj_loc, int index_size, + int adj_size) { + const int gid = get_global_id(0); + const int lid = get_local_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + for (int i = lid; i < adj_size * lsize; i += lsize) { + adj_loc[i] = 0; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = gid; i < index_size; i += gsize) { + adj_loc[index[i] + lid * adj_size] += res[i]; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + double p = adj_loc[i + adj_size]; + for (int j = 2; j < lsize; j++) { + p += adj_loc[i + j * adj_size]; + } + adj_loc[i] += p; + } + barrier(CLK_LOCAL_MEM_FENCE); + for (int i = lid; i < adj_size; i += lsize) { + atomic_add_double(adj + i, adj_loc[i]); + } } - adj_loc[i] += p; - } - barrier(CLK_LOCAL_MEM_FENCE); - for (int i = lid; i < adj_size; i += lsize) { - atomic_add_double(adj + i, adj_loc[i]); - } - } - // \cond -); + // \cond + ); // \endcond /** \ingroup opencl_kernels From 7f2b34e38f8d965d29493beb1efc1224e90caa2a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 26 May 2023 11:34:32 +0300 Subject: [PATCH 20/35] Missed cpplint in merge --- stan/math/opencl/kernels/indexing_rev.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index d6657ae6657..5cb0ac9d61c 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -152,7 +152,7 @@ static constexpr const char* indexing_rev_local_independent_kernel_code } } // \cond - ); + ); // NOLINT(whitespace/parens) // \endcond /** \ingroup opencl_kernels From 5ca9e19744d0fbda0bc640abbab03b909eab944f Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Fri, 26 May 2023 04:35:30 -0400 Subject: [PATCH 21/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/indexing_rev.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stan/math/opencl/kernels/indexing_rev.hpp b/stan/math/opencl/kernels/indexing_rev.hpp index 5cb0ac9d61c..c69d5d3f094 100644 --- a/stan/math/opencl/kernels/indexing_rev.hpp +++ b/stan/math/opencl/kernels/indexing_rev.hpp @@ -152,7 +152,7 @@ static constexpr const char* indexing_rev_local_independent_kernel_code } } // \cond - ); // NOLINT(whitespace/parens) + ); // NOLINT(whitespace/parens) // \endcond /** \ingroup opencl_kernels From 12597cec696414bab1643a84f794b3eeacdadada Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 20 Jul 2023 16:56:39 -0400 Subject: [PATCH 22/35] update with simplifications for constant values --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- .../opencl/kernels/device_functions/atomic_add_double.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/prim/fun/constants.hpp | 6 ++---- stan/math/prim/fun/log.hpp | 4 +--- stan/math/prim/fun/log10.hpp | 2 +- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/wiener_lpdf.hpp | 6 ++---- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +++--- stan/math/rev/functor/integrate_1d.hpp | 2 +- 17 files changed, 23 insertions(+), 29 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index e37e2b21cdc..81f4c94f440 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *add_batch_kernel_code = STRINGIFY( +static constexpr const char* add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 81efa9f5d9c..5a2cf62e666 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *is_symmetric_kernel_code = STRINGIFY( +static constexpr const char* is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index 12e5d94ca97..c05b819441a 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp index b07e1246d24..221ce4c546b 100644 --- a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp +++ b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *atomic_add_double_device_function +static constexpr const char* atomic_add_double_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 9bad330ebaa..95f006c53d4 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *divide_columns_kernel_code = STRINGIFY( +static constexpr const char* divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index f88653ea585..f8e9b26d275 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -77,8 +77,7 @@ const double LOG_EPSILON = std::log(EPSILON); * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. */ -static constexpr double LOG_PI - = 1.14472988584940017414342735135305871164729481291531157151362; +static constexpr double LOG_PI = 2 * boost::math::constants::log_root_two_pi() - LOG_TWO; /** * The natural logarithm of 2, @@ -108,8 +107,7 @@ static constexpr double LOG_PI_OVER_FOUR = 0.25 * LOG_PI; * The natural logarithm of the square root of \f$ \pi \f$, * \f$ \log(sqrt{\pi}) \f$. */ -static constexpr double LOG_SQRT_PI - = 0.5723649429247000870717136756765293558236474064576557857568115357; +static constexpr double LOG_SQRT_PI = LOG_PI / 2; /** * The natural logarithm of 10, diff --git a/stan/math/prim/fun/log.hpp b/stan/math/prim/fun/log.hpp index d18c35db721..0a538027f7d 100644 --- a/stan/math/prim/fun/log.hpp +++ b/stan/math/prim/fun/log.hpp @@ -76,11 +76,9 @@ namespace internal { */ template inline std::complex complex_log(const std::complex& z) { - static constexpr double inf = std::numeric_limits::infinity(); - static constexpr double nan = std::numeric_limits::quiet_NaN(); if ((is_nan(z.real()) && is_inf(z.imag())) || (is_inf(z.real()) && is_nan(z.imag()))) { - return {inf, nan}; + return {INFTY, NOT_A_NUMBER}; } V r = sqrt(norm(z)); V theta = arg(z); diff --git a/stan/math/prim/fun/log10.hpp b/stan/math/prim/fun/log10.hpp index b7e4f72af10..02e60664a29 100644 --- a/stan/math/prim/fun/log10.hpp +++ b/stan/math/prim/fun/log10.hpp @@ -67,7 +67,7 @@ namespace internal { */ template inline std::complex complex_log10(const std::complex& z) { - static constexpr double inv_log_10 = 1 / 2.30258509299404568401799145468; + static constexpr double inv_log_10 = 1.0f / LOG_TEN; return log(z) * inv_log_10; } } // namespace internal diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index a96ecfd5c3c..7445ae2d269 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char *function = "beta_binomial_rng"; + static constexpr const char* function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 61bb114f00f..90ca685786a 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static constexpr const char *function = "beta_proportion_rng"; + static constexpr const char* function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index 9fdc839bf4e..1f544c857f9 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char *function = "beta_rng"; + static constexpr const char* function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 9417ec6317a..9ac4f2184c1 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static constexpr const char *function = "gaussian_dlm_obs_rng"; + static constexpr const char* function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index e7a1d275fb2..b3d508060a8 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char *function = "matrix_normal_prec_rng"; + static constexpr const char* function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index b3c7c63f518..a206fa79ea5 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char *function = "multi_normal_prec_rng"; + static constexpr const char* function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/prim/prob/wiener_lpdf.hpp b/stan/math/prim/prob/wiener_lpdf.hpp index 540c590d428..a61d0959deb 100644 --- a/stan/math/prim/prob/wiener_lpdf.hpp +++ b/stan/math/prim/prob/wiener_lpdf.hpp @@ -140,15 +140,13 @@ return_type_t wiener_lpdf( static constexpr double WIENER_ERR = 0.000001; static constexpr double PI_TIMES_WIENER_ERR = pi() * WIENER_ERR; - static constexpr double LOG_PI_LOG_WIENER_ERR - = LOG_PI + -13.81551055796427410410794872810618524; + static constexpr double LOG_PI_LOG_WIENER_ERR = LOG_PI - 6 * LOG_TEN; static constexpr double TWO_TIMES_SQRT_TWO_PI_TIMES_WIENER_ERR = 2.0 * SQRT_TWO_PI * WIENER_ERR; static constexpr double LOG_TWO_OVER_TWO_PLUS_LOG_SQRT_PI = LOG_TWO / 2 + LOG_SQRT_PI; // square(pi()) * 0.5 - static constexpr double SQUARE_PI_OVER_TWO - = 9.869604401089358618834490999876151135 * 0.5; + static constexpr double SQUARE_PI_OVER_TWO = (pi() * pi()) / 2; static constexpr double TWO_TIMES_LOG_SQRT_PI = 2.0 * LOG_SQRT_PI; for (size_t i = 0; i < N; i++) { diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 58a4486235c..19488d6befc 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); diff --git a/stan/math/rev/functor/integrate_1d.hpp b/stan/math/rev/functor/integrate_1d.hpp index 60607db7894..5d29eea2037 100644 --- a/stan/math/rev/functor/integrate_1d.hpp +++ b/stan/math/rev/functor/integrate_1d.hpp @@ -41,7 +41,7 @@ template integrate_1d_impl( const F &f, const T_a &a, const T_b &b, double relative_tolerance, std::ostream *msgs, const Args &... args) { - static constexpr const char *function = "integrate_1d"; + static constexpr const char* function = "integrate_1d"; check_less_or_equal(function, "lower limit", a, b); double a_val = value_of(a); From 092c0be6114ba35757b7e356ebc8850e49da4c7a Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 20 Jul 2023 17:01:18 -0400 Subject: [PATCH 23/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- .../opencl/kernels/device_functions/atomic_add_double.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/prim/fun/constants.hpp | 3 ++- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +++--- stan/math/rev/functor/integrate_1d.hpp | 2 +- 14 files changed, 19 insertions(+), 18 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 81f4c94f440..e37e2b21cdc 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* add_batch_kernel_code = STRINGIFY( +static constexpr const char *add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 5a2cf62e666..81efa9f5d9c 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* is_symmetric_kernel_code = STRINGIFY( +static constexpr const char *is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index c05b819441a..12e5d94ca97 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp index 221ce4c546b..b07e1246d24 100644 --- a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp +++ b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* atomic_add_double_device_function +static constexpr const char *atomic_add_double_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 95f006c53d4..9bad330ebaa 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* divide_columns_kernel_code = STRINGIFY( +static constexpr const char *divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index f8e9b26d275..dedba05018f 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -77,7 +77,8 @@ const double LOG_EPSILON = std::log(EPSILON); * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. */ -static constexpr double LOG_PI = 2 * boost::math::constants::log_root_two_pi() - LOG_TWO; +static constexpr double LOG_PI + = 2 * boost::math::constants::log_root_two_pi() - LOG_TWO; /** * The natural logarithm of 2, diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index 7445ae2d269..a96ecfd5c3c 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_binomial_rng"; + static constexpr const char *function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 90ca685786a..61bb114f00f 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static constexpr const char* function = "beta_proportion_rng"; + static constexpr const char *function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index 1f544c857f9..9fdc839bf4e 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_rng"; + static constexpr const char *function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 9ac4f2184c1..9417ec6317a 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static constexpr const char* function = "gaussian_dlm_obs_rng"; + static constexpr const char *function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index b3d508060a8..e7a1d275fb2 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "matrix_normal_prec_rng"; + static constexpr const char *function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index a206fa79ea5..b3c7c63f518 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "multi_normal_prec_rng"; + static constexpr const char *function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 19488d6befc..58a4486235c 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); diff --git a/stan/math/rev/functor/integrate_1d.hpp b/stan/math/rev/functor/integrate_1d.hpp index 5d29eea2037..60607db7894 100644 --- a/stan/math/rev/functor/integrate_1d.hpp +++ b/stan/math/rev/functor/integrate_1d.hpp @@ -41,7 +41,7 @@ template integrate_1d_impl( const F &f, const T_a &a, const T_b &b, double relative_tolerance, std::ostream *msgs, const Args &... args) { - static constexpr const char* function = "integrate_1d"; + static constexpr const char *function = "integrate_1d"; check_less_or_equal(function, "lower limit", a, b); double a_val = value_of(a); From e9cf9cf74e8dc88ce17bb558b45fb766d169e747 Mon Sep 17 00:00:00 2001 From: Steve Bronder Date: Thu, 20 Jul 2023 17:03:51 -0400 Subject: [PATCH 24/35] update headers --- stan/math/prim/fun/log.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/stan/math/prim/fun/log.hpp b/stan/math/prim/fun/log.hpp index 0a538027f7d..75a2dcd00b9 100644 --- a/stan/math/prim/fun/log.hpp +++ b/stan/math/prim/fun/log.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include From ef5fbdcfbb6f35587421f47a4e6c7f8fca080b6e Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Tue, 19 Sep 2023 09:33:58 -0400 Subject: [PATCH 25/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- .../opencl/kernels/tridiagonalization.hpp | 709 +++++++++--------- 1 file changed, 357 insertions(+), 352 deletions(-) diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index 4138a0c4cd0..6c72087475f 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -36,68 +36,68 @@ static constexpr const char* tridiagonalization_householder_kernel_code double q = 0; - const int P_start = P_rows * (k + j) + k + j; - const int P_span = P_rows * (k + j + 1) - P_start; - for (int i = lid; i < P_span; i += lsize) { - double acc = 0; - // apply previous householder reflections from current block to the - // column we are making the Householder vector from - for (int l = 0; l < j; l++) { - acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] - + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; - } - double tmp = P[P_start + i] - acc; - P[P_start + i] = tmp; - if (i != 0) { - q += tmp * tmp; - } - } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; + const int P_start = P_rows * (k + j) + k + j; + const int P_span = P_rows * (k + j + 1) - P_start; + for (int i = lid; i < P_span; i += lsize) { + double acc = 0; + // apply previous householder reflections from current block to the + // column we are making the Householder vector from + for (int l = 0; l < j; l++) { + acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] + + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; + } + double tmp = P[P_start + i] - acc; + P[P_start + i] = tmp; + if (i != 0) { + q += tmp * tmp; + } + } + // calculate column norm between threads + __local double q_local[LOCAL_SIZE_]; + q_local[lid] = q; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + q_local[lid] += q_local[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = M_SQRT2 / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; + double alpha; + if (lid == 0) { + q = q_local[0]; + double p1 = P[P_start + 1]; + // make Householder vector + alpha = -copysign(sqrt(q), P[P_start]); + q -= p1 * p1; + p1 -= alpha; + P[P_start + 1] = p1; + q += p1 * p1; + q = sqrt(q); + q_local[0] = q; + q_local[1] = alpha; + *q_glob = q; + } + barrier(CLK_LOCAL_MEM_FENCE); + q = q_local[0]; + alpha = q_local[1]; + if (q != 0) { + double multi = M_SQRT2 / q; + // normalize the Householder vector + for (int i = lid + 1; i < P_span; i += lsize) { + P[P_start + i] *= multi; + } + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] + = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; + } } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; - } - } - // \cond -); + // \cond + ); // \endcond // \cond @@ -186,303 +186,305 @@ static const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( const __global double* P, __global double* V, const __global double* Uu, const __global double* Vu, const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - int work = P_rows - k - j - 1; - double acc = 0; + int work = P_rows - k - j - 1; + double acc = 0; - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; + const __global double* vec = P + P_rows * (k + j) + k + j + 1; + const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; + const __global double* M2 = P + P_rows * k + k + j + 1; + const __global double* M3 = V + j; + int i; + if (gid < work) { + for (i = 0; i <= gid; i++) { + acc += M1[P_rows * i + gid] * vec[i]; + } + for (int i = 0; i < j; i++) { + acc -= M2[P_rows * i + gid] * Vu[i]; + acc -= M3[V_rows * i + gid] * Uu[i]; + } + V[V_rows * j + gid + j] = acc; + } + float work_per_group = (float)work / ngroups; // NOLINT(readability/casting) + int start = work_per_group * wgid; + int end = work_per_group * (wgid + 1); + __local double res_loc[LOCAL_SIZE_]; + for (int i = start; i < end; i += 1) { + acc = 0; + for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { + acc += M1[P_rows * i + l] * vec[l]; + } + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; } - V[V_rows * j + gid + j] = acc; } - float work_per_group - = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; + // calculate column norm between threads + __local double q_local[LOCAL_SIZE_]; + q_local[lid] = q; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + q_local[lid] += q_local[lid + step * i]; + } } - res_loc[lid] = acc; barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; - } - } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; - } - } - barrier(CLK_LOCAL_MEM_FENCE); - } + } - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = sqrt(2.) / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; - } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / sqrt(2.) + alpha; - } + double alpha; + if (lid == 0) { + q = q_local[0]; + double p1 = P[P_start + 1]; + // make Householder vector + alpha = -copysign(sqrt(q), P[P_start]); + q -= p1 * p1; + p1 -= alpha; + P[P_start + 1] = p1; + q += p1 * p1; + q = sqrt(q); + q_local[0] = q; + q_local[1] = alpha; + *q_glob = q; + } + barrier(CLK_LOCAL_MEM_FENCE); + q = q_local[0]; + alpha = q_local[1]; + if (q != 0) { + double multi = sqrt(2.) / q; + // normalize the Householder vector + for (int i = lid + 1; i < P_span; i += lsize) { + P[P_start + i] *= multi; } - // \cond + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] + = P[P_rows * (k + j) + k + j + 1] * q / sqrt(2.) + alpha; + } + } + // \cond ); // NOLINT(whitespace/parens) -// \endcond + // \endcond -// \cond -static constexpr const char* tridiagonalization_v_step_1_kernel_code - = STRINGIFY( - // \endcond - /** - * Calculates first part of constructing the vector v: Uu = Pb * u and - * Vu = Vl * u. Pb is a block of packed matrix, Vl is left part of - * matrix V and u is householder vector. Must be run with number of work - * groups equal to size of resulting vectors and 64 threads per work - * group. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param[out] Uu First resulting vector. - * @param[out] Vu Second resulting vector. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - */ - __kernel void tridiagonalization_v_step_1( - const __global double* P, const __global double* V, - __global double* Uu, __global double* Vu, const int P_rows, - const int V_rows, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); + // \cond + static constexpr const char* tridiagonalization_v_step_1_kernel_code + = STRINGIFY( + // \endcond + /** + * Calculates first part of constructing the vector v: Uu = Pb * u + * and Vu = Vl * u. Pb is a block of packed matrix, Vl is left part + * of matrix V and u is householder vector. Must be run with number + * of work groups equal to size of resulting vectors and 64 threads + * per work group. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param[out] Uu First resulting vector. + * @param[out] Vu Second resulting vector. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as + * input + */ + __kernel void tridiagonalization_v_step_1( + const __global double* P, const __global double* V, + __global double* Uu, __global double* Vu, const int P_rows, + const int V_rows, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __local double res_loc1[LOCAL_SIZE_]; - __local double res_loc2[LOCAL_SIZE_]; - double acc1 = 0; - double acc2 = 0; + __local double res_loc1[LOCAL_SIZE_]; + __local double res_loc2[LOCAL_SIZE_]; + double acc1 = 0; + double acc2 = 0; - const __global double* vec - = P + P_rows * (k + ngroups) + k + ngroups + 1; - const __global double* M1 = P + P_rows * (k + wgid) + k + ngroups + 1; - const __global double* M2 = V + V_rows * wgid + ngroups; - for (int i = lid; i < P_rows - k - ngroups - 1; - i - += LOCAL_SIZE_) { // go over column of the matrix in steps of 64 - double v = vec[i]; - acc1 += M1[i] * v; - acc2 += M2[i] * v; - } - res_loc1[lid] = acc1; - res_loc2[lid] = acc2; - barrier(CLK_LOCAL_MEM_FENCE); + const __global double* vec + = P + P_rows * (k + ngroups) + k + ngroups + 1; + const __global double* M1 + = P + P_rows * (k + wgid) + k + ngroups + 1; + const __global double* M2 = V + V_rows * wgid + ngroups; + for (int i = lid; i < P_rows - k - ngroups - 1; + i += LOCAL_SIZE_) { // go over column of the matrix in steps + // of 64 + double v = vec[i]; + acc1 += M1[i] * v; + acc2 += M2[i] * v; + } + res_loc1[lid] = acc1; + res_loc2[lid] = acc2; + barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc1[lid] += res_loc1[lid + step * i]; - res_loc2[lid] += res_loc2[lid + step * i]; + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc1[lid] += res_loc1[lid + step * i]; + res_loc2[lid] += res_loc2[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + Uu[wgid] = res_loc1[0]; + Vu[wgid] = res_loc2[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - Uu[wgid] = res_loc1[0]; - Vu[wgid] = res_loc2[0]; - } - } <<<<<<< HEAD - // \cond - ); // NOLINT(whitespace/parens) -// \endcond + // \cond + ); // NOLINT(whitespace/parens) + // \endcond -// \cond -static constexpr const char* tridiagonalization_v_step_2_kernel_code - = STRINGIFY( - // \endcond - /** - * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. - * Pb is a block of packed matrix and U is householder vector. Pb is - * symmetric with only lower triangle having values. That is why two - * columns of V are written that must be added to obtain the vector v. - * Must be run with 64 threads per work group and total number of - * threads equal or greater than size of result vector. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param Uu Uu from previous kernel. - * @param Vu Vu from previous kernel. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_2( - const __global double* P, __global double* V, - const __global double* Uu, const __global double* Vu, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); + // \cond + static constexpr const char* tridiagonalization_v_step_2_kernel_code + = STRINGIFY( + // \endcond + /** + * Second part in constructing vector v: v = Pb * u + V * Uu + U * + * Vu. Pb is a block of packed matrix and U is householder vector. + * Pb is symmetric with only lower triangle having values. That is + * why two columns of V are written that must be added to obtain the + * vector v. Must be run with 64 threads per work group and total + * number of threads equal or greater than size of result vector. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param Uu Uu from previous kernel. + * @param Vu Vu from previous kernel. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as + * input + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_2( + const __global double* P, __global double* V, + const __global double* Uu, const __global double* Vu, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - int work = P_rows - k - j - 1; - double acc = 0; + int work = P_rows - k - j - 1; + double acc = 0; - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; - } - V[V_rows * j + gid + j] = acc; - } - float work_per_group - = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; - } - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + const __global double* vec = P + P_rows * (k + j) + k + j + 1; + const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; + const __global double* M2 = P + P_rows * k + k + j + 1; + const __global double* M3 = V + j; + int i; + if (gid < work) { + for (i = 0; i <= gid; i++) { + acc += M1[P_rows * i + gid] * vec[i]; + } + for (int i = 0; i < j; i++) { + acc -= M2[P_rows * i + gid] * Vu[i]; + acc -= M3[V_rows * i + gid] * Uu[i]; } + V[V_rows * j + gid + j] = acc; + } + float work_per_group + = (float)work / ngroups; // NOLINT(readability/casting) + int start = work_per_group * wgid; + int end = work_per_group * (wgid + 1); + __local double res_loc[LOCAL_SIZE_]; + for (int i = start; i < end; i += 1) { + acc = 0; + for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { + acc += M1[P_rows * i + l] * vec[l]; + } + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + V[V_rows * (j + 1) + i + j] = res_loc[lid]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - V[V_rows * (j + 1) + i + j] = res_loc[lid]; } - barrier(CLK_LOCAL_MEM_FENCE); - } - } - // \cond - ); // NOLINT(whitespace/parens) -// \endcond + // \cond + ); // NOLINT(whitespace/parens) + // \endcond -// \cond -static constexpr const char* tridiagonalization_v_step_3_kernel_code - = STRINGIFY( - // \endcond - /** - * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the - * householder vector. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block to create - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_3( - __global double* P, __global double* V, __global double* q, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); + // \cond + static constexpr const char* tridiagonalization_v_step_3_kernel_code + = STRINGIFY( + // \endcond + /** + * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is + * the householder vector. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block to create + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_3( + __global double* P, __global double* V, __global double* q, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __global double* u = P + P_rows * (k + j) + k + j + 1; - __global double* v = V + V_rows * j + j; - double acc = 0; + __global double* u = P + P_rows * (k + j) + k + j + 1; + __global double* v = V + V_rows * j + j; + double acc = 0; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - double vi = v[i] + v[i + V_rows]; - v[i] = vi; - acc += u[i] * vi; - } - __local double res_loc[LOCAL_SIZE_]; - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + double vi = v[i] + v[i + V_rows]; + v[i] = vi; + acc += u[i] * vi; + } + __local double res_loc[LOCAL_SIZE_]; + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + acc = res_loc[0] * 0.5; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + v[i] -= acc * u[i]; + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] -= *q / sqrt(2.) * u[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - acc = res_loc[0] * 0.5; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - v[i] -= acc * u[i]; - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] -= *q / sqrt(2.) * u[0]; - } - } - // \cond - ); // NOLINT(whitespace/parens) + // \cond + ); // NOLINT(whitespace/parens) ======= barrier(CLK_LOCAL_MEM_FENCE); } @@ -497,34 +499,37 @@ static constexpr const char* tridiagonalization_v_step_3_kernel_code // \cond ); >>>>>>> develop -// \endcond + // \endcond -const kernel_cl - tridiagonalization_householder("tridiagonalization_householder", - {tridiagonalization_householder_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, - {"LOCAL_SIZE_", 1024}}); + const kernel_cl + tridiagonalization_householder( + "tridiagonalization_householder", + {tridiagonalization_householder_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 1024}}); -const kernel_cl - tridiagonalization_v_step_1("tridiagonalization_v_step_1", - {tridiagonalization_v_step_1_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, - {"LOCAL_SIZE_", 64}}); + const kernel_cl + tridiagonalization_v_step_1( + "tridiagonalization_v_step_1", + {tridiagonalization_v_step_1_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 64}}); -const kernel_cl - tridiagonalization_v_step_2("tridiagonalization_v_step_2", - {tridiagonalization_v_step_2_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, - {"LOCAL_SIZE_", 64}}); + const kernel_cl + tridiagonalization_v_step_2( + "tridiagonalization_v_step_2", + {tridiagonalization_v_step_2_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 64}}); -const kernel_cl - tridiagonalization_v_step_3("tridiagonalization_v_step_3", - {tridiagonalization_v_step_3_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, - {"LOCAL_SIZE_", 1024}}); + const kernel_cl + tridiagonalization_v_step_3( + "tridiagonalization_v_step_3", + {tridiagonalization_v_step_3_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 1024}}); -} // namespace opencl_kernels + } // namespace opencl_kernels } // namespace math -} // namespace stan +} // namespace opencl_kernels #endif #endif From d2d4cee9f0f46920fc81dbfbe62b4f4b065739b2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 19 Sep 2023 16:41:35 +0300 Subject: [PATCH 26/35] Fix header tests --- stan/math/prim/fun/constants.hpp | 12 ++++++------ stan/math/prim/prob/bernoulli_lccdf.hpp | 2 +- stan/math/prim/prob/bernoulli_lcdf.hpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index dedba05018f..ab77c472c00 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -73,6 +73,12 @@ static constexpr double LOG_ZERO = -INFTY; */ const double LOG_EPSILON = std::log(EPSILON); +/** + * The natural logarithm of 2, + * \f$ \log 2 \f$. + */ +static constexpr double LOG_TWO = boost::math::constants::ln_two(); + /** * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. @@ -80,12 +86,6 @@ const double LOG_EPSILON = std::log(EPSILON); static constexpr double LOG_PI = 2 * boost::math::constants::log_root_two_pi() - LOG_TWO; -/** - * The natural logarithm of 2, - * \f$ \log 2 \f$. - */ -static constexpr double LOG_TWO = boost::math::constants::ln_two(); - /** * The natural logarithm of 0.5, * \f$ \log 0.5 = \log 1 - \log 2 \f$. diff --git a/stan/math/prim/prob/bernoulli_lccdf.hpp b/stan/math/prim/prob/bernoulli_lccdf.hpp index 48b99e3738d..ee2802c20aa 100644 --- a/stan/math/prim/prob/bernoulli_lccdf.hpp +++ b/stan/math/prim/prob/bernoulli_lccdf.hpp @@ -31,7 +31,7 @@ template * = nullptr> return_type_t bernoulli_lccdf(const T_n& n, const T_prob& theta) { using T_theta_ref = ref_type_t; - static constexpr char* function = "bernoulli_lccdf"; + static constexpr const char* function = "bernoulli_lccdf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); T_theta_ref theta_ref = theta; diff --git a/stan/math/prim/prob/bernoulli_lcdf.hpp b/stan/math/prim/prob/bernoulli_lcdf.hpp index b1ceee39aa8..c2d8ef53867 100644 --- a/stan/math/prim/prob/bernoulli_lcdf.hpp +++ b/stan/math/prim/prob/bernoulli_lcdf.hpp @@ -29,7 +29,7 @@ template * = nullptr> return_type_t bernoulli_lcdf(const T_n& n, const T_prob& theta) { using T_theta_ref = ref_type_t; - static constexpr char* function = "bernoulli_lcdf"; + static constexpr const char* function = "bernoulli_lcdf"; check_consistent_sizes(function, "Random variable", n, "Probability parameter", theta); T_theta_ref theta_ref = theta; From b6349788c9678eb63c8d2de6cb89811dbae20c5c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 19 Sep 2023 17:03:40 +0300 Subject: [PATCH 27/35] Fix merge breakage --- .../opencl/kernels/tridiagonalization.hpp | 590 ++++++------------ 1 file changed, 192 insertions(+), 398 deletions(-) diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index 6c72087475f..1a85d9d5cb1 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -10,98 +10,97 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* tridiagonalization_householder_kernel_code - = STRINGIFY( - // \endcond - /** - * Calculates householder vector and first element of the vector v. - * Must be run with 1 workgroup of LOCAL_SIZE_ threads. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q_glob q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param j Start column of the block to work on - * @param k Index of the householder vector in the block to create - */ - __kernel void tridiagonalization_householder( - __global double* P, __global double* V, __global double* q_glob, - const int P_rows, const int V_rows, const int j, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_householder_kernel_code = STRINGIFY( + // \endcond + /** + * Calculates householder vector and first element of the vector v. + * Must be run with 1 workgroup of LOCAL_SIZE_ threads. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q_glob q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param j Start column of the block to work on + * @param k Index of the householder vector in the block to create + */ + __kernel void tridiagonalization_householder( + __global double* P, __global double* V, __global double* q_glob, + const int P_rows, const int V_rows, const int j, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - double q = 0; + double q = 0; - const int P_start = P_rows * (k + j) + k + j; - const int P_span = P_rows * (k + j + 1) - P_start; - for (int i = lid; i < P_span; i += lsize) { - double acc = 0; - // apply previous householder reflections from current block to the - // column we are making the Householder vector from - for (int l = 0; l < j; l++) { - acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] - + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; - } - double tmp = P[P_start + i] - acc; - P[P_start + i] = tmp; - if (i != 0) { - q += tmp * tmp; - } - } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; - } - } - barrier(CLK_LOCAL_MEM_FENCE); + const int P_start = P_rows * (k + j) + k + j; + const int P_span = P_rows * (k + j + 1) - P_start; + for (int i = lid; i < P_span; i += lsize) { + double acc = 0; + // apply previous householder reflections from current block to the + // column we are making the Householder vector from + for (int l = 0; l < j; l++) { + acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] + + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; + } + double tmp = P[P_start + i] - acc; + P[P_start + i] = tmp; + if (i != 0) { + q += tmp * tmp; + } + } + // calculate column norm between threads + __local double q_local[LOCAL_SIZE_]; + q_local[lid] = q; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + q_local[lid] += q_local[lid + step * i]; } + } + barrier(CLK_LOCAL_MEM_FENCE); + } - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = M_SQRT2 / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; - } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; - } + double alpha; + if (lid == 0) { + q = q_local[0]; + double p1 = P[P_start + 1]; + // make Householder vector + alpha = -copysign(sqrt(q), P[P_start]); + q -= p1 * p1; + p1 -= alpha; + P[P_start + 1] = p1; + q += p1 * p1; + q = sqrt(q); + q_local[0] = q; + q_local[1] = alpha; + *q_glob = q; + } + barrier(CLK_LOCAL_MEM_FENCE); + q = q_local[0]; + alpha = q_local[1]; + if (q != 0) { + double multi = M_SQRT2 / q; + // normalize the Householder vector + for (int i = lid + 1; i < P_span; i += lsize) { + P[P_start + i] *= multi; } - // \cond - ); + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] + = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; + } + } + // \cond +); // \endcond // \cond -static const char* tridiagonalization_v_step_1_kernel_code = STRINGIFY( +static constexpr const char* tridiagonalization_v_step_1_kernel_code = STRINGIFY( // \endcond /** * Calculates first part of constructing the vector v: Uu = Pb * u and Vu = @@ -164,7 +163,7 @@ static const char* tridiagonalization_v_step_1_kernel_code = STRINGIFY( // \endcond // \cond -static const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( +static constexpr const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( // \endcond /** * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. Pb is @@ -186,306 +185,105 @@ static const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( const __global double* P, __global double* V, const __global double* Uu, const __global double* Vu, const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - int work = P_rows - k - j - 1; - double acc = 0; + int work = P_rows - k - j - 1; + double acc = 0; - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; - } - V[V_rows * j + gid + j] = acc; - } - float work_per_group = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; - } - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + const __global double* vec = P + P_rows * (k + j) + k + j + 1; + const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; + const __global double* M2 = P + P_rows * k + k + j + 1; + const __global double* M3 = V + j; + int i; + if (gid < work) { + for (i = 0; i <= gid; i++) { + acc += M1[P_rows * i + gid] * vec[i]; } + for (int i = 0; i < j; i++) { + acc -= M2[P_rows * i + gid] * Vu[i]; + acc -= M3[V_rows * i + gid] * Uu[i]; + } + V[V_rows * j + gid + j] = acc; } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; - } + float work_per_group + = (float)work / ngroups; // NOLINT(readability/casting) + int start = work_per_group * wgid; + int end = work_per_group * (wgid + 1); + __local double res_loc[LOCAL_SIZE_]; + for (int i = start; i < end; i += 1) { + acc = 0; + for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { + acc += M1[P_rows * i + l] * vec[l]; } + res_loc[lid] = acc; barrier(CLK_LOCAL_MEM_FENCE); - } - - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = sqrt(2.) / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / sqrt(2.) + alpha; + if (lid == 0) { + V[V_rows * (j + 1) + i + j] = res_loc[lid]; + } + barrier(CLK_LOCAL_MEM_FENCE); } } // \cond - ); // NOLINT(whitespace/parens) - // \endcond - - // \cond - static constexpr const char* tridiagonalization_v_step_1_kernel_code - = STRINGIFY( - // \endcond - /** - * Calculates first part of constructing the vector v: Uu = Pb * u - * and Vu = Vl * u. Pb is a block of packed matrix, Vl is left part - * of matrix V and u is householder vector. Must be run with number - * of work groups equal to size of resulting vectors and 64 threads - * per work group. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param[out] Uu First resulting vector. - * @param[out] Vu Second resulting vector. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as - * input - */ - __kernel void tridiagonalization_v_step_1( - const __global double* P, const __global double* V, - __global double* Uu, __global double* Vu, const int P_rows, - const int V_rows, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); - - __local double res_loc1[LOCAL_SIZE_]; - __local double res_loc2[LOCAL_SIZE_]; - double acc1 = 0; - double acc2 = 0; - - const __global double* vec - = P + P_rows * (k + ngroups) + k + ngroups + 1; - const __global double* M1 - = P + P_rows * (k + wgid) + k + ngroups + 1; - const __global double* M2 = V + V_rows * wgid + ngroups; - for (int i = lid; i < P_rows - k - ngroups - 1; - i += LOCAL_SIZE_) { // go over column of the matrix in steps - // of 64 - double v = vec[i]; - acc1 += M1[i] * v; - acc2 += M2[i] * v; - } - res_loc1[lid] = acc1; - res_loc2[lid] = acc2; - barrier(CLK_LOCAL_MEM_FENCE); - - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc1[lid] += res_loc1[lid + step * i]; - res_loc2[lid] += res_loc2[lid + step * i]; - } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - Uu[wgid] = res_loc1[0]; - Vu[wgid] = res_loc2[0]; - } - } -<<<<<<< HEAD - // \cond - ); // NOLINT(whitespace/parens) - // \endcond - - // \cond - static constexpr const char* tridiagonalization_v_step_2_kernel_code - = STRINGIFY( - // \endcond - /** - * Second part in constructing vector v: v = Pb * u + V * Uu + U * - * Vu. Pb is a block of packed matrix and U is householder vector. - * Pb is symmetric with only lower triangle having values. That is - * why two columns of V are written that must be added to obtain the - * vector v. Must be run with 64 threads per work group and total - * number of threads equal or greater than size of result vector. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param Uu Uu from previous kernel. - * @param Vu Vu from previous kernel. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as - * input - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_2( - const __global double* P, __global double* V, - const __global double* Uu, const __global double* Vu, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); - - int work = P_rows - k - j - 1; - double acc = 0; +); +// \endcond - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; - } - V[V_rows * j + gid + j] = acc; - } - float work_per_group - = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; - } - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; - } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - V[V_rows * (j + 1) + i + j] = res_loc[lid]; - } - barrier(CLK_LOCAL_MEM_FENCE); - } - } - // \cond - ); // NOLINT(whitespace/parens) +// \cond +static constexpr const char* tridiagonalization_v_step_3_kernel_code = STRINGIFY( // \endcond + /** + * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the + * householder vector. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block to create + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_3( + __global double* P, __global double* V, __global double* q, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - // \cond - static constexpr const char* tridiagonalization_v_step_3_kernel_code - = STRINGIFY( - // \endcond - /** - * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is - * the householder vector. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block to create - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_3( - __global double* P, __global double* V, __global double* q, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); - - __global double* u = P + P_rows * (k + j) + k + j + 1; - __global double* v = V + V_rows * j + j; - double acc = 0; + __global double* u = P + P_rows * (k + j) + k + j + 1; + __global double* v = V + V_rows * j + j; + double acc = 0; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - double vi = v[i] + v[i + V_rows]; - v[i] = vi; - acc += u[i] * vi; - } - __local double res_loc[LOCAL_SIZE_]; - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; - } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - acc = res_loc[0] * 0.5; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - v[i] -= acc * u[i]; - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] -= *q / sqrt(2.) * u[0]; - } - } - // \cond - ); // NOLINT(whitespace/parens) -======= + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + double vi = v[i] + v[i + V_rows]; + v[i] = vi; + acc += u[i] * vi; + } + __local double res_loc[LOCAL_SIZE_]; + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } barrier(CLK_LOCAL_MEM_FENCE); } acc = res_loc[0] * 0.5; @@ -498,38 +296,34 @@ static const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( } // \cond ); ->>>>>>> develop - // \endcond +// \endcond - const kernel_cl - tridiagonalization_householder( - "tridiagonalization_householder", - {tridiagonalization_householder_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 1024}}); +const kernel_cl + tridiagonalization_householder("tridiagonalization_householder", + {tridiagonalization_householder_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, + {"LOCAL_SIZE_", 1024}}); - const kernel_cl - tridiagonalization_v_step_1( - "tridiagonalization_v_step_1", - {tridiagonalization_v_step_1_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 64}}); +const kernel_cl + tridiagonalization_v_step_1("tridiagonalization_v_step_1", + {tridiagonalization_v_step_1_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, + {"LOCAL_SIZE_", 64}}); - const kernel_cl - tridiagonalization_v_step_2( - "tridiagonalization_v_step_2", - {tridiagonalization_v_step_2_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 64}}); +const kernel_cl + tridiagonalization_v_step_2("tridiagonalization_v_step_2", + {tridiagonalization_v_step_2_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, + {"LOCAL_SIZE_", 64}}); - const kernel_cl - tridiagonalization_v_step_3( - "tridiagonalization_v_step_3", - {tridiagonalization_v_step_3_kernel_code}, - {{"REDUCTION_STEP_SIZE", 4}, {"LOCAL_SIZE_", 1024}}); +const kernel_cl + tridiagonalization_v_step_3("tridiagonalization_v_step_3", + {tridiagonalization_v_step_3_kernel_code}, + {{"REDUCTION_STEP_SIZE", 4}, + {"LOCAL_SIZE_", 1024}}); - } // namespace opencl_kernels -} // namespace math } // namespace opencl_kernels +} // namespace math +} // namespace stan #endif #endif From 5be66536ca30785cda922070ea9da81b7ea2ddb2 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Tue, 19 Sep 2023 10:04:53 -0400 Subject: [PATCH 28/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- .../opencl/kernels/tridiagonalization.hpp | 524 +++++++++--------- 1 file changed, 266 insertions(+), 258 deletions(-) diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index 1a85d9d5cb1..67195e631c8 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -10,292 +10,300 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* tridiagonalization_householder_kernel_code = STRINGIFY( - // \endcond - /** - * Calculates householder vector and first element of the vector v. - * Must be run with 1 workgroup of LOCAL_SIZE_ threads. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q_glob q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param j Start column of the block to work on - * @param k Index of the householder vector in the block to create - */ - __kernel void tridiagonalization_householder( - __global double* P, __global double* V, __global double* q_glob, - const int P_rows, const int V_rows, const int j, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_householder_kernel_code + = STRINGIFY( + // \endcond + /** + * Calculates householder vector and first element of the vector v. + * Must be run with 1 workgroup of LOCAL_SIZE_ threads. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q_glob q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param j Start column of the block to work on + * @param k Index of the householder vector in the block to create + */ + __kernel void tridiagonalization_householder( + __global double* P, __global double* V, __global double* q_glob, + const int P_rows, const int V_rows, const int j, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - double q = 0; + double q = 0; - const int P_start = P_rows * (k + j) + k + j; - const int P_span = P_rows * (k + j + 1) - P_start; - for (int i = lid; i < P_span; i += lsize) { - double acc = 0; - // apply previous householder reflections from current block to the - // column we are making the Householder vector from - for (int l = 0; l < j; l++) { - acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] - + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; - } - double tmp = P[P_start + i] - acc; - P[P_start + i] = tmp; - if (i != 0) { - q += tmp * tmp; - } - } - // calculate column norm between threads - __local double q_local[LOCAL_SIZE_]; - q_local[lid] = q; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - q_local[lid] += q_local[lid + step * i]; + const int P_start = P_rows * (k + j) + k + j; + const int P_span = P_rows * (k + j + 1) - P_start; + for (int i = lid; i < P_span; i += lsize) { + double acc = 0; + // apply previous householder reflections from current block to the + // column we are making the Householder vector from + for (int l = 0; l < j; l++) { + acc += P[P_rows * (k + l) + k + j + i] * V[V_rows * l + j - 1] + + V[V_rows * l + j - 1 + i] * P[P_rows * (k + l) + k + j]; + } + double tmp = P[P_start + i] - acc; + P[P_start + i] = tmp; + if (i != 0) { + q += tmp * tmp; + } + } + // calculate column norm between threads + __local double q_local[LOCAL_SIZE_]; + q_local[lid] = q; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + q_local[lid] += q_local[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); } - } - barrier(CLK_LOCAL_MEM_FENCE); - } - double alpha; - if (lid == 0) { - q = q_local[0]; - double p1 = P[P_start + 1]; - // make Householder vector - alpha = -copysign(sqrt(q), P[P_start]); - q -= p1 * p1; - p1 -= alpha; - P[P_start + 1] = p1; - q += p1 * p1; - q = sqrt(q); - q_local[0] = q; - q_local[1] = alpha; - *q_glob = q; - } - barrier(CLK_LOCAL_MEM_FENCE); - q = q_local[0]; - alpha = q_local[1]; - if (q != 0) { - double multi = M_SQRT2 / q; - // normalize the Householder vector - for (int i = lid + 1; i < P_span; i += lsize) { - P[P_start + i] *= multi; + double alpha; + if (lid == 0) { + q = q_local[0]; + double p1 = P[P_start + 1]; + // make Householder vector + alpha = -copysign(sqrt(q), P[P_start]); + q -= p1 * p1; + p1 -= alpha; + P[P_start + 1] = p1; + q += p1 * p1; + q = sqrt(q); + q_local[0] = q; + q_local[1] = alpha; + *q_glob = q; + } + barrier(CLK_LOCAL_MEM_FENCE); + q = q_local[0]; + alpha = q_local[1]; + if (q != 0) { + double multi = M_SQRT2 / q; + // normalize the Householder vector + for (int i = lid + 1; i < P_span; i += lsize) { + P[P_start + i] *= multi; + } + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] + = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; + } } - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] - = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_1_kernel_code = STRINGIFY( - // \endcond - /** - * Calculates first part of constructing the vector v: Uu = Pb * u and Vu = - * Vl * u. Pb is a block of packed matrix, Vl is left part of matrix V and u - * is householder vector. Must be run with number of work groups equal to - * size of resulting vectors and 64 threads per work group. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param[out] Uu First resulting vector. - * @param[out] Vu Second resulting vector. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - */ - __kernel void tridiagonalization_v_step_1( - const __global double* P, const __global double* V, __global double* Uu, - __global double* Vu, const int P_rows, const int V_rows, const int k) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_1_kernel_code + = STRINGIFY( + // \endcond + /** + * Calculates first part of constructing the vector v: Uu = Pb * u and + * Vu = Vl * u. Pb is a block of packed matrix, Vl is left part of + * matrix V and u is householder vector. Must be run with number of work + * groups equal to size of resulting vectors and 64 threads per work + * group. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param[out] Uu First resulting vector. + * @param[out] Vu Second resulting vector. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as input + */ + __kernel void tridiagonalization_v_step_1( + const __global double* P, const __global double* V, + __global double* Uu, __global double* Vu, const int P_rows, + const int V_rows, const int k) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __local double res_loc1[LOCAL_SIZE_]; - __local double res_loc2[LOCAL_SIZE_]; - double acc1 = 0; - double acc2 = 0; + __local double res_loc1[LOCAL_SIZE_]; + __local double res_loc2[LOCAL_SIZE_]; + double acc1 = 0; + double acc2 = 0; - const __global double* vec = P + P_rows * (k + ngroups) + k + ngroups + 1; - const __global double* M1 = P + P_rows * (k + wgid) + k + ngroups + 1; - const __global double* M2 = V + V_rows * wgid + ngroups; - for (int i = lid; i < P_rows - k - ngroups - 1; - i += LOCAL_SIZE_) { // go over column of the matrix in steps of 64 - double v = vec[i]; - acc1 += M1[i] * v; - acc2 += M2[i] * v; - } - res_loc1[lid] = acc1; - res_loc2[lid] = acc2; - barrier(CLK_LOCAL_MEM_FENCE); + const __global double* vec + = P + P_rows * (k + ngroups) + k + ngroups + 1; + const __global double* M1 = P + P_rows * (k + wgid) + k + ngroups + 1; + const __global double* M2 = V + V_rows * wgid + ngroups; + for (int i = lid; i < P_rows - k - ngroups - 1; + i + += LOCAL_SIZE_) { // go over column of the matrix in steps of 64 + double v = vec[i]; + acc1 += M1[i] * v; + acc2 += M2[i] * v; + } + res_loc1[lid] = acc1; + res_loc2[lid] = acc2; + barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc1[lid] += res_loc1[lid + step * i]; - res_loc2[lid] += res_loc2[lid + step * i]; + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc1[lid] += res_loc1[lid + step * i]; + res_loc2[lid] += res_loc2[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + Uu[wgid] = res_loc1[0]; + Vu[wgid] = res_loc2[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - Uu[wgid] = res_loc1[0]; - Vu[wgid] = res_loc2[0]; - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_2_kernel_code = STRINGIFY( - // \endcond - /** - * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. Pb is - * a block of packed matrix and U is householder vector. Pb is symmetric - * with only lower triangle having values. That is why two columns of V are - * written that must be added to obtain the vector v. Must be run with 64 - * threads per work group and total number of threads equal or greater than - * size of result vector. - * @param P Packed matrix being constructed. - * @param V Matrix V. - * @param Uu Uu from previous kernel. - * @param Vu Vu from previous kernel. - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block we use as input - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_2( - const __global double* P, __global double* V, const __global double* Uu, - const __global double* Vu, const int P_rows, const int V_rows, - const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_2_kernel_code + = STRINGIFY( + // \endcond + /** + * Second part in constructing vector v: v = Pb * u + V * Uu + U * Vu. + * Pb is a block of packed matrix and U is householder vector. Pb is + * symmetric with only lower triangle having values. That is why two + * columns of V are written that must be added to obtain the vector v. + * Must be run with 64 threads per work group and total number of + * threads equal or greater than size of result vector. + * @param P Packed matrix being constructed. + * @param V Matrix V. + * @param Uu Uu from previous kernel. + * @param Vu Vu from previous kernel. + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block we use as input + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_2( + const __global double* P, __global double* V, + const __global double* Uu, const __global double* Vu, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - int work = P_rows - k - j - 1; - double acc = 0; + int work = P_rows - k - j - 1; + double acc = 0; - const __global double* vec = P + P_rows * (k + j) + k + j + 1; - const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; - const __global double* M2 = P + P_rows * k + k + j + 1; - const __global double* M3 = V + j; - int i; - if (gid < work) { - for (i = 0; i <= gid; i++) { - acc += M1[P_rows * i + gid] * vec[i]; - } - for (int i = 0; i < j; i++) { - acc -= M2[P_rows * i + gid] * Vu[i]; - acc -= M3[V_rows * i + gid] * Uu[i]; - } - V[V_rows * j + gid + j] = acc; - } - float work_per_group - = (float)work / ngroups; // NOLINT(readability/casting) - int start = work_per_group * wgid; - int end = work_per_group * (wgid + 1); - __local double res_loc[LOCAL_SIZE_]; - for (int i = start; i < end; i += 1) { - acc = 0; - for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { - acc += M1[P_rows * i + l] * vec[l]; - } - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + const __global double* vec = P + P_rows * (k + j) + k + j + 1; + const __global double* M1 = P + P_rows * (k + j + 1) + k + j + 1; + const __global double* M2 = P + P_rows * k + k + j + 1; + const __global double* M3 = V + j; + int i; + if (gid < work) { + for (i = 0; i <= gid; i++) { + acc += M1[P_rows * i + gid] * vec[i]; } + for (int i = 0; i < j; i++) { + acc -= M2[P_rows * i + gid] * Vu[i]; + acc -= M3[V_rows * i + gid] * Uu[i]; + } + V[V_rows * j + gid + j] = acc; + } + float work_per_group + = (float)work / ngroups; // NOLINT(readability/casting) + int start = work_per_group * wgid; + int end = work_per_group * (wgid + 1); + __local double res_loc[LOCAL_SIZE_]; + for (int i = start; i < end; i += 1) { + acc = 0; + for (int l = i + 1 + lid; l < work; l += LOCAL_SIZE_) { + acc += M1[P_rows * i + l] * vec[l]; + } + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + if (lid == 0) { + V[V_rows * (j + 1) + i + j] = res_loc[lid]; + } + barrier(CLK_LOCAL_MEM_FENCE); } - barrier(CLK_LOCAL_MEM_FENCE); - } - if (lid == 0) { - V[V_rows * (j + 1) + i + j] = res_loc[lid]; } - barrier(CLK_LOCAL_MEM_FENCE); - } - } - // \cond -); + // \cond + ); // \endcond // \cond -static constexpr const char* tridiagonalization_v_step_3_kernel_code = STRINGIFY( - // \endcond - /** - * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the - * householder vector. - * @param[in,out] P packed matrix being constructed - * @param[in,out] V matrix V - * @param[out] q q - * @param P_rows Number of rows of the packed matrix - * @param V_rows Number of rows of the matrix V - * @param k Index of the householder vector in the block to create - * @param j Start column of the block to work on - */ - __kernel void tridiagonalization_v_step_3( - __global double* P, __global double* V, __global double* q, - const int P_rows, const int V_rows, const int k, const int j) { - const int lid = get_local_id(0); - const int gid = get_global_id(0); - const int gsize = get_global_size(0); - const int lsize = get_local_size(0); - const int ngroups = get_num_groups(0); - const int wgid = get_group_id(0); +static constexpr const char* tridiagonalization_v_step_3_kernel_code + = STRINGIFY( + // \endcond + /** + * Third part in constructing vector v: v-=0.5*(v^T*u)*u, where u is the + * householder vector. + * @param[in,out] P packed matrix being constructed + * @param[in,out] V matrix V + * @param[out] q q + * @param P_rows Number of rows of the packed matrix + * @param V_rows Number of rows of the matrix V + * @param k Index of the householder vector in the block to create + * @param j Start column of the block to work on + */ + __kernel void tridiagonalization_v_step_3( + __global double* P, __global double* V, __global double* q, + const int P_rows, const int V_rows, const int k, const int j) { + const int lid = get_local_id(0); + const int gid = get_global_id(0); + const int gsize = get_global_size(0); + const int lsize = get_local_size(0); + const int ngroups = get_num_groups(0); + const int wgid = get_group_id(0); - __global double* u = P + P_rows * (k + j) + k + j + 1; - __global double* v = V + V_rows * j + j; - double acc = 0; + __global double* u = P + P_rows * (k + j) + k + j + 1; + __global double* v = V + V_rows * j + j; + double acc = 0; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - double vi = v[i] + v[i + V_rows]; - v[i] = vi; - acc += u[i] * vi; - } - __local double res_loc[LOCAL_SIZE_]; - res_loc[lid] = acc; - barrier(CLK_LOCAL_MEM_FENCE); - for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; - step /= REDUCTION_STEP_SIZE) { - if (lid < step) { - for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { - res_loc[lid] += res_loc[lid + step * i]; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + double vi = v[i] + v[i + V_rows]; + v[i] = vi; + acc += u[i] * vi; + } + __local double res_loc[LOCAL_SIZE_]; + res_loc[lid] = acc; + barrier(CLK_LOCAL_MEM_FENCE); + for (int step = lsize / REDUCTION_STEP_SIZE; step > 0; + step /= REDUCTION_STEP_SIZE) { + if (lid < step) { + for (int i = 1; i < REDUCTION_STEP_SIZE; i++) { + res_loc[lid] += res_loc[lid + step * i]; + } + } + barrier(CLK_LOCAL_MEM_FENCE); + } + acc = res_loc[0] * 0.5; + for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { + v[i] -= acc * u[i]; + } + if (gid == 0) { + P[P_rows * (k + j + 1) + k + j] -= *q / M_SQRT2 * u[0]; } } - barrier(CLK_LOCAL_MEM_FENCE); - } - acc = res_loc[0] * 0.5; - for (int i = lid; i < P_rows - k - j - 1; i += LOCAL_SIZE_) { - v[i] -= acc * u[i]; - } - if (gid == 0) { - P[P_rows * (k + j + 1) + k + j] -= *q / M_SQRT2 * u[0]; - } - } - // \cond -); + // \cond + ); // \endcond const kernel_cl From 57cc14073e96a6e16acc6883d29635e3a79be3b0 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 19 Sep 2023 17:15:17 +0300 Subject: [PATCH 29/35] Update char * to char* --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- .../opencl/kernels/device_functions/atomic_add_double.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +++--- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index e37e2b21cdc..81f4c94f440 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *add_batch_kernel_code = STRINGIFY( +static constexpr const char* add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 81efa9f5d9c..5a2cf62e666 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *is_symmetric_kernel_code = STRINGIFY( +static constexpr const char* is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index 12e5d94ca97..c05b819441a 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp index b07e1246d24..221ce4c546b 100644 --- a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp +++ b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *atomic_add_double_device_function +static constexpr const char* atomic_add_double_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 9bad330ebaa..95f006c53d4 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *divide_columns_kernel_code = STRINGIFY( +static constexpr const char* divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index a96ecfd5c3c..7445ae2d269 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char *function = "beta_binomial_rng"; + static constexpr const char* function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 61bb114f00f..90ca685786a 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static constexpr const char *function = "beta_proportion_rng"; + static constexpr const char* function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index 9fdc839bf4e..1f544c857f9 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char *function = "beta_rng"; + static constexpr const char* function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index 8ae0067b504..d79db9221e7 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static constexpr const char *function = "gaussian_dlm_obs_rng"; + static constexpr const char* function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index e7a1d275fb2..b3d508060a8 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char *function = "matrix_normal_prec_rng"; + static constexpr const char* function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index b3c7c63f518..a206fa79ea5 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char *function = "multi_normal_prec_rng"; + static constexpr const char* function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 58a4486235c..19488d6befc 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char *function = "mdivide_left_spd"; + static constexpr const char* function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); From 87245ad91cfcf4f3ce784b6b3143ed6a044b52f8 Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Tue, 19 Sep 2023 10:16:29 -0400 Subject: [PATCH 30/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- .../opencl/kernels/device_functions/atomic_add_double.hpp | 2 +- stan/math/opencl/kernels/divide_columns.hpp | 2 +- stan/math/prim/prob/beta_binomial_rng.hpp | 2 +- stan/math/prim/prob/beta_proportion_rng.hpp | 2 +- stan/math/prim/prob/beta_rng.hpp | 2 +- stan/math/prim/prob/gaussian_dlm_obs_rng.hpp | 2 +- stan/math/prim/prob/matrix_normal_prec_rng.hpp | 2 +- stan/math/prim/prob/multi_normal_prec_rng.hpp | 2 +- stan/math/rev/fun/mdivide_left_spd.hpp | 6 +++--- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 81f4c94f440..e37e2b21cdc 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* add_batch_kernel_code = STRINGIFY( +static constexpr const char *add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 5a2cf62e666..81efa9f5d9c 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* is_symmetric_kernel_code = STRINGIFY( +static constexpr const char *is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index c05b819441a..12e5d94ca97 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp index 221ce4c546b..b07e1246d24 100644 --- a/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp +++ b/stan/math/opencl/kernels/device_functions/atomic_add_double.hpp @@ -9,7 +9,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* atomic_add_double_device_function +static constexpr const char *atomic_add_double_device_function = "\n" "#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" "#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_ATOMIC_ADD_DOUBLE\n" diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 95f006c53d4..9bad330ebaa 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* divide_columns_kernel_code = STRINGIFY( +static constexpr const char *divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values diff --git a/stan/math/prim/prob/beta_binomial_rng.hpp b/stan/math/prim/prob/beta_binomial_rng.hpp index 7445ae2d269..a96ecfd5c3c 100644 --- a/stan/math/prim/prob/beta_binomial_rng.hpp +++ b/stan/math/prim/prob/beta_binomial_rng.hpp @@ -35,7 +35,7 @@ beta_binomial_rng(const T_N &N, const T_shape1 &alpha, const T_shape2 &beta, using T_N_ref = ref_type_t; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_binomial_rng"; + static constexpr const char *function = "beta_binomial_rng"; check_consistent_sizes(function, "First prior sample size parameter", alpha, "Second prior sample size parameter", beta); diff --git a/stan/math/prim/prob/beta_proportion_rng.hpp b/stan/math/prim/prob/beta_proportion_rng.hpp index 90ca685786a..61bb114f00f 100644 --- a/stan/math/prim/prob/beta_proportion_rng.hpp +++ b/stan/math/prim/prob/beta_proportion_rng.hpp @@ -36,7 +36,7 @@ inline typename VectorBuilder::type beta_proportion_rng(const T_loc &mu, const T_prec &kappa, RNG &rng) { using T_mu_ref = ref_type_t; using T_kappa_ref = ref_type_t; - static constexpr const char* function = "beta_proportion_rng"; + static constexpr const char *function = "beta_proportion_rng"; check_consistent_sizes(function, "Location parameter", mu, "Precision parameter", kappa); T_mu_ref mu_ref = mu; diff --git a/stan/math/prim/prob/beta_rng.hpp b/stan/math/prim/prob/beta_rng.hpp index 1f544c857f9..9fdc839bf4e 100644 --- a/stan/math/prim/prob/beta_rng.hpp +++ b/stan/math/prim/prob/beta_rng.hpp @@ -40,7 +40,7 @@ inline typename VectorBuilder::type beta_rng( using boost::random::uniform_real_distribution; using T_alpha_ref = ref_type_t; using T_beta_ref = ref_type_t; - static constexpr const char* function = "beta_rng"; + static constexpr const char *function = "beta_rng"; check_consistent_sizes(function, "First shape parameter", alpha, "Second shape Parameter", beta); T_alpha_ref alpha_ref = alpha; diff --git a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp index d79db9221e7..8ae0067b504 100644 --- a/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp +++ b/stan/math/prim/prob/gaussian_dlm_obs_rng.hpp @@ -92,7 +92,7 @@ inline Eigen::MatrixXd gaussian_dlm_obs_rng(const Eigen::MatrixXd &F, const Eigen::VectorXd &m0, const Eigen::MatrixXd &C0, const int T, RNG &rng) { - static constexpr const char* function = "gaussian_dlm_obs_rng"; + static constexpr const char *function = "gaussian_dlm_obs_rng"; int r = F.cols(); // number of variables int n = G.rows(); // number of states diff --git a/stan/math/prim/prob/matrix_normal_prec_rng.hpp b/stan/math/prim/prob/matrix_normal_prec_rng.hpp index b3d508060a8..e7a1d275fb2 100644 --- a/stan/math/prim/prob/matrix_normal_prec_rng.hpp +++ b/stan/math/prim/prob/matrix_normal_prec_rng.hpp @@ -35,7 +35,7 @@ inline Eigen::MatrixXd matrix_normal_prec_rng(const Eigen::MatrixXd &Mu, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "matrix_normal_prec_rng"; + static constexpr const char *function = "matrix_normal_prec_rng"; check_positive(function, "Sigma rows", Sigma.rows()); check_finite(function, "Sigma", Sigma); check_symmetric(function, "Sigma", Sigma); diff --git a/stan/math/prim/prob/multi_normal_prec_rng.hpp b/stan/math/prim/prob/multi_normal_prec_rng.hpp index a206fa79ea5..b3c7c63f518 100644 --- a/stan/math/prim/prob/multi_normal_prec_rng.hpp +++ b/stan/math/prim/prob/multi_normal_prec_rng.hpp @@ -34,7 +34,7 @@ inline typename StdVectorBuilder::type multi_normal_prec_rng(const T_loc &mu, const Eigen::MatrixXd &S, RNG &rng) { using boost::normal_distribution; using boost::variate_generator; - static constexpr const char* function = "multi_normal_prec_rng"; + static constexpr const char *function = "multi_normal_prec_rng"; check_positive(function, "Precision matrix rows", S.rows()); vector_seq_view mu_vec(mu); diff --git a/stan/math/rev/fun/mdivide_left_spd.hpp b/stan/math/rev/fun/mdivide_left_spd.hpp index 19488d6befc..58a4486235c 100644 --- a/stan/math/rev/fun/mdivide_left_spd.hpp +++ b/stan/math/rev/fun/mdivide_left_spd.hpp @@ -154,7 +154,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -185,7 +185,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); @@ -216,7 +216,7 @@ mdivide_left_spd(const EigMat1 &A, const EigMat2 &b) { constexpr int C1 = EigMat1::ColsAtCompileTime; constexpr int R2 = EigMat2::RowsAtCompileTime; constexpr int C2 = EigMat2::ColsAtCompileTime; - static constexpr const char* function = "mdivide_left_spd"; + static constexpr const char *function = "mdivide_left_spd"; check_multiplicable(function, "A", A, "b", b); const auto &A_ref = to_ref(A); check_symmetric(function, "A", A_ref); From c7dd4fd91ea56ad446cd72f8f0b0977ab4183eb5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 19 Sep 2023 17:29:37 +0300 Subject: [PATCH 31/35] Cpplint --- stan/math/opencl/kernels/tridiagonalization.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/stan/math/opencl/kernels/tridiagonalization.hpp b/stan/math/opencl/kernels/tridiagonalization.hpp index 67195e631c8..c8369dbd2fc 100644 --- a/stan/math/opencl/kernels/tridiagonalization.hpp +++ b/stan/math/opencl/kernels/tridiagonalization.hpp @@ -95,9 +95,7 @@ static constexpr const char* tridiagonalization_householder_kernel_code P[P_rows * (k + j + 1) + k + j] = P[P_rows * (k + j) + k + j + 1] * q / M_SQRT2 + alpha; } - } - // \cond - ); + }); // \cond // \endcond // \cond @@ -163,9 +161,7 @@ static constexpr const char* tridiagonalization_v_step_1_kernel_code Uu[wgid] = res_loc1[0]; Vu[wgid] = res_loc2[0]; } - } - // \cond - ); + }); // \cond // \endcond // \cond @@ -243,9 +239,7 @@ static constexpr const char* tridiagonalization_v_step_2_kernel_code } barrier(CLK_LOCAL_MEM_FENCE); } - } - // \cond - ); + }); // \cond // \endcond // \cond @@ -301,9 +295,7 @@ static constexpr const char* tridiagonalization_v_step_3_kernel_code if (gid == 0) { P[P_rows * (k + j + 1) + k + j] -= *q / M_SQRT2 * u[0]; } - } - // \cond - ); + }); // \cond // \endcond const kernel_cl From 952ea3ac8570aeea5cb19a29919a82825385b019 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 15 Feb 2024 17:08:32 +0200 Subject: [PATCH 32/35] const char* updates --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- stan/math/opencl/kernels/divide_columns.hpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index e37e2b21cdc..81f4c94f440 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *add_batch_kernel_code = STRINGIFY( +static constexpr const char* add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 81efa9f5d9c..5a2cf62e666 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *is_symmetric_kernel_code = STRINGIFY( +static constexpr const char* is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index 12e5d94ca97..c05b819441a 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 9bad330ebaa..95f006c53d4 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char *divide_columns_kernel_code = STRINGIFY( +static constexpr const char* divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values From f365972d03d4ee5a84d457d605862d8ab3b38f9a Mon Sep 17 00:00:00 2001 From: Stan Jenkins Date: Thu, 15 Feb 2024 10:10:09 -0500 Subject: [PATCH 33/35] [Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1 --- stan/math/opencl/kernels/add.hpp | 2 +- stan/math/opencl/kernels/check_symmetric.hpp | 2 +- stan/math/opencl/kernels/cumulative_sum.hpp | 6 +++--- stan/math/opencl/kernels/divide_columns.hpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stan/math/opencl/kernels/add.hpp b/stan/math/opencl/kernels/add.hpp index 81f4c94f440..e37e2b21cdc 100644 --- a/stan/math/opencl/kernels/add.hpp +++ b/stan/math/opencl/kernels/add.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* add_batch_kernel_code = STRINGIFY( +static constexpr const char *add_batch_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Sums a batch of matrices. Buffer A contains diff --git a/stan/math/opencl/kernels/check_symmetric.hpp b/stan/math/opencl/kernels/check_symmetric.hpp index 5a2cf62e666..81efa9f5d9c 100644 --- a/stan/math/opencl/kernels/check_symmetric.hpp +++ b/stan/math/opencl/kernels/check_symmetric.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* is_symmetric_kernel_code = STRINGIFY( +static constexpr const char *is_symmetric_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Check if the matrix_cl is symmetric diff --git a/stan/math/opencl/kernels/cumulative_sum.hpp b/stan/math/opencl/kernels/cumulative_sum.hpp index c05b819441a..12e5d94ca97 100644 --- a/stan/math/opencl/kernels/cumulative_sum.hpp +++ b/stan/math/opencl/kernels/cumulative_sum.hpp @@ -12,7 +12,7 @@ namespace math { namespace opencl_kernels { // \cond -static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum1_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * First kernel of the cumulative sum implementation. Each thread sums the @@ -62,7 +62,7 @@ static constexpr const char* cumulative_sum1_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum2_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Second kernel of the cumulative sum implementation. Calculates prefix sum @@ -116,7 +116,7 @@ static constexpr const char* cumulative_sum2_kernel_code = STRINGIFY( // \endcond // \cond -static constexpr const char* cumulative_sum3_kernel_code = STRINGIFY( +static constexpr const char *cumulative_sum3_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Third kernel of the cumulative sum implementation. Given sums of threads diff --git a/stan/math/opencl/kernels/divide_columns.hpp b/stan/math/opencl/kernels/divide_columns.hpp index 95f006c53d4..9bad330ebaa 100644 --- a/stan/math/opencl/kernels/divide_columns.hpp +++ b/stan/math/opencl/kernels/divide_columns.hpp @@ -10,7 +10,7 @@ namespace stan { namespace math { namespace opencl_kernels { // \cond -static constexpr const char* divide_columns_kernel_code = STRINGIFY( +static constexpr const char *divide_columns_kernel_code = STRINGIFY( // \endcond /** \ingroup opencl_kernels * Takes vector A and divides columns vector in A element-wise by the values From e9987b6e1828fe048cbdf6cb696af95929e4bf81 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 16 Feb 2024 14:54:32 +0200 Subject: [PATCH 34/35] Temporarily disable problematic test --- test/unit/math/rev/prob/lkj_corr_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/math/rev/prob/lkj_corr_test.cpp b/test/unit/math/rev/prob/lkj_corr_test.cpp index 9faa3024e8f..5bb93a8390b 100644 --- a/test/unit/math/rev/prob/lkj_corr_test.cpp +++ b/test/unit/math/rev/prob/lkj_corr_test.cpp @@ -92,9 +92,10 @@ TEST(ProbDistributionsLkjCorrCholesky, gradients) { double fx_1; Eigen::Matrix grad_ad_1; double fx_ad_1; - + /* finite_diff_gradient(test_func_1, x1, fx_1, grad_1); gradient(test_func_1, x1, fx_ad_1, grad_ad_1); test_grad_eq(grad_1, grad_ad_1); EXPECT_FLOAT_EQ(fx, fx_ad); + */ } From 44dd969a1b062cee50b9259f82032b1af8a78620 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 16 Feb 2024 16:55:09 +0200 Subject: [PATCH 35/35] Revert use of Boost's constants for LOG_PI --- stan/math/prim/fun/constants.hpp | 3 +-- test/unit/math/rev/prob/lkj_corr_test.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stan/math/prim/fun/constants.hpp b/stan/math/prim/fun/constants.hpp index ab77c472c00..fa2b64a3cde 100644 --- a/stan/math/prim/fun/constants.hpp +++ b/stan/math/prim/fun/constants.hpp @@ -83,8 +83,7 @@ static constexpr double LOG_TWO = boost::math::constants::ln_two(); * The natural logarithm of \f$ \pi \f$, * \f$ \log \pi \f$. */ -static constexpr double LOG_PI - = 2 * boost::math::constants::log_root_two_pi() - LOG_TWO; +static constexpr double LOG_PI = 1.14472988584940017414342735135; /** * The natural logarithm of 0.5, diff --git a/test/unit/math/rev/prob/lkj_corr_test.cpp b/test/unit/math/rev/prob/lkj_corr_test.cpp index 5bb93a8390b..9faa3024e8f 100644 --- a/test/unit/math/rev/prob/lkj_corr_test.cpp +++ b/test/unit/math/rev/prob/lkj_corr_test.cpp @@ -92,10 +92,9 @@ TEST(ProbDistributionsLkjCorrCholesky, gradients) { double fx_1; Eigen::Matrix grad_ad_1; double fx_ad_1; - /* + finite_diff_gradient(test_func_1, x1, fx_1, grad_1); gradient(test_func_1, x1, fx_ad_1, grad_ad_1); test_grad_eq(grad_1, grad_ad_1); EXPECT_FLOAT_EQ(fx, fx_ad); - */ }