Prev Next Index-> contents reference index search external Up-> pycppad ad_function independent independent.py pycppad-> install get_started.py example ad_variable ad_function two_levels.py runge_kutta_4 whats_new license ad_function-> independent adfun abort_recording forward reverse jacobian hessian optimize independent-> independent.py independent.py Headings

$\newcommand{\B}[1]{{\bf #1}} \newcommand{\R}[1]{{\rm #1}}$
independent: Example and Test
 from pycppad import * # Example using a_float --------------------------------------------------- def pycppad_test_independent() : x = numpy.array( [ 0., 0., 0. ] ) a_x = independent(x) # level 1 independent variables and start recording assert type(a_x) == numpy.ndarray for j in range(len(x)) : assert isinstance(x[j], float) assert isinstance(a_x[j], a_float) assert a_x[j] == x[j] f = adfun(a_x, a_x) # stop level 1 recording # Example using a2float --------------------------------------------------- def pycppad_test_independent_a2() : x = numpy.array( [ 0., 0., 0. ] ) a_x = independent(x) # level 1 independent variables and start recording a2x = independent(a_x) # level 2 independent variables and start recording assert type(a_x) == numpy.ndarray assert type(a2x) == numpy.ndarray for j in range(len(x)) : assert isinstance(x[j], float) assert isinstance(a_x[j], a_float) assert isinstance(a2x[j], a2float) assert a_x[j] == x[j] assert a2x[j] == x[j] a_f = adfun(a2x, a2x) # stop level 2 recording f = adfun(a_x, a_x) # stop level 1 recording 
Input File: example/independent.py