# source:trunk/test_more/pow_int.cpp@2506

Last change on this file since 2506 was 2506, checked in by bradbell, 8 years ago

Change Licenses: CPL-1.0 -> EPL-1.0, GPL-2.0->GPL-3.0

• Property svn:keywords set to `Id`
File size: 1.7 KB
Line
1/* \$Id: pow_int.cpp 2506 2012-10-24 19:36:49Z bradbell \$ */
2/* --------------------------------------------------------------------------
4
6the terms of the
7                    Eclipse Public License Version 1.0.
8
9A copy of this license is included in the COPYING file of this distribution.
11-------------------------------------------------------------------------- */
12
13/*
14Old example now just used for validation testing.
15*/
16
18
19bool PowInt(void)
20{       bool ok = true;
21
26
27
28        // independent variable vector, indices, values, and declaration
30        U[0]     = 2.;
31        Independent(U);
32
33        // dependent variable vector and indices
35
36        // dependent variable values
37        Z[0]         = pow(U[0], 5);     // x = u^5
38        Z[1]         = pow(U[0], -5);    // y = u^{-5}
39
40        // create f: U -> Z and vectors used for derivative calculations
44
45        /*
46        x_u = 5 * u^4
47        y_u = - 5 * u^{-6}
48        */
49
50        // check function values values
51        double u = Value(U[0]);
52        ok &= NearEqual(Z[0] , exp( log(u) * 5.),              1e-10 , 1e-10);
53        ok &= NearEqual(Z[1] , exp( - log(u) * 5.),            1e-10 , 1e-10);
54
55        // forward computation of partials
56        v[0] = 1.;
57        w = f.Forward(1, v);
58        ok &= NearEqual(w[0] , 5. * exp( log(u) * 4.),         1e-10 , 1e-10);
59        ok &= NearEqual(w[1] , - 5. * exp( - log(u) * 6.),     1e-10 , 1e-10);
60
61        return ok;
62}
Note: See TracBrowser for help on using the repository browser.