source: trunk/ADOL-C/examples/additional_examples/tapesave/useTape.cpp @ 88

Last change on this file since 88 was 88, checked in by utke, 10 years ago

compiler message: ISO C++ does not support the `%le' printf format

  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     createTape.cpp
4 Revision: $Id: useTape.cpp 88 2010-02-17 18:33:52Z utke $
5 Contents:
6
7   How to use a tape with ADOL-C
8   =============================
9   
10   Application of ADOL-C to the example function of Tony Wong
11   to use a tape, which was previously saved on HD
12 
13 Copyright (c) Andrea Walther, Andreas Griewank, Andreas Kowarz,
14               Hristo Mitev, Sebastian Schlenkrich, Jean Utke, Olaf Vogel
15 
16 This file is part of ADOL-C. This software is provided as open source.
17 Any use, reproduction, or distribution of the software constitutes
18 recipient's acceptance of the terms of the accompanying license file.
19 
20---------------------------------------------------------------------------*/
21
22/****************************************************************************/
23/*                                                                 INCLUDES */
24/* use of ALL ADOL-C interfaces */
25#include <adolc.h>
26
27#include <cstdio>
28
29
30/****************************************************************************/
31/*                                                USING THE EVALUATION TAPE */
32
33
34int main() {
35    double  xyz[3],  f, gradf[3];    /* variables */
36
37    xyz[0] = 1.0;
38    xyz[1] = 1.0;      /* initialize any values */
39    xyz[2] = 1.0;
40
41    /* USING THE TAPE FOR DERIVATIVE COMPUTATION */
42
43    function(1,                      /* the tape identifier 1 (tag) */
44             1,                      /* number of dependent variables
45                                                                             = dimension of f */
46             3,                      /* number of independent variables
47                                                                             = dimension of xyz */
48             xyz,                    /* the point where the function has
49                                                                             to be differentiated */
50             &f);                    /* contains the function value (after
51                                                  calling 'function(..)') */
52
53    gradient(1,                      /* the tape identifier 1 (tag) */
54             3,                      /* number of independent variables
55                                                                             = dimension of xyz */
56             xyz,                    /* the point where the function has
57                                                                             to be differentiated */
58             gradf);                 /* contains the gradient (after
59                                                  calling 'gradient(..)') */
60
61    /* print the results */
62    fprintf(stdout,"f  = %E\n",f);
63    fprintf(stdout,"df = (%E, %E, %E)\n",gradf[0],gradf[1],gradf[2]);
64
65    return 0;
66}
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Note: See TracBrowser for help on using the repository browser.