Prev Next ad.py Headings

@(@\newcommand{\B}[1]{{\bf #1}} \newcommand{\R}[1]{{\rm #1}}@)@
ad: Example and Test
 
from pycppad import *
import numpy
def pycppad_test_ad() :
  x   = 1
  a_x = ad(x)
  a2x = ad(a_x)
  #
  assert type(a_x) == a_float and a_x == x
  assert type(a2x) == a2float and a2x == x
  #
  x   = numpy.array( [ 1 , 2 , 3 ] )
  a_x = ad(x)
  a2x = ad(a_x)
  #
  for i in range( len(a_x) ) :  
    assert type(a_x[i]) == a_float and a_x[i] == x[i]
  for i in range( len(a2x) ) :  
    assert type(a2x[i]) == a2float and a2x[i] == x[i]

Input File: example/ad.py