Prev Next a_double_assign_xam.py Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Python: a_double Assignment Operators: Example and Test
def a_double_assign_xam() :
     #
     # load the Cppad Swig library
     import py_cppad
     #
     # initialize return variable
     ok = True
     # ---------------------------------------------------------------------
     x = py_cppad.a_double(2.0)
     #
     x = py_cppad.a_double(3.0);
     ok = ok and x.value() == 3.0
     #
     x += py_cppad.a_double(2.0);
     ok = ok and x.value() == 5.0
     #
     x -= py_cppad.a_double(1.0);
     ok = ok and x.value() == 4.0
     #
     x *= py_cppad.a_double(3.0);
     ok = ok and x.value() == 12.0
     #
     x /= py_cppad.a_double(4.0);
     ok = ok and x.value() == 3.0
     #
     return( ok )
#

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