Skip to content

Commit 46eae9c

Browse files
committed
Revert "Add tuple support to apply_scalar_unary for autodiff"
This reverts commit 23dafa2.
1 parent 78e67ac commit 46eae9c

3 files changed

Lines changed: 3 additions & 51 deletions

File tree

stan/math/prim/functor/apply_scalar_unary.hpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
#include <stan/math/prim/fun/Eigen.hpp>
55
#include <stan/math/prim/meta/is_eigen.hpp>
66
#include <stan/math/prim/meta/is_complex.hpp>
7-
#include <stan/math/prim/meta/is_tuple.hpp>
87
#include <stan/math/prim/meta/holder.hpp>
98
#include <stan/math/prim/meta/require_generics.hpp>
109
#include <stan/math/prim/meta/is_vector.hpp>
1110
#include <stan/math/prim/meta/is_vector_like.hpp>
1211
#include <stan/math/prim/meta/plain_type.hpp>
13-
#include <tuple>
1412
#include <utility>
1513
#include <vector>
1614

@@ -208,36 +206,6 @@ struct apply_scalar_unary<F, T, require_std_vector_t<T>> {
208206
}
209207
};
210208

211-
/**
212-
* Template specialization for vectorized functions applying to
213-
* tuple arguments. Each element of the tuple is processed
214-
* recursively through apply_scalar_unary, allowing heterogeneous
215-
* element types.
216-
*
217-
* @tparam F Type of function defining static apply function.
218-
* @tparam T Tuple type.
219-
*/
220-
template <typename F, typename T>
221-
struct apply_scalar_unary<F, T, require_tuple_t<T>> {
222-
template <typename TT, size_t... Is>
223-
static inline auto apply_impl(TT&& x, std::index_sequence<Is...>) {
224-
return std::make_tuple(
225-
apply_scalar_unary<
226-
F, std::tuple_element_t<Is, std::decay_t<T>>>::
227-
apply(std::get<Is>(std::forward<TT>(x)))...);
228-
}
229-
230-
template <typename TT>
231-
static inline auto apply(TT&& x) {
232-
return apply_impl(
233-
std::forward<TT>(x),
234-
std::make_index_sequence<std::tuple_size_v<std::decay_t<T>>>());
235-
}
236-
237-
using return_t = std::decay_t<decltype(
238-
apply_scalar_unary<F, T>::apply(std::declval<T>()))>;
239-
};
240-
241209
} // namespace math
242210
} // namespace stan
243211
#endif

stan/math/prim/meta/is_autodiff.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#include <stan/math/prim/meta/is_fvar.hpp>
99
#include <stan/math/prim/meta/is_vector.hpp>
1010
#include <stan/math/prim/meta/is_var.hpp>
11-
#include <stan/math/prim/meta/is_tuple.hpp>
1211
#include <stan/math/prim/meta/require_helpers.hpp>
1312
#include <stan/math/prim/meta/scalar_type.hpp>
1413
#include <stan/math/prim/meta/value_type.hpp>
1514
#include <complex>
16-
#include <tuple>
1715
#include <type_traits>
1816

1917
namespace stan {
@@ -48,17 +46,6 @@ template <typename T>
4846
struct is_autodiff<T, require_eigen_t<T>>
4947
: bool_constant<is_autodiff<typename std::decay_t<T>::Scalar>::value> {};
5048

51-
template <typename Tuple, typename = void>
52-
struct is_tuple_autodiff : std::false_type {};
53-
54-
template <typename... Ts>
55-
struct is_tuple_autodiff<std::tuple<Ts...>, void>
56-
: bool_constant<(is_autodiff<Ts>::value || ...)> {};
57-
58-
template <typename T>
59-
struct is_autodiff<T, math::require_tuple_t<T>>
60-
: is_tuple_autodiff<std::decay_t<T>> {};
61-
6249
} // namespace internal
6350

6451
/**

stan/math/prim/meta/is_container.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <stan/math/prim/meta/disjunction.hpp>
66
#include <stan/math/prim/meta/is_autodiff.hpp>
77
#include <stan/math/prim/meta/is_eigen.hpp>
8-
#include <stan/math/prim/meta/is_tuple.hpp>
98
#include <stan/math/prim/meta/is_vector.hpp>
109
#include <stan/math/prim/meta/is_var_matrix.hpp>
1110
#include <stan/math/prim/meta/base_type.hpp>
@@ -100,11 +99,9 @@ using require_not_container_st
10099
/*! and holds a base type that satisfies @ref is_autodiff_scalar */
101100
/*! @tparam T the type to check */
102101
template <typename T>
103-
using require_ad_container_t = require_t<math::disjunction<
104-
math::conjunction<math::disjunction<is_eigen<T>, is_std_vector<T>>,
105-
is_autodiff_scalar<base_type_t<T>>>,
106-
math::conjunction<math::is_tuple<T>,
107-
internal::is_autodiff<std::decay_t<T>>>>>;
102+
using require_ad_container_t
103+
= require_all_t<stan::math::disjunction<is_eigen<T>, is_std_vector<T>>,
104+
is_autodiff_scalar<base_type_t<T>>>;
108105
/*! @} */
109106

110107
} // namespace stan

0 commit comments

Comments
 (0)