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

◆ fmod() [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::fmod ( T_a &&  a,
T_b &&  b 
)
inline

Return the floating point remainder after dividing the first variable by the second (cmath).

The partial derivatives with respect to the variables are defined everywhere but where \(x = y\), but we set these to match other values, with

\(\frac{\partial}{\partial x} \mbox{fmod}(x, y) = 1\), and

\(\frac{\partial}{\partial y} \mbox{fmod}(x, y) = -\lfloor \frac{x}{y} \rfloor\).

\[ \mbox{fmod}(x, y) = \begin{cases} x - \lfloor \frac{x}{y}\rfloor y & \mbox{if } -\infty\leq x, y \leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fmod}(x, y)}{\partial x} = \begin{cases} 1 & \mbox{if } -\infty\leq x, y\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{fmod}(x, y)}{\partial y} = \begin{cases} -\lfloor \frac{x}{y}\rfloor & \mbox{if } -\infty\leq x, y\leq \infty \\[6pt] \textrm{NaN} & \mbox{if } x = \textrm{NaN or } y = \textrm{NaN} \end{cases} \]

Parameters
aFirst variable.
bSecond variable.
Returns
Floating pointer remainder of dividing the first variable by the second.

Definition at line 66 of file fmod.hpp.