Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ fdim() [5/10]

template<typename T_a , typename T_b , require_all_prim_or_rev_kernel_expression_t< T_a, T_b > * = nullptr, require_any_var_t< T_a, T_b > * = nullptr, require_any_not_stan_scalar_t< T_a, T_b > * = nullptr>
var_value< matrix_cl< double > > stan::math::fdim ( T_a &&  a,
T_b &&  b 
)
inline

Return the positive difference between the first variable's the value and the second's (C99, C++11).

The function values and derivatives are defined by

\[ \mbox{fdim}(x, y) = \begin{cases} x-y & \mbox{if } x > y \\[6pt] 0 & \mbox{otherwise} \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fdim}(x, y)}{\partial x} = \begin{cases} 1 & \mbox{if } x > y \\[6pt] 0 & \mbox{otherwise} \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fdim}(x, y)}{\partial y} = \begin{cases} -1 & \mbox{if } x > y \\[6pt] 0 & \mbox{otherwise} \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

Parameters
aFirst variable.
bSecond variable.
Returns
The positive difference between the first and second variable.

Definition at line 61 of file fdim.hpp.