Last change
on this file since 2354 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.5 KB

Line  

1  /* $Id: value.cpp 1370 20090531 05:31:50Z bradbell $ */ 

2  /*  

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

4  

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

6  the terms of the 

7  Common 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  Old Value example now used just for valiadation testing 

15  */ 

16  // BEGIN PROGRAM 

17  

18  # include <cppad/cppad.hpp> 

19  

20  bool Value(void) 

21  { bool ok = true; 

22  

23  using namespace CppAD; 

24  

25  // independent variable vector, indices, values, and declaration 

26  CPPAD_TEST_VECTOR< AD<double> > U(2); 

27  size_t s = 0; 

28  size_t t = 1; 

29  U[s] = 3.; 

30  U[t] = 4.; 

31  Independent(U); 

32  

33  // cannot call Value after Independent (tape is recording) 

34  

35  // dependent variable vector and indices 

36  CPPAD_TEST_VECTOR< AD<double> > Z(1); 

37  size_t x = 0; 

38  

39  // dependent variable values 

40  Z[x] =  U[t]; 

41  

42  // create f: U > Z and vectors used for derivative calculations 

43  ADFun<double> f(U, Z); 

44  CPPAD_TEST_VECTOR<double> v( f.Domain() ); 

45  CPPAD_TEST_VECTOR<double> w( f.Range() ); 

46  

47  // can call Value after ADFun constructor (tape is no longer recording) 

48  

49  // check value of s 

50  double sValue = Value(U[s]); 

51  ok &= ( sValue == 3. ); 

52  

53  // check value of x 

54  double xValue = Value(Z[x]); 

55  ok &= ( xValue == 4. ); 

56  

57  return ok; 

58  } 

59  // END PROGRAM 

Note: See
TracBrowser
for help on using the repository browser.