Automatic Differentiation
 
Loading...
Searching...
No Matches
all.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ALL_HPP
2#define STAN_MATH_PRIM_FUN_ALL_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 all(T x) {
22 return x;
23}
24
35template <typename ContainerT,
37inline bool all(const ContainerT& x) {
38 return x.all();
39}
40
41// Forward-declaration for correct resolution of all(std::vector<std::tuple>)
42template <typename... Types>
43inline bool all(const std::tuple<Types...>& x);
44
56template <typename InnerT>
57inline bool all(const std::vector<InnerT>& x) {
58 return std::all_of(x.begin(), x.end(), [](const auto& i) { return all(i); });
59}
60
70template <typename... Types>
71inline bool all(const std::tuple<Types...>& x) {
72 bool all_true = true;
74 [&all_true](const auto& i) {
75 all_true = all_true && all(i);
76 return;
77 },
78 x);
79 return all_true;
80}
81
82} // namespace math
83} // namespace stan
84
85#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:151
constexpr auto for_each(F &&f, T &&t)
Apply a function to each element of a tuple.
Definition for_each.hpp:66
constexpr bool all(T x)
Return true if all values in the input are true.
Definition all.hpp:21
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...