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

Change Licenses: CPL1.0 > EPL1.0, GPL2.0>GPL3.0


Property svn:keywords set to
Id

File size:
1.4 KB

Line  

1  /* $Id: from_base.cpp 2506 20121024 19:36:49Z bradbell $ */ 

2  /*  

3  CppAD: C++ Algorithmic Differentiation: Copyright (C) 200306 Bradley M. Bell 

4  

5  CppAD is distributed under multiple licenses. This distribution is under 

6  the terms of the 

7  Eclipse Public License Version 1.0. 

8  

9  A copy of this license is included in the COPYING file of this distribution. 

10  Please visit http://www.coinor.org/CppAD/ for information on other licenses. 

11   */ 

12  

13  

14  /* 

15  Old FromBase example now used just for valiadation testing 

16  */ 

17  # include <cppad/cppad.hpp> 

18  

19  bool 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.