source: trunk/test_more/from_base.cpp @ 1524

Last change on this file since 1524 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: 1.4 KB
Line 
1/* $Id: from_base.cpp 1370 2009-05-31 05:31:50Z bradbell $ */
2/* --------------------------------------------------------------------------
3CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-06 Bradley M. Bell
4
5CppAD is distributed under multiple licenses. This distribution is under
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.
10Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11-------------------------------------------------------------------------- */
12
13
14/*
15Old FromBase example now used just for valiadation testing
16*/
17# include <cppad/cppad.hpp>
18
19bool FromBase(void)
20{       bool ok = true;
21
22        using namespace CppAD;
23
24        // construct directly form Base where Base = double
25        AD<double> x(1.); 
26        AD<double> y = 2.;
27
28        // construct from a type that can be converted to Base
29        // where Base = AD<double>
30        AD< AD<double> > X(1.); 
31        AD< AD<double> > Y(2);
32
33        // check that resulting objects are parameters
34        ok &= Parameter(x);
35        ok &= Parameter(y);
36
37        ok &= Parameter(X);
38        ok &= Parameter(Y);
39
40        // check values of objects
41        ok &= (x == 1.);
42        ok &= (X == x);
43
44        ok &= (y == 2.);
45        ok &= (Y == y);
46
47        // user constructor through the static_cast template function
48        x   = static_cast < AD<double> >( 4 );
49        X   = static_cast < AD< AD<double> > >( 4 );
50
51        ok &= (x == 4.);
52        ok &= (X == x);
53
54        return ok;
55}
56
57// END PROGRAM
Note: See TracBrowser for help on using the repository browser.