# HG changeset patch # User John W. Eaton # Date 1286639751 14400 # Node ID add5beb3b845279b7c9a86ab7d7f0dc2dc4daae1 # Parent d748acc75658e9ae9e79540da33244398b2e5ed6 avoid use of | and & in IF conditions in statistics distribution functions diff -r d748acc75658 -r add5beb3b845 scripts/ChangeLog --- a/scripts/ChangeLog Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/ChangeLog Sat Oct 09 11:55:51 2010 -0400 @@ -1,3 +1,13 @@ +2010-10-09 John W. Eaton + + * 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 * plot/__fltk_ginput__.m: Use || instead of | in IF condition. diff -r d748acc75658 -r add5beb3b845 scripts/statistics/distributions/geornd.m --- a/scripts/statistics/distributions/geornd.m Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/statistics/distributions/geornd.m Sat Oct 09 11:55:51 2010 -0400 @@ -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); diff -r d748acc75658 -r add5beb3b845 scripts/statistics/distributions/hygecdf.m --- a/scripts/statistics/distributions/hygecdf.m Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/statistics/distributions/hygecdf.m Sat Oct 09 11:55:51 2010 -0400 @@ -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)); diff -r d748acc75658 -r add5beb3b845 scripts/statistics/distributions/hygeinv.m --- a/scripts/statistics/distributions/hygeinv.m Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/statistics/distributions/hygeinv.m Sat Oct 09 11:55:51 2010 -0400 @@ -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)); diff -r d748acc75658 -r add5beb3b845 scripts/statistics/distributions/poissrnd.m --- a/scripts/statistics/distributions/poissrnd.m Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/statistics/distributions/poissrnd.m Sat Oct 09 11:55:51 2010 -0400 @@ -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); diff -r d748acc75658 -r add5beb3b845 scripts/statistics/distributions/wblrnd.m --- a/scripts/statistics/distributions/wblrnd.m Sat Oct 09 11:42:22 2010 -0400 +++ b/scripts/statistics/distributions/wblrnd.m Sat Oct 09 11:55:51 2010 -0400 @@ -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);