\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\)
a_double_binary#
View page sourcea_double Binary Operators with an AD Result#
Syntax#
Python#
C++#
op#
The binary operator op is one of the following:
addition + ,
subtraction - ,
multiplication * ,
division / , or
exponentiation ** .
Note that exponentiation in c++ is special and always has the function syntax;
i.e.,
fun#
This function is one of the following:
radd (right addition) ,
rsub (right subtraction) ,
rmul (right multiplication) ,
rdiv (right division).
ax#
This object has c++ prototype
const a_double& axay#
This object has c++ prototype
const a_double& ayy#
This object has c++ prototype
const double& yx#
This object has c++ prototype
const double& xaz#
The result has c++ prototype
a_double azpow_int#
Exponentiation by an integer is an even more special case.
Derivatives of the pow function will return nan
when the argument value is zero; e.g. the derivative of
\(\R{pow} (x, 2)\) at \(x = 0\)
( derivatives of the pow function work fine when \(x \ne 0\) ).
This is because the derivative of the log function at zero
results in a division by zero.
This nan can be avoided by using multiplication, instead of logs,
to compute powers when the exponent is an integer.
i#
The argument to the pow_int function has c++ prototype
const int& iExample#
Python: a_double Binary Operators With AD Result: Example and Test
C++: a_double Binary Operators With AD Result: Example and Test