comparison liboctave/Quad.cc @ 1528:dc527156c38c

[project @ 1995-10-05 01:44:18 by jwe]
author jwe
date Thu, 05 Oct 1995 01:45:30 +0000
parents 6422f071ba11
children a272c4056bab
comparison
equal deleted inserted replaced
1527:13d27938e778 1528:dc527156c38c
58 const double&, const double&, double&, 58 const double&, const double&, double&,
59 double&, int&, int&, const int&, 59 double&, int&, int&, const int&,
60 const int&, int&, int*, double*); 60 const int&, int&, int*, double*);
61 } 61 }
62 62
63 Quad::Quad (integrand_fcn fcn)
64 {
65 f = fcn;
66 }
67
68 Quad::Quad (integrand_fcn fcn, double abs, double rel)
69 : Quad_options (abs, rel)
70 {
71 f = fcn;
72 }
73
74 double
75 Quad::integrate (void)
76 {
77 int ier, neval;
78 double abserr;
79 return integrate (ier, neval, abserr);
80 }
81
82 double
83 Quad::integrate (int& ier)
84 {
85 int neval;
86 double abserr;
87 return integrate (ier, neval, abserr);
88 }
89
90 double
91 Quad::integrate (int& ier, int& neval)
92 {
93 double abserr;
94 return integrate (ier, neval, abserr);
95 }
96
97 static double 63 static double
98 user_function (double *x, int& ierr) 64 user_function (double *x, int& ierr)
99 { 65 {
100 #if defined (sun) && defined (__GNUC__) 66 #if defined (sun) && defined (__GNUC__)
101 double xx = access_double (x); 67 double xx = access_double (x);
109 75
110 if (quad_integration_error) 76 if (quad_integration_error)
111 ierr = -1; 77 ierr = -1;
112 78
113 return retval; 79 return retval;
114 }
115
116 DefQuad::DefQuad (integrand_fcn fcn) : Quad (fcn)
117 {
118 lower_limit = 0.0;
119 upper_limit = 1.0;
120 }
121
122 DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul)
123 : Quad (fcn)
124 {
125 lower_limit = ll;
126 upper_limit = ul;
127 }
128
129 DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul,
130 double abs, double rel) : Quad (fcn, abs, rel)
131 {
132 lower_limit = ll;
133 upper_limit = ul;
134 }
135
136 DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul,
137 const Vector& sing) : Quad (fcn)
138 {
139 lower_limit = ll;
140 upper_limit = ul;
141 singularities = sing;
142 }
143
144 DefQuad::DefQuad (integrand_fcn fcn, const Vector& sing,
145 double abs, double rel) : Quad (fcn, abs, rel)
146 {
147 lower_limit = 0.0;
148 upper_limit = 1.0;
149 singularities = sing;
150 }
151
152 DefQuad::DefQuad (integrand_fcn fcn, const Vector& sing)
153 : Quad (fcn)
154 {
155 lower_limit = 0.0;
156 upper_limit = 1.0;
157 singularities = sing;
158 }
159
160 DefQuad::DefQuad (integrand_fcn fcn, double ll, double ul,
161 const Vector& sing, double abs, double rel)
162 : Quad (fcn, abs, rel)
163 {
164 lower_limit = ll;
165 upper_limit = ul;
166 singularities = sing;
167 } 80 }
168 81
169 double 82 double
170 DefQuad::integrate (int& ier, int& neval, double& abserr) 83 DefQuad::integrate (int& ier, int& neval, double& abserr)
171 { 84 {
189 102
190 delete [] iwork; 103 delete [] iwork;
191 delete [] work; 104 delete [] work;
192 105
193 return result; 106 return result;
194 }
195
196 IndefQuad::IndefQuad (integrand_fcn fcn) : Quad (fcn)
197 {
198 bound = 0.0;
199 type = bound_to_inf;
200 }
201
202 IndefQuad::IndefQuad (integrand_fcn fcn, double b, IntegralType t)
203 : Quad (fcn)
204 {
205 bound = b;
206 type = t;
207 }
208
209 IndefQuad::IndefQuad (integrand_fcn fcn, double b, IntegralType t,
210 double abs, double rel) : Quad (fcn, abs, rel)
211 {
212 bound = b;
213 type = t;
214 }
215
216 IndefQuad::IndefQuad (integrand_fcn fcn, double abs, double rel)
217 : Quad (fcn, abs, rel)
218 {
219 bound = 0.0;
220 type = bound_to_inf;
221 } 107 }
222 108
223 double 109 double
224 IndefQuad::integrate (int& ier, int& neval, double& abserr) 110 IndefQuad::integrate (int& ier, int& neval, double& abserr)
225 { 111 {
262 delete [] work; 148 delete [] work;
263 149
264 return result; 150 return result;
265 } 151 }
266 152
267 Quad_options::Quad_options (void)
268 {
269 init ();
270 }
271
272 Quad_options::Quad_options (double abs, double rel)
273 {
274 x_absolute_tolerance = abs;
275 x_relative_tolerance = rel;
276 }
277
278 Quad_options::Quad_options (const Quad_options& opt)
279 {
280 copy (opt);
281 }
282
283 Quad_options&
284 Quad_options::operator = (const Quad_options& opt)
285 {
286 if (this != &opt)
287 copy (opt);
288
289 return *this;
290 }
291
292 Quad_options::~Quad_options (void)
293 {
294 }
295
296 void
297 Quad_options::init (void)
298 {
299 double sqrt_eps = sqrt (DBL_EPSILON);
300 x_absolute_tolerance = sqrt_eps;
301 x_relative_tolerance = sqrt_eps;
302 }
303
304 void
305 Quad_options::copy (const Quad_options& opt)
306 {
307 x_absolute_tolerance = opt.x_absolute_tolerance;
308 x_relative_tolerance = opt.x_relative_tolerance;
309 }
310
311 void
312 Quad_options::set_default_options (void)
313 {
314 init ();
315 }
316
317 void
318 Quad_options::set_absolute_tolerance (double val)
319 {
320 x_absolute_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON);
321 }
322
323 void
324 Quad_options::set_relative_tolerance (double val)
325 {
326 x_relative_tolerance = (val > 0.0) ? val : sqrt (DBL_EPSILON);
327 }
328
329 double
330 Quad_options::absolute_tolerance (void)
331 {
332 return x_absolute_tolerance;
333 }
334
335 double
336 Quad_options::relative_tolerance (void)
337 {
338 return x_relative_tolerance;
339 }
340
341 /* 153 /*
342 ;;; Local Variables: *** 154 ;;; Local Variables: ***
343 ;;; mode: C++ *** 155 ;;; mode: C++ ***
344 ;;; page-delimiter: "^/\\*" *** 156 ;;; page-delimiter: "^/\\*" ***
345 ;;; End: *** 157 ;;; End: ***