# HG changeset patch # User Rik # Date 1318001940 25200 # Node ID 5c22edebf2e87eedec100adc9fbda760c87ae2d2 # Parent 49ae6f4971711c5e54370d6aa9986ad1773f510e rot90.m: Simplify function by using mod() rather than rem() * rot90.m: Simplify function by using mod() rather than rem() diff -r 49ae6f497171 -r 5c22edebf2e8 scripts/general/rot90.m --- a/scripts/general/rot90.m Fri Oct 07 08:28:00 2011 -0700 +++ b/scripts/general/rot90.m Fri Oct 07 08:39:00 2011 -0700 @@ -60,17 +60,11 @@ if (ndims (A) > 2) error ("rot90: A must be a 2-D array"); - endif - - if (! (isscalar (k) && isreal (k) && fix (k) == k)) + elseif (! (isscalar (k) && isreal (k) && k == fix (k))) error ("rot90: K must be a single real integer"); endif - k = rem (k, 4); - - if (k < 0) - k = k + 4; - endif + k = mod (k, 4); if (k == 0) B = A; @@ -93,12 +87,12 @@ %! x3 = [4, 3; 2, 1]; %! x4 = [3, 1; 4, 2]; %! -%! assert(rot90 (x1) == x2); -%! assert(rot90 (x1, 2) == x3); -%! assert(rot90 (x1, 3) == x4); -%! assert(rot90 (x1, 4) == x1); -%! assert(rot90 (x1, 5) == x2); -%! assert(rot90 (x1, -1) == x4); +%! assert(rot90 (x1), x2); +%! assert(rot90 (x1, 2), x3); +%! assert(rot90 (x1, 3), x4); +%! assert(rot90 (x1, 4), x1); +%! assert(rot90 (x1, 5), x2); +%! assert(rot90 (x1, -1), x4); %% Test input validation %!error rot90 ();