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

◆ floor() [7/8]

var stan::math::floor ( const var a)
inline

Return the floor of the specified variable (cmath).

The derivative of the floor function is defined and zero everywhere but at integers, so we set these derivatives to zero for convenience,

\(\frac{d}{dx} {\lfloor x \rfloor} = 0\).

The floor function rounds down. For double values, this is the largest integral value that is not greater than the specified value. Although this function is not differentiable because it is discontinuous at integral values, its gradient is returned as zero everywhere.

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

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

Parameters
aInput variable.
Returns
Floor of the variable.

Definition at line 48 of file floor.hpp.