Prev Next a_double_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_binary_xam() :
     #
     import numpy
     import cppad_py
     ok = True
     a2 = cppad_py.a_double(2.0)
     a3 = cppad_py.a_double(3.0)
     # ---------------------------------------------------------------------
     a5       = a2 + a3
     a6       = a2 * a3
     a1_minus = a2 - a3
     a23 = a2 / a3
     #
     ok = ok and a5 == 5.0
     ok = ok and a6 == 6.0
     ok = ok and a1_minus == -1.0
     ok = ok and a23.near_equal( cppad_py.a_double(2.0 / 3.0) )
     # ---------------------------------------------------------------------
     a5       = a2 + 3.0
     a6       = a2 * 3.0
     a1_minus = a2 - 3.0
     a23 = a2 / 3.0
     #
     ok = ok and a5 == 5.0
     ok = ok and a6 == 6.0
     ok = ok and a1_minus == -1.0
     ok = ok and a23.near_equal( cppad_py.a_double(2.0 / 3.0) )
     #
     return( ok )
#

Input File: lib/example/python/a_double_binary_xam.py