math icon indicating copy to clipboard operation
math copied to clipboard

Distributions - Replace separate `propto` template with default argument?

Open andrjohns opened this issue 2 years ago • 0 comments

Description

We currently use a separate declaration to handle calls to the distribution functions without the propto parameter:

template <bool propto, typename T_y, typename T_loc, typename T_scale>
inline return_type_t<T_y, T_loc, T_scale> normal_lpdf(const T_y& y,
                                                      const T_loc& mu,
                                                      const T_scale& sigma) {
  ...
}

template <typename T_y, typename T_loc, typename T_scale>
inline return_type_t<T_y, T_loc, T_scale> normal_lpdf(const T_y& y,
                                                      const T_loc& mu,
                                                      const T_scale& sigma) {
  return normal_lpdf<false>(y, mu, sigma);
}

We could remove this additional definition by instead having a default value for the propto parameter:

template <bool propto = false, typename T_y, typename T_loc, typename T_scale>
inline return_type_t<T_y, T_loc, T_scale> normal_lpdf(const T_y& y,
                                                      const T_loc& mu,
                                                      const T_scale& sigma) {
  ...
}

Current Version:

v4.6.1

andrjohns avatar May 11 '23 07:05 andrjohns