source: trunk/ADOL-C/examples/tapeless_scalar.cpp @ 408

Last change on this file since 408 was 171, checked in by kulshres, 9 years ago

Squashed merge branch 'master' of 'gitclone' into svn

  • 'master' of 'gitclone': (84 commits) adjust example makefiles and include paths get rid of the symlink in the src subdirectory

details of the commits:
commit c9e4bc332d2363f737fc2e8a8fcfc2e43ddb9d15
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 4 15:43:47 2010 +0200

adjust example makefiles and include paths

include paths in example sources were wrong for some time now
simplify makefile rules too, there is really no need for checking SPARSE
adjust include paths in makefiles.

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

commit e6e1963e41e097fd5b4a79cd1611c12f6868dc94
Author: Kshitij Kulshreshtha <kshitij@…>
Date: Mon Oct 4 15:41:25 2010 +0200

get rid of the symlink in the src subdirectory

windows doesn't like symlinks and make infinite depth directories
we now create a symlink for build in the directory parallel to src
adjust all makefiles.am accordingly for build

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File:     tapeless_scalar.cpp
4 Revision: $Id: tapeless_scalar.cpp 171 2010-10-04 13:57:19Z kulshres $
5 Contents: computation of coordinate transform,
6           scalar tapeless forward mode
7           described in the manual
8
9 Copyright (c) Andrea Walther, Andreas Kowarz
10 
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduction, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14 
15---------------------------------------------------------------------------*/
16
17
18/****************************************************************************/
19/*                                                                 INCLUDES */
20
21#include <iostream>
22using namespace std;
23
24#define ADOLC_TAPELESS
25#include <adolc/adouble.h>
26typedef adtl::adouble adouble;
27
28
29int main(int argc, char *argv[]) {
30    adouble x[3], y[3];
31
32    for (int i=0; i<3;++i)          // Initialize x_i
33        x[i] = i + 1.0;
34
35    cout << endl << "Compute transform from Cartesian to spherical polar coordinates" << endl << endl;
36
37    // derivative of y with respect to x0
38    x[0].setADValue(1);
39
40    y[0] = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
41    y[1] = atan(sqrt(x[0]*x[0]+x[1]*x[1])/x[2]);
42    y[2] = atan(x[1]/x[0]);
43
44    cout << "cartesian coordinates: " << endl;
45    cout << "x[0] = " << x[0].getValue() << "  x[1] = " << x[1].getValue()
46    << "  x[2] = " << x[2].getValue() << endl << endl;
47    cout << "cpherical polar coordinates: " << endl;
48    cout << "y[0] = " << y[0].getValue() << "  y[1] = " << y[1].getValue()
49    << "  y[2] = " << y[2].getValue() << endl <<endl;
50
51    // "use" the derivative
52    cout << "derivative:" << endl;
53    cout << "dy[0]/dx[0] = " << y[0].getADValue() << "  dy[1]/dx[0] = " << y[1].getADValue()
54    << "  dy[2]/dx[0] = " << y[2].getADValue() << endl;
55
56    return 0;
57}
58
Note: See TracBrowser for help on using the repository browser.