|
Prev | Next | a_fun_property_xam.py | Headings |
def a_fun_property_xam() :
#
# load the Cppad Swig library
import py_cppad
#
# initialize return variable
ok = True
# ---------------------------------------------------------------------
n_ind = 1 # number of independent variables
n_dep = 2 # number of dependent variables
n_var = 1 # phantom variable at address 0
n_op = 1 # special operator at beginning
#
# dimension some vectors
x = py_cppad.vec_double(n_ind)
ay = py_cppad.vec_a_double(n_dep)
#
# independent variables
x[0] = 1.0
ax = py_cppad.independent(x)
n_var = n_var + n_ind # one for each indpendent
n_op = n_op + n_ind
#
# first dependent variable
ay[0] = ax[0] + ax[0]
n_var = n_var + 1 # one variable and operator
n_op = n_op + 1
#
# second dependent variable
ax0 = ax[0]
ay[1] = ax0.sin()
n_var = n_var + 2 # two varialbes, one operator
n_op = n_op + 1
#
# define f(x) = y
af = py_cppad.a_fun(ax, ay)
n_op = n_op + 1 # speical operator at end
#
# check af properties
ok = ok and af.size_ind() == n_ind
ok = ok and af.size_dep() == n_dep
ok = ok and af.size_var() == n_var
ok = ok and af.size_op() == n_op
#
return( ok )
#