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(ContainerT&& x) {
38 return make_holder([](auto&& x_) { return x_.all(); },
39 std::forward<ContainerT>(x));
40}
41
42// Forward-declaration for correct resolution of all(std::vector<std::tuple>)
43template <typename... Types>
44inline bool all(const std::tuple<Types...>& x);
45
57template <typename InnerT>
58inline bool all(const std::vector<InnerT>& x) {
59 return std::all_of(x.begin(), x.end(), [](auto&& i) { return all(i); });
60}
61
71template <typename... Types>
72inline bool all(const std::tuple<Types...>& x) {
73 bool all_true = true;
75 [&all_true](auto&& i) {
76 all_true = all_true && all(i);
77 return;
78 },
79 x);
80 return all_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 all(T x)
Return true if all values in the input are true.
Definition all.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 ...