# source:trunk/test_more/poly.cpp@1581

Last change on this file since 1581 was 1370, checked in by bradbell, 11 years ago

trunk: Fix svn_add_id.sh and use it set Id property for some missed files.

• Property svn:keywords set to `Id`
File size: 2.1 KB
Line
1/* \$Id: poly.cpp 1370 2009-05-31 05:31:50Z bradbell \$ */
2/* --------------------------------------------------------------------------
4
6the terms of the
7                    Common Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
11-------------------------------------------------------------------------- */
12
13/*
14// Old GetStarted example now used just for validation testing
15*/
16// BEGIN PROGRAM
17
20
21bool Poly(void)
22{       bool ok = true;
23
26
27        // degree of the polynomial that we will differentiate
28        size_t deg = 4;
29
30        // vector that will hold polynomial coefficients for p(z)
32        CPPAD_TEST_VECTOR<double>       a(deg + 1);  //    double  elements
33
34        // set the polynomial coefficients
35        A = 1.;
36        size_t k;
37        for(k = 1; k <= deg; k++)
38                A[k] = a[k] = 1.;
39
40        // independent variables
42        Z     = 3.;                        // value of independent variable
43        Independent(Z);                       // declare independent variable
44
45        // dependent variables
47        P     = Poly(0, A, Z);    // value of polynomial at Z
48
49        // define f : Z -> P as a function mapping independent to dependent
51
52        // compute derivative of polynomial
53        CPPAD_TEST_VECTOR<double> z(1);  // vector length f.Domain()
54        CPPAD_TEST_VECTOR<double> J(1);  // vector length f.Range * f.Domain()
55        z = 3.;                 // point at which to compute derivative
56        J    = f.Jacobian(z);      // value of derivative
57
58        // compare with derivative as computed by Poly
59        ok  &= (Poly(1, a, z) == J);
60
61        return ok;
62}
63
64// END PROGRAM
Note: See TracBrowser for help on using the repository browser.