Loading [MathJax]/extensions/TeX/AMSmath.js
Automatic Differentiation
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches

◆ apply_scalar_ternary() [1/2]

template<typename F , typename T1 , typename T2 , typename T3 , require_all_stan_scalar_t< T1, T2, T3 > * = nullptr>
auto stan::math::apply_scalar_ternary ( F &&  f,
T1 &&  x,
T2 &&  y,
T3 &&  z 
)
inline

Base template function for vectorization of ternary scalar functions defined by applying a functor to a combination of scalars, containers of matching sizes, or a combination of a scalar and a container.

Specialization for use with three nested containers (std::vectors).

Specialization for use with (non-nested) std::vectors.

Specialization for use with three Eigen inputs.

These containers can be a standard library vector, Eigen dense matrix expression template, or container of these. For each specialization, the same type as the largest (dimension) input is returned.

This base template function takes (and returns) scalars.

Template Parameters
T1An Arithmetic, Integral, var, or fvar<T> type.
T2An Arithmetic, Integral, var, or fvar<T> type.
T3An Arithmetic, Integral, var, or fvar<T> type.
FType of functor to apply.
Parameters
xFirst input to which operation is applied.
ySecond input to which operation is applied.
zThird scalar to which operation is applied.
ffunctor to apply to inputs.
Returns
Scalar with result of applying functor to inputs.

Eigen's ternaryExpr framework is used for more efficient indexing of both row- and column-major inputs without separate loops.

Template Parameters
T1Eigen type of first argument to which functor is applied.
T2Eigen type Type of second argument to which functor is applied.
T3Eigen type of third argument to which functor is applied.
FType of functor to apply.
Parameters
xFirst Eigen input to which operation is applied.
ySecond Eigen input to which operation is applied.
zThird Eigen input to which operation is applied.
ffunctor to apply to Eigen input.
Returns
Eigen object with result of applying functor to inputs.

Inputs are mapped to Eigen column vectors and then the result is evaluated directly into the returned std::vector (via Eigen::Map).

The returned scalar type is deduced to allow for cases where the input and return scalar types differ (e.g., functions implicitly promoting integers).

Template Parameters
T1Type of first std::vector to which functor is applied.
T2Type of second std::vector to which functor is applied.
T3Type of third std::vector to which functor is applied.
FType of functor to apply.
Parameters
xFirst std::vector input to which operation is applied.
ySecond std::vector input to which operation is applied.
zThird std::vector input to which operation is applied.
ffunctor to apply to std::vector inputs.
Returns
std::vector with result of applying functor to inputs.

The returned scalar type is deduced to allow for cases where the input and return scalar types differ (e.g., functions implicitly promoting integers).

Template Parameters
T1Type of first std::vector to which functor is applied.
T2Type of second std::vector to which functor is applied.
T3Type of second std::vector to which functor is applied.
FType of functor to apply.
Parameters
xFirst std::vector input to which operation is applied.
ySecond std::vector input to which operation is applied.
zThird std::vector input to which operation is applied.
ffunctor to apply to std::vector inputs.
Returns
std::vector with result of applying functor to inputs.

Definition at line 39 of file apply_scalar_ternary.hpp.