Loading [MathJax]/extensions/TeX/AMSsymbols.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
apply_scalar_unary.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUNCTOR_APPLY_SCALAR_UNARY_HPP
2#define STAN_MATH_PRIM_FUNCTOR_APPLY_SCALAR_UNARY_HPP
3
11#include <utility>
12#include <vector>
13
14namespace stan {
15namespace math {
16
40template <typename F, typename T, typename Enable = void>
42
51template <typename F, typename T>
61 static inline auto apply(const std::decay_t<T>& x) {
62 return x.unaryExpr([](auto&& x) {
63 return apply_scalar_unary<F, std::decay_t<decltype(x)>>::apply(x);
64 });
65 }
66
71 using return_t = std::decay_t<decltype(
73};
74
81template <typename F, typename T>
87 = std::decay_t<decltype(F::fun(std::declval<std::decay_t<T>>()))>;
88
98 static inline auto apply(T x) { return F::fun(x); }
99};
100
107template <typename F, typename T>
118 static inline auto apply(const std::decay_t<T>& x) { return F::fun(x); }
123 = std::decay_t<decltype(F::fun(std::declval<std::decay_t<T>>()))>;
124};
125
134template <typename F, typename T>
145 static inline auto apply(T x) { return F::fun(x); }
149 using return_t = std::decay_t<decltype(F::fun(std::declval<double>()))>;
150};
151
161template <typename F, typename T>
167 using return_t = typename std::vector<plain_type_t<
169
179 static inline auto apply(const std::decay_t<T>& x) {
180 return_t fx(x.size());
181 for (size_t i = 0; i < x.size(); ++i) {
183 }
184 return fx;
185 }
186};
187
188} // namespace math
189} // namespace stan
190#endif
require_t< is_complex< std::decay_t< T > > > require_complex_t
Require type satisfies is_complex.
require_t< is_eigen< std::decay_t< T > > > require_eigen_t
Require type satisfies is_eigen.
Definition is_eigen.hpp:110
require_t< std::is_floating_point< std::decay_t< T > > > require_floating_point_t
Require type satisfies std::is_floating_point.
require_t< std::is_integral< std::decay_t< T > > > require_integral_t
Require type satisfies std::is_integral.
require_t< is_std_vector< std::decay_t< T > > > require_std_vector_t
Require type satisfies is_std_vector.
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
Definition apply.hpp:52
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static auto apply(const std::decay_t< T > &x)
Apply the function specified by F to the specified argument.
std::decay_t< decltype(F::fun(std::declval< std::decay_t< T > >()))> return_t
The return type.
std::decay_t< decltype(apply_scalar_unary< F, std::decay_t< T > >::apply(std::declval< T >()))> return_t
Return type for applying the function elementwise to a matrix expression template of type T.
static auto apply(const std::decay_t< T > &x)
Return the result of applying the function defined by the template parameter F to the specified matri...
static auto apply(T x)
Apply the function specified by F to the specified argument.
std::decay_t< decltype(F::fun(std::declval< std::decay_t< T > >()))> return_t
The return type, double.
static auto apply(T x)
Apply the function specified by F to the specified argument.
std::decay_t< decltype(F::fun(std::declval< double >()))> return_t
The return type, double.
static auto apply(const std::decay_t< T > &x)
Apply the function specified by F elementwise to the specified argument.
typename std::vector< plain_type_t< typename apply_scalar_unary< F, value_type_t< std::decay_t< T > > >::return_t > > return_t
Return type, which is calculated recursively as a standard vector of the return type of the contained...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...