Revision 759 trunk/src/linad99/derch.cpp
derch.cpp (revision 759)  

80  80 
} 
81  81 
while (j > 0) 
82  82 
{ 
83 
//cout << "\nEntering derivative checker.\n";


84 
cout << "\n Enter index (1 ... "<< n <<") of derivative to check.";


85 
cout << " To check all derivatives, enter 0: ";


86 
cout << " To quit enter 1: "; 

83 
cout << "\nEntering derivative checker.\n"; 

84 
cout << " Enter index (1 ... "<< n <<") of derivative to check.\n";


85 
cout << " To check all derivatives, enter 0;\n";


86 
cout << " To quit enter 1: ";


87  87 
flush(cout); 
88  88 
cin >> j; 
89  89 
if (j == 1) 
...  ...  
106  106 
n1 = j; 
107  107 
n2 = j; 
108  108 
} 
109 
cout << " Enter step size (to quit derivative checker, enter 0): "; 

109 
cout << " Enter step size.\n"; 

110 
cout << " To quit derivative checker enter 1;\n"; 

111 
cout << " to check for unitialized variables enter 0): "; 

110  112 
flush(cout); 
111  113 
# if defined(__BORLANDC__) 
112  114 
char mystring[1000]; 
...  ...  
115  117 
# else 
116  118 
cin >> s; 
117  119 
# endif 
118 
// cout << "\n X Function Analytical Finite Diff; Index\n"; 

119  120 

120 
if (s <= 0) ad_exit(0);


121 
if (s < 0) ad_exit(0); 

121  122 
if (j==0) 
122  123 
{ 
123  124 
cout << endl << " If you want the derivatives approximated in order" 
...  ...  
130  131 
else 
131  132 
order_flag=0; 
132  133 
} 
133 
cout << "\n X Function Analytical Finite Diff; Index" 

134 
else 

135 
{ 

136 
cout << "\n X Function Analytical Finite Diff; Index" 

134  137 
<< endl; 
138 
} 

135  139  
136  140 
for (ii=n1; ii<=n2; ii++) 
137  141 
{ 
...  ...  
160  164 
f2 = f; 
161  165 
f = fsave; 
162  166 
x(i)=xsave; 
163 
g2=(f1f2)/(2.*s); 

164 
derchflag=0; 

165 
double perr= fabs(g2g(i))/(fabs(g(i))+1.e6); 

166  
167 
if (pofs) 

167 
if (s==0.0) 

168  168 
{ 
169 
if (perr > 1.e3) 

170 
(*pofs) << " ** "; 

169 
if (fabs(f1f2)>0.0) 

170 
{ 

171 
cout << "There appear to be uninitialized variables in " 

172 
<< "the objective function " << endl 

173 
<< " f1 = " << setprecision(15) << f1 

174 
<< " f2 = " << setprecision(15) << f2 << endl; 

175 
} 

171  176 
else 
172 
(*pofs) << " "; 

173 
(*pofs) << " " << setw(4) << i 

174 
<< " " << setw(12) << g(i) 

175 
<< " " << setw(12) << g2 

176 
<< " " << setw(12) << perr 

177 
<< endl; 

177 
{ 

178 
cout << "There do not appear to be uninitialized variables in" << endl 

179 
<< "the objective function " << endl; 

180 
} 

178  181 
} 
179 
if (ad_printf)


182 
else


180  183 
{ 
181 
(*ad_printf)(" %12.5e %12.5e %12.5e %12.5e ; %5d \n", 

182 
x(i), f, g(i), g2, i); 

183 
fflush(stdout); 

184 
g2=(f1f2)/(2.*s); 

185 
derchflag=0; 

186 
double perr= fabs(g2g(i))/(fabs(g(i))+1.e6); 

187 


188 
if (pofs) 

189 
{ 

190 
if (perr > 1.e3) 

191 
(*pofs) << " ** "; 

192 
else 
Also available in: Unified diff