Mercurial > hg > octave-nkf
comparison liboctave/Quad.cc @ 289:c23f50e61c58
[project @ 1994-01-13 06:25:58 by jwe]
author | jwe |
---|---|
date | Thu, 13 Jan 1994 06:26:54 +0000 |
parents | 74d73a4b3fc7 |
children | 3c23b8ea9099 |
comparison
equal
deleted
inserted
replaced
288:f8ae4f4dc9fd | 289:c23f50e61c58 |
---|---|
22 */ | 22 */ |
23 | 23 |
24 #ifdef HAVE_CONFIG_H | 24 #ifdef HAVE_CONFIG_H |
25 #include "config.h" | 25 #include "config.h" |
26 #endif | 26 #endif |
27 | |
28 #include <math.h> | |
29 #include <float.h> | |
27 | 30 |
28 #include "Quad.h" | 31 #include "Quad.h" |
29 #include "f77-uscore.h" | 32 #include "f77-uscore.h" |
30 #include "sun-utils.h" | 33 #include "sun-utils.h" |
31 | 34 |
51 const int*, int*, int*, double*); | 54 const int*, int*, int*, double*); |
52 } | 55 } |
53 | 56 |
54 Quad::Quad (integrand_fcn fcn) | 57 Quad::Quad (integrand_fcn fcn) |
55 { | 58 { |
56 absolute_tolerance = 1.0e-6; | |
57 relative_tolerance = 1.0e-6; | |
58 f = fcn; | 59 f = fcn; |
59 } | 60 } |
60 | 61 |
61 Quad::Quad (integrand_fcn fcn, double abs, double rel) | 62 Quad::Quad (integrand_fcn fcn, double abs, double rel) |
62 { | 63 { |
63 absolute_tolerance = abs; | |
64 relative_tolerance = rel; | |
65 f = fcn; | 64 f = fcn; |
66 } | 65 } |
67 | 66 |
68 double | 67 double |
69 Quad::integrate (void) | 68 Quad::integrate (void) |
171 int *iwork = new int [leniw]; | 170 int *iwork = new int [leniw]; |
172 double *work = new double [lenw]; | 171 double *work = new double [lenw]; |
173 user_fcn = f; | 172 user_fcn = f; |
174 int last; | 173 int last; |
175 | 174 |
175 double abs_tol = absolute_tolerance (); | |
176 double rel_tol = relative_tolerance (); | |
177 | |
176 F77_FCN (dqagp) (user_function, &lower_limit, &upper_limit, &npts, | 178 F77_FCN (dqagp) (user_function, &lower_limit, &upper_limit, &npts, |
177 points, &absolute_tolerance, &relative_tolerance, | 179 points, &abs_tol, &rel_tol, &result, &abserr, |
178 &result, &abserr, &neval, &ier, &leniw, &lenw, | 180 &neval, &ier, &leniw, &lenw, &last, iwork, work); |
179 &last, iwork, work); | |
180 | 181 |
181 delete [] iwork; | 182 delete [] iwork; |
182 delete [] work; | 183 delete [] work; |
183 | 184 |
184 return result; | 185 return result; |
237 default: | 238 default: |
238 assert (0); | 239 assert (0); |
239 break; | 240 break; |
240 } | 241 } |
241 | 242 |
242 F77_FCN (dqagi) (user_function, &bound, &inf, &absolute_tolerance, | 243 double abs_tol = absolute_tolerance (); |
243 &relative_tolerance, &result, &abserr, &neval, | 244 double rel_tol = relative_tolerance (); |
244 &ier, &leniw, &lenw, &last, iwork, work); | 245 |
246 F77_FCN (dqagi) (user_function, &bound, &inf, &abs_tol, &rel_tol, | |
247 &result, &abserr, &neval, &ier, &leniw, &lenw, | |
248 &last, iwork, work); | |
245 | 249 |
246 delete [] iwork; | 250 delete [] iwork; |
247 delete [] work; | 251 delete [] work; |
248 | 252 |
249 return result; | 253 return result; |
254 } | |
255 | |
256 Quad_options::Quad_options (void) | |
257 { | |
258 init (); | |
259 } | |
260 | |
261 Quad_options::Quad_options (const Quad_options& opt) | |
262 { | |
263 copy (opt); | |
264 } | |
265 | |
266 Quad_options& | |
267 Quad_options::operator = (const Quad_options& opt) | |
268 { | |
269 if (this != &opt) | |
270 copy (opt); | |
271 | |
272 return *this; | |
273 } | |
274 | |
275 Quad_options::~Quad_options (void) | |
276 { | |
277 } | |
278 | |
279 void | |
280 Quad_options::init (void) | |
281 { | |
282 double sqrt_eps = sqrt (DBL_EPSILON); | |
283 x_absolute_tolerance = sqrt_eps; | |
284 x_relative_tolerance = sqrt_eps; | |
285 } | |
286 | |
287 void | |
288 Quad_options::copy (const Quad_options& opt) | |
289 { | |
290 x_absolute_tolerance = opt.x_absolute_tolerance; | |
291 x_relative_tolerance = opt.x_relative_tolerance; | |
292 } | |
293 | |
294 void | |
295 Quad_options::set_default_options (void) | |
296 { | |
297 init (); | |
298 } | |
299 | |
300 void | |
301 Quad_options::set_absolute_tolerance (double val) | |
302 { | |
303 x_absolute_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); | |
304 } | |
305 | |
306 void | |
307 Quad_options::set_relative_tolerance (double val) | |
308 { | |
309 x_relative_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON); | |
310 } | |
311 | |
312 double | |
313 Quad_options::absolute_tolerance (void) | |
314 { | |
315 return x_absolute_tolerance; | |
316 } | |
317 | |
318 double | |
319 Quad_options::relative_tolerance (void) | |
320 { | |
321 return x_relative_tolerance; | |
250 } | 322 } |
251 | 323 |
252 /* | 324 /* |
253 ;;; Local Variables: *** | 325 ;;; Local Variables: *** |
254 ;;; mode: C++ *** | 326 ;;; mode: C++ *** |