AD Constructors: Example and Test
Keywords: ad constructors: example test constructor object

| Prev | Next |  |  |  |  |  | ad_ctor.cpp | Headings

AD Constructors: Example and Test
`

    # include <cppad/cppad.hpp>

    bool ad_ctor(void)
    {	bool ok = true;   // initialize test result flag
    	using CppAD::AD;  // so can use AD in place of CppAD::AD

    	// default constructor
    	AD<double> a;
    	a = 0.;
    	ok &= a == 0.;

    	// constructor from base type
    	AD<double> b(1.);
    	ok &= b == 1.;

    	// constructor from another type that converts to the base type
    	AD<double> c(2);
    	ok &= c == 2.;

    	// constructor from AD<Base>
    	AD<double> d(c);
    	ok &= d == 2.;

    	// constructor from a VecAD<Base> element
    	CppAD::VecAD<double> v(1);
    	v[0] = 3.;
    	AD<double> e( v[0] );
    	ok &= e == 3.;

    	return ok;
    }

`

Input File: example/ad_ctor.cpp