diff scripts/general/rem.m @ 4:b4df021f796c

[project @ 1993-08-08 01:26:08 by jwe] Initial revision
author jwe
date Sun, 08 Aug 1993 01:26:08 +0000
parents
children 16a24e76d6e0
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/scripts/general/rem.m
@@ -0,0 +1,28 @@
+function retval = rem (x, y)
+
+# usage: rem (x, y)
+#
+# Return remainder (x, y).
+
+  if (nargin != 2)
+    error ("usage: rem (x, y)");
+  endif
+
+  if (any (size (x) != size (y)))
+    error ("rem: argument sizes must agree")
+  endif
+
+# 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))))
+    error ("rem: complex arguments are not allowed");
+  endif
+
+  if (nargin == 2)
+    retval = x - y .* fix (x ./ y);
+  else
+    error ("usage: rem (x, y)");
+  endif
+
+endfunction