changeset 11094:add5beb3b845

avoid use of | and & in IF conditions in statistics distribution functions
author John W. Eaton <jwe@octave.org>
date Sat, 09 Oct 2010 11:55:51 -0400
parents d748acc75658
children d4619eb6ef8e
files scripts/ChangeLog scripts/statistics/distributions/geornd.m scripts/statistics/distributions/hygecdf.m scripts/statistics/distributions/hygeinv.m scripts/statistics/distributions/poissrnd.m scripts/statistics/distributions/wblrnd.m
diffstat 6 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,13 @@
+2010-10-09  John W. Eaton  <jwe@octave.org>
+
+	* statistics/distributions/geornd.m,
+	* statistics/distributions/hygecdf.m,
+	* statistics/distributions/hygeinv.m,
+	* statistics/distributions/poissrnd.m, 
+	* statistics/distributions/wblrnd.m:
+	Use || instead of | and && instead of & in IF conditions
+	involving scalars.
+
 2010-10-09  John W. Eaton  <jwe@octave.org>
 
 	* plot/__fltk_ginput__.m: Use || instead of | in IF condition.
--- a/scripts/statistics/distributions/geornd.m
+++ b/scripts/statistics/distributions/geornd.m
@@ -67,11 +67,11 @@
 
 
   if (isscalar (p))
-    if (!(p >= 0) || !(p <= 1))
+    if (p < 0 || p > 1)
       rnd = NaN (sz);
     elseif (p == 0)
       rnd = Inf (sz);
-    elseif ((p > 0) & (p < 1));
+    elseif (p > 0 && p < 1);
       rnd = floor (- rande(sz) ./ log (1 - p));
     else
       rnd = zeros (sz);
--- a/scripts/statistics/distributions/hygecdf.m
+++ b/scripts/statistics/distributions/hygecdf.m
@@ -42,8 +42,8 @@
     error ("hygecdf: t, m and n must all be positive integers");
   endif
 
-  if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) |
-      (m != round (m)) | (n != round (n)) | (m > t) | (n > t))
+  if (t < 0 || m < 0 || n <= 0 || t != round (t) || m != round (m)
+      || n != round (n) || m > t || n > t)
     cdf = NaN (size (x))
   else
     cdf = discrete_cdf (x, 0 : n, hygepdf (0 : n, t, m, n));
--- a/scripts/statistics/distributions/hygeinv.m
+++ b/scripts/statistics/distributions/hygeinv.m
@@ -39,8 +39,8 @@
     error ("hygeinv: t, m and n must all be positive integers");
   endif
 
-  if ((t < 0) | (m < 0) | (n <= 0) | (t != round (t)) |
-      (m != round (m)) | (n != round (n)) | (m > t) | (n > t))
+  if (t < 0 || m < 0 || n <= 0 || t != round (t) || m != round (m)
+      || n != round (n) || m > t || n > t)
     inv = NaN (size (x))
   else
     inv = discrete_inv (x, 0 : n, hygepdf (0 : n, t, m, n));
--- a/scripts/statistics/distributions/poissrnd.m
+++ b/scripts/statistics/distributions/poissrnd.m
@@ -65,9 +65,9 @@
 
   if (isscalar (l))
 
-    if (!(l >= 0) | !(l < Inf))
+    if (!(l >= 0) || !(l < Inf))
       rnd = NaN (sz);
-    elseif ((l > 0) & (l < Inf))
+    elseif (l > 0 && l < Inf)
       rnd = randp(l, sz);
     else
       rnd = zeros (sz);
--- a/scripts/statistics/distributions/wblrnd.m
+++ b/scripts/statistics/distributions/wblrnd.m
@@ -77,7 +77,7 @@
   endif
 
   if (isscalar (shape) && isscalar (scale))
-    if ((shape > 0) & (shape < Inf) & (scale > 0) & (scale < Inf))
+    if (shape > 0 && shape < Inf && scale > 0 && scale < Inf)
       rnd = scale .* rande(sz) .^ (1./shape);
     else
       rnd = NaN (sz);