Prev Next a_double_ad_binary_xam.py Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Python: a_double Binary Operators With AD Result: Example and Test
def a_double_ad_binary_xam() :
     #
     # load the Cppad Swig library
     import py_cppad
     #
     # initialize return variable
     ok = True
     # ---------------------------------------------------------------------
     two = py_cppad.a_double(2.0)
     three = py_cppad.a_double(3.0)
     #
     five = two + three
     six = two * three
     neg_one = two - three
     two_thirds = two / three
     #
     ok = ok and five.value() == 5.0
     ok = ok and six.value() == 6.0
     ok = ok and neg_one.value() == -1.0
     ok = ok and 0.5 < two_thirds.value()
     ok = ok and two_thirds.value() < 1.0
     ok = ok and five < six
     #
     return( ok )
#

Input File: build/lib/example/python/a_double_ad_binary_xam.py