changeset 29615:f6151f915e3c

maint: merge stable to default.
author Rik <rik@octave.org>
date Wed, 05 May 2021 14:13:01 -0700
parents 9367cba2a6d5 (current diff) 26ba91f0eea7 (diff)
children 69e701caf5f6
files scripts/specfun/betaincinv.m
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/specfun/betaincinv.m	Thu Apr 29 11:12:40 2021 -0400
+++ b/scripts/specfun/betaincinv.m	Wed May 05 14:13:01 2021 -0700
@@ -236,6 +236,7 @@
   while (any (todo) && (it < maxit))
     it++;
     x(todo) += res(todo);
+    x(x(todo) < 0) = eps;  # Avoid negative x in betainc() call, bug #60528
     res(todo) = -F(x(todo), a(todo), b(todo), y(todo)) ...
                 ./ JF (x(todo), a(todo), b(todo));
     todo = (abs (res) >= tol * abs (x));
@@ -282,6 +283,8 @@
 %!assert (class (betaincinv (int8 (0), single (1), 1)), "single")
 %!assert (class (betaincinv (single (0.5), int8 (1), 1)), "single")
 
+%!assert <*60528> (betaincinv (1e-6, 1, 3), 3.3333344444450657e-07, eps)
+
 ## Test input validation
 %!error <Invalid call> betaincinv ()
 %!error <Invalid call> betaincinv (1)