Changeset 3583 for trunk/test_more
 Timestamp:
 Jan 9, 2015 6:34:24 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test_more/forward_dir.cpp
r3305 r3583 1 1 /* $Id$ */ 2 2 /*  3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 20031 4Bradley M. Bell3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 200315 Bradley M. Bell 4 4 5 5 CppAD is distributed under multiple licenses. This distribution is under … … 936 936 ok &= NearEqual(y2[1] , y_2_1, eps, eps); 937 937 // 938 return ok; 939 } 940 //  941 // ParOp 942 bool par_op(void) 943 { bool ok = true; 944 size_t j; 945 946 // domain space vector 947 size_t n = 1; 948 CPPAD_TESTVECTOR(AD<double>) ax(n); 949 ax[0] = 0.5; 950 951 // declare independent variables and starting recording 952 CppAD::Independent(ax); 953 954 // range space vector 955 size_t m = 1; 956 CPPAD_TESTVECTOR(AD<double>) ay(m); 957 ay[0] = 0.0 * ax[0]; 958 959 // create f: x > y and stop tape recording 960 CppAD::ADFun<double> f(ax, ay); 961 962 // first order Taylor coefficients 963 size_t r = 2, ell; 964 CPPAD_TESTVECTOR(double) x1(r*n), y1; 965 for(ell = 0; ell < r; ell++) 966 { for(j = 0; j < n; j++) 967 x1[ r * j + ell ] = double(j + ell + 1); 968 } 969 y1 = f.Forward(1, r, x1); 970 ok &= y1.size() == r*m; 971 972 // secondorder Taylor coefficients 973 CPPAD_TESTVECTOR(double) x2(r*n), y2; 974 for(ell = 0; ell < r; ell++) 975 { for(j = 0; j < n; j++) 976 x2[ r * j + ell ] = double(j + ell + 2); 977 } 978 y2 = f.Forward(2, r, x2); 979 ok &= y2.size() == r*m; 980 // 981 // Y_0 (t) = 0.0 982 for(ell = 0; ell < r; ell++) 983 { ok &= y1[ell] == 0.0; 984 ok &= y2[ell] == 0.0; 985 } 938 986 return ok; 939 987 } … … 1556 1604 ok &= log_op(); 1557 1605 ok &= mulpv_op(); 1606 ok &= par_op(); 1558 1607 ok &= powpv_op(); 1559 1608 ok &= powvp_op();
Note: See TracChangeset
for help on using the changeset viewer.