# HG changeset patch # User John W. Eaton # Date 1203841969 18000 # Node ID 8a6965a011764c14a5d33e15d498453c3613fe3b # Parent 6f10bbb2854afddb9f2660d8146fde76b83f184f log2: ensure F strictly less than 1 diff --git a/doc/interpreter/contributors.in b/doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -59,10 +59,11 @@ Peter Gustafson Kai Habel William P. Y. Hadisoeseno +Jaroslav Hajek Benjamin Hall Kim Hansen Soren Hauberg -Jaroslav Hajek +Dave Hawthorne Daniel Heiserer Yozo Hida Roman Hodek diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2008-02-24 John W. Eaton + + * specfun/log2.m: Ensure returned value of F strictly less than 1. + From Dave Hawthorne . + 2008-02-22 Ben Abbott * specfun/legendre.m: Doc fix. diff --git a/scripts/specfun/log2.m b/scripts/specfun/log2.m --- a/scripts/specfun/log2.m +++ b/scripts/specfun/log2.m @@ -53,6 +53,12 @@ f = abs (x) + (x == 0); e = (floor (log (f) / log (2)) + 1) .* (x != 0); f = sign (x) .* f ./ (2 .^ e); + ## Workaround to cases of f == 1 (due to precision issues). + idx = abs (f) >= 1; + if (any (idx)) + f(idx) /= 2; + e(idx)++; + endif else error ("log2 takes at most 2 output arguments"); endif