diff --git a/test/adolctest.cc b/test/adolctest.cc index 0936d2988e8f21045decc5eed307131048fdfa57..0058eab5783b229a254a444fe633caa4cfa1cd19 100644 --- a/test/adolctest.cc +++ b/test/adolctest.cc @@ -153,60 +153,6 @@ int main() { std::cout << std::endl; } - // Get gradient -#if 0 - int n,i,j; - size_t tape_stats[STAT_SIZE]; - - cout << "SPEELPENNINGS PRODUCT (ADOL-C Documented Example)\n\n"; - cout << "number of independent variables = ? \n"; - cin >> n; - - std::vector<double> xp(n); - double yp = 0.0; - std::vector<adouble> x(n); - adouble y = 1; - - for(i=0; i<n; i++) - xp[i] = (i+1.0)/(2.0+i); // some initialization - - trace_on(1); // tag = 1, keep = 0 by default - for(i=0; i<n; i++) { - x[i] <<= xp[i]; // or x <<= xp outside the loop - y *= x[i]; - } // end for - y >>= yp; - trace_off(1); - - tapestats(1,tape_stats); // reading of tape statistics - cout<<"maxlive "<<tape_stats[NUM_MAX_LIVES]<<"\n"; - // ..... print other tape stats - - double* g = new double[n]; - gradient(1,n,xp.data(),g); // gradient evaluation - - double** H = (double**) malloc(n*sizeof(double*)); - for(i=0; i<n; i++) - H[i] = (double*)malloc((i+1)*sizeof(double)); - hessian(1,n,xp.data(),H); // H equals (n-1)g since g is - - - - - double errg = 0; // homogeneous of degree n-1. - double errh = 0; - for(i=0; i<n; i++) - errg += fabs(g[i]-yp/xp[i]); // vanishes analytically. - for(i=0; i<n; i++) { - for(j=0; j<n; j++) { - if (i>j) // lower half of hessian - errh += fabs(H[i][j]-g[i]/xp[j]); - } // end for - } // end for - cout << yp-1/(1.0+n) << " error in function \n"; - cout << errg <<" error in gradient \n"; - cout << errh <<" consistency check \n"; -#endif return 0; } // end main