Mercurial > hg > octave-lyh
diff scripts/general/quadv.m @ 7795:df9519e9990c
Handle single precision eps values
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 12 May 2008 22:57:11 +0200 |
parents | 680631e787aa |
children | cadc73247d65 |
line wrap: on
line diff
--- a/scripts/general/quadv.m +++ b/scripts/general/quadv.m @@ -52,6 +52,11 @@ if (nargin < 5) trace = []; endif + if (isa (a, "single") || isa (b, "single")) + myeps = eps ("single"); + else + myeps = eps; + endif if (isempty (tol)) tol = 1e-6; endif @@ -69,10 +74,10 @@ ## If have edge singularities, move edge point by eps*(b-a) as ## discussed in Shampine paper used to implement quadgk if (isinf (fa)) - fa = feval (f, a + eps * (b-a), varargin{:}); + fa = feval (f, a + myeps * (b-a), varargin{:}); endif if (isinf (fb)) - fb = feval (f, b - eps * (b-a), varargin{:}); + fb = feval (f, b - myeps * (b-a), varargin{:}); endif h = (b - a) / 2; @@ -85,7 +90,7 @@ warning("Maximum iteration count reached"); elseif (isnan(Q) || isinf (Q)) warning ("Infinite or NaN function evaluations were returned"); - elseif (hmin < (b - a) * eps) + elseif (hmin < (b - a) * myeps) warning ("Minimum step size reached. Possibly singular integral"); endif endfunction