Skip to content

Commit

Permalink
Merge pull request #2822 from Franzi2114/feature/issue-2682-Add-7-par…
Browse files Browse the repository at this point in the history
…ameter-DDM-PDF

Feature/issue 2682 add 7 parameter ddm pdf
  • Loading branch information
Franzi2114 committed Mar 13, 2024
2 parents c5e8f08 + 2d5d4f7 commit b21e184
Show file tree
Hide file tree
Showing 27 changed files with 3,626 additions and 477 deletions.
24 changes: 17 additions & 7 deletions stan/math/prim/functor/apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ namespace math {
namespace internal {
/*
* Invoke the functor f with arguments given in t and indexed in the index
* sequence I
* sequence I with other arguments possibly before or after
*
* @tparam F Type of functor
* @tparam Tuple Type of tuple containing arguments
* @tparam PreArgs Parameter pack of arguments before the tuple
* @tparam I Parameter pack of an index sequence going from 0 to
* std::tuple_size<T>::value - 1 inclusive
* @param f functor callable
* @param t tuple of arguments
* @param i placeholder variable for index sequence
* @param pre_args parameter pack of arguments to place before elements in
* tuple.
*/
template <class F, class Tuple, std::size_t... I>
template <class F, class Tuple, typename... PreArgs, std::size_t... I>
constexpr decltype(auto) apply_impl(F&& f, Tuple&& t,
std::index_sequence<I...> i) {
return f(std::forward<decltype(std::get<I>(t))>(std::get<I>(t))...);
std::index_sequence<I...> i,
PreArgs&&... pre_args) {
return std::forward<F>(f)(
std::forward<PreArgs>(pre_args)...,
std::forward<decltype(std::get<I>(t))>(std::get<I>(t))...);
}
} // namespace internal

Expand All @@ -36,15 +42,19 @@ constexpr decltype(auto) apply_impl(F&& f, Tuple&& t,
*
* @tparam F Type of functor
* @tparam Tuple Type of tuple containing arguments
* @tparam PreArgs Parameter pack of arguments before the tuple
* @param f functor callable
* @param t tuple of arguments
* @param pre_args parameter pack of arguments to place before elements in
* tuple.
*/
template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t) {
template <class F, class Tuple, typename... PreArgs>
constexpr decltype(auto) apply(F&& f, Tuple&& t, PreArgs&&... pre_args) {
return internal::apply_impl(
std::forward<F>(f), std::forward<Tuple>(t),
std::make_index_sequence<
std::tuple_size<std::remove_reference_t<Tuple>>{}>{});
std::tuple_size<std::remove_reference_t<Tuple>>{}>{},
std::forward<PreArgs>(pre_args)...);
}

} // namespace math
Expand Down
Loading

0 comments on commit b21e184

Please sign in to comment.