Mercurial > octave
changeset 24156:ce435b70fd94
quadl.m: Return single output when inputs are single (bug #52243).
* quadl.m: Declare intermediate variable q to be of same class as input x.
Add BIST tests for behavior.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 17 Oct 2017 13:45:47 -0700 |
parents | 47dd094a6239 |
children | 5fc5c1a49aa1 |
files | scripts/general/quadl.m |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/quadl.m Tue Oct 17 14:13:19 2017 -0400 +++ b/scripts/general/quadl.m Tue Oct 17 13:45:47 2017 -0700 @@ -149,7 +149,7 @@ if ((abs (i1-i2) < tol || mll <= a || b <= mrr) && nfun > 2) q = i1; else - q = zeros (6, 1); + q = zeros (6, 1, class (x)); [q(1), nfun, hmin] = adaptlobstp (f, a , mll, fa , fmll, q0/6, nfun, hmin, tol, trace, varargin{:}); [q(2), nfun, hmin] = adaptlobstp (f, mll, ml , fmll, fml , q0/6, nfun, hmin, @@ -187,6 +187,11 @@ %! assert (q, (60 + sin(4) - sin(64))/12, 0.1); %! assert (nfun2 > nfun1); +%!test # test single input/output +%! assert (class (quadl (@sin, 0, 1)), "double"); +%! assert (class (quadl (@sin, single (0), 1)), "single"); +%! assert (class (quadl (@sin, 0, single (1))), "single"); + ## Test input validation %!error quadl () %!error quadl (@sin)