39 const dvector& _gg,
int n,
const int & _ireturn)
42 double& f=(
double&) _f;
45 static int i, n1 ,n2,ii;
47 static int order_flag;
48 static double s, f1, f2,
g2, xsave;
55 if (ireturn == 4 )
goto label4;
56 else if (ireturn == 5)
goto label5;
60 double maxg=
fabs(
g(maxind));
65 ofstream ofs(
"derivatives");
76 cout <<
"maxind = " << maxind <<
" maxg = " << maxg <<
endl;
81 cout <<
"\nEntering derivative checker.\n";
82 cout <<
" Enter index (1 ... "<< n <<
") of derivative to check.\n";
83 cout <<
" To check all derivatives, enter 0;\n";
84 cout <<
" To quit enter -1: ";
94 cout <<
"\n Checking all derivatives. Press X to terminate checking.\n";
96 pofs=
new ofstream(
"ders.dat");
97 (*pofs) <<
" index analytical finite % error " <<
endl;
98 (*pofs) <<
" difference " <<
endl;
102 else if (j >= 1 && j <= n)
109 cout <<
"Error: Invalid derivative index \"" << j
110 <<
"\" entered which is not in range (1 ... "<< n <<
").\n";
113 cout <<
"\n Enter step size.\n";
114 cout <<
" To quit derivative checker enter -1;\n";
115 cout <<
" to check for uninitialized variables enter 0): ";
117 #if defined(__BORLANDC__)
128 cout <<
"\n If you want the derivatives approximated in order\n"
129 <<
" of decreasing magnitude enter 1;\n"
130 <<
" else enter 0: ";
142 "\n X Function Analytical Finite Diff ; Index"
146 for (ii=n1; ii<=n2; ii++)
155 int idx = (int)index(_ii);
157 double _idx = index(_ii);
158 assert(_idx <= (
double)INT_MAX);
196 cout <<
"There appear to be uninitialized variables in "
197 <<
"the objective function " <<
endl
198 <<
" f1 = " << setprecision(15) << f1
199 <<
" f2 = " << setprecision(15) << f2 <<
endl;
203 cout <<
"There do not appear to be uninitialized variables in" <<
endl
204 <<
"the objective function " <<
endl;
211 double perr=
fabs(g2-
g(i))/(
fabs(
g(i))+1.e-6);
219 (*pofs) <<
" " << setw(4) << i
220 <<
" " << setw(12) <<
g(i)
221 <<
" " << setw(12) << g2
222 <<
" " << setw(12) << perr
225 ad_printf(
" %12.5e %12.5e %12.5e %12.5e ; %5d \n",
226 x(i), f,
g(i), g2, i);
229 #if defined(_MSC_VER)
232 int c = toupper(
getch());
235 cout <<
" Exiting derivative checker by user interrupt.\n";
void derch(const double &_f, const dvector &_x, const dvector &_gg, int n, const int &_ireturn)
Description not yet available.
dmatrix trans(const dmatrix &m1)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Vector of double precision numbers.
int indexmin() const
Get minimum valid index.
df1_two_variable fabs(const df1_two_variable &x)
dmatrix sort(const dmatrix &m, int column, int NSTACK)
Description not yet available.
prnstream & endl(prnstream &)
Description not yet available.
int indexmax() const
Get maximum valid index.
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Description not yet available.
double fill_seqadd(double, double)
Description not yet available.
dvector column(const dmatrix &matrix, int j)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int ad_printf(FILE *stream, const char *format, Args...args)