Mercurial > hg > octave-avbm
changeset 4027:af3a0264eefc
[project @ 2002-08-09 07:01:03 by jwe]
author | jwe |
---|---|
date | Fri, 09 Aug 2002 07:01:03 +0000 |
parents | 8cb8eff3f44c |
children | ef75c970c8f5 |
files | scripts/general/mod.m |
diffstat | 1 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/mod.m +++ b/scripts/general/mod.m @@ -51,28 +51,29 @@ ## Matlab allows complex arguments, but as far as I can tell, that's a ## bunch of hooey. - if (any (any (imag (x))) || any (any (imag (y)))) + if (isreal (x) && isreal (y)) + nz = y != 0.0; + if (all (nz(:))) + ## No elements of y are zero. + r = x - y .* floor (x ./ y); + elseif (is_scalar (y)) + ## y must be zero. + r = x; + else + ## Some elements of y are zero. + if (is_scalar (x)) + r = x * ones (size (y)); + else + r = x; + x = x(nz); + endif + y = y(nz); + r(nz) = x - y .* floor (x ./ y); + endif + else error ("mod: complex arguments are not allowed"); endif - nz = y != 0.0; - if (all (nz(:))) - ## No elements of y are zero. - r = x - y .* floor (x ./ y); - elseif (is_scalar (y)) - ## y must be zero. - r = x; - else - ## Some elements of y are zero. - if (is_scalar (x)) - r = x * ones (size (y)); - else - r = x; - x = x(nz); - endif - r(nz) = x - y .* floor (x ./ y); - endif - endfunction ## empty input test