Automatic Differentiation
 
Loading...
Searching...
No Matches
any.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ANY_HPP
2#define STAN_MATH_PRIM_FUN_ANY_HPP
3
6#include <algorithm>
7
8namespace stan {
9namespace math {
10
20template <typename T, require_t<std::is_convertible<T, bool>>* = nullptr>
21constexpr inline bool any(T x) {
22 return x;
23}
24
35template <typename ContainerT,
37inline bool any(ContainerT&& x) {
38 return make_holder([](auto&& x_) { return x_.any(); },
39 std::forward<ContainerT>(x));
40}
41
42// Forward-declaration for correct resolution of any(std::vector<std::tuple>)
43template <typename... Types>
44inline bool any(const std::tuple<Types...>& x);
45
57template <typename InnerT>
58inline bool any(const std::vector<InnerT>& x) {
59 return std::any_of(x.begin(), x.end(), [](auto&& i) { return any(i); });
60}
61
71template <typename... Types>
72inline bool any(const std::tuple<Types...>& x) {
73 bool any_true = false;
75 [&any_true](auto&& i) {
76 any_true = any_true || any(i);
77 return;
78 },
79 x);
80 return any_true;
81}
82
83} // namespace math
84} // namespace stan
85
86#endif
require_t< container_type_check_base< is_eigen, scalar_type_t, TypeCheck, Check... > > require_eigen_st
Require type satisfies is_eigen.
Definition is_eigen.hpp:209
constexpr bool any(T x)
Return true if any values in the input are true.
Definition any.hpp:21
constexpr void for_each(F &&f, const std::tuple<> &)
Apply a function to each element of a tuple.
Definition for_each.hpp:80
auto make_holder(F &&func, Args &&... args)
Calls given function with given arguments.
Definition holder.hpp:481
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...