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.3 KB

Line  

1  /* $Id: rev_two.cpp 1370 20090531 05:31:50Z 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  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  # include <cppad/cppad.hpp> 

13  

14  bool RevTwo() 

15  { bool ok = true; 

16  using CppAD::AD; 

17  using CppAD::vector; 

18  using CppAD::NearEqual; 

19  

20  

21  size_t n = 2; 

22  vector< AD<double> > X(n); 

23  X[0] = 1.; 

24  X[1] = 1.; 

25  Independent(X); 

26  

27  size_t m = 1; 

28  vector< AD<double> > Y(m); 

29  Y[0] = X[0] * X[0] + X[0] * X[1] + 2. * X[1] * X[1]; 

30  CppAD::ADFun<double> F(X,Y); 

31  

32  vector<double> x(n); 

33  x[0] = .5; 

34  x[1] = 1.5; 

35  

36  size_t L = 1; 

37  vector<size_t> I(L); 

38  vector<size_t> J(L); 

39  vector<double> H(n); 

40  I[0] = 0; 

41  J[0] = 0; 

42  H = F.RevTwo(x, I, J); 

43  ok &= NearEqual(H[0], 2., 1e10, 1e10); 

44  ok &= NearEqual(H[1], 1., 1e10, 1e10); 

45  J[0] = 1; 

46  H = F.RevTwo(x, I, J); 

47  ok &= NearEqual(H[0], 1., 1e10, 1e10); 

48  ok &= NearEqual(H[1], 4., 1e10, 1e10); 

49  

50  return ok; 

51  } 

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