octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

use of size_equal()


From: Kai Habel
Subject: use of size_equal()
Date: Tue, 11 Dec 2007 13:32:43 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20070801)

Hello,

I noticed only recently that size_equal allows to use more than 2
arguments, which are checked against each other. This patch changes
constructs like

size_equal(x,y) && size_equal(x,z)

to the simpler form

size_equal(x,y,z)


Kai

ChangeLog:

2007-12-11  Kai Habel  <address@hidden>

  * plot/__go_draw_axes__.m: Use size_equal(var1,var2,...) when
  possible.
  * plot/plot3.m: Ditto.
  * plot/ribbon.m: Ditto.
  * plot/slice.m: Ditto.

diff -u scripts.orig/plot/__go_draw_axes__.m scripts/plot/__go_draw_axes__.m
--- scripts.orig/plot/__go_draw_axes__.m        2007-12-11 12:07:21.000000000 
+0100
+++ scripts/plot/__go_draw_axes__.m     2007-12-11 12:08:26.000000000 +0100
@@ -844,7 +844,7 @@
                 err = true;
              endif
            elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat))
-             if (! (size_equal (xdat, ydat) && size_equal (xdat, zdat)))
+             if (! size_equal (xdat, ydat, zdat))
                 err = true;
              endif
            else
diff -u scripts.orig/plot/plot3.m scripts/plot/plot3.m
--- scripts.orig/plot/plot3.m   2007-12-11 12:07:21.000000000 +0100
+++ scripts/plot/plot3.m        2007-12-11 12:10:04.000000000 +0100
@@ -167,7 +167,7 @@
        endif
       endif
 
-      if (! size_equal (x, y) || ! size_equal (x, z))
+      if (! size_equal (x, y, z))
        error ("plot3: x, y, and z must have the same shape");
       endif
 
@@ -211,7 +211,7 @@
        endif
       endif
 
-      if (! size_equal (x, y) || ! size_equal (x, z))
+      if (! size_equal (x, y, z))
        error ("plot3: x, y, and z must have the same shape");
       endif
 
@@ -275,7 +275,7 @@
       endif
     endif
 
-    if (! size_equal (x, y) || ! size_equal (x, z))
+    if (! size_equal (x, y, z))
       error ("plot3: x, y, and z must have the same shape");
     endif
 
diff -u scripts.orig/plot/ribbon.m scripts/plot/ribbon.m
--- scripts.orig/plot/ribbon.m  2007-12-11 12:07:21.000000000 +0100
+++ scripts/plot/ribbon.m       2007-12-11 12:13:24.000000000 +0100
@@ -55,7 +55,7 @@
       [x, y] = meshgrid (x, y);
     endif
   else
-    if (! all (size (x) == size (y)))
+    if (! size_equal(x, y))
       error ("ribbon: in case of matrices, X and Y must have same size")
     endif
   endif
diff -u scripts.orig/plot/slice.m scripts/plot/slice.m
--- scripts.orig/plot/slice.m   2007-12-11 12:07:21.000000000 +0100
+++ scripts/plot/slice.m        2007-12-11 12:11:09.000000000 +0100
@@ -100,7 +100,7 @@
     z = varargin{3};
     if (all ([isvector(x), isvector(y), isvector(z)]))
       [x, y, z] = meshgrid (x, y, z);
-    elseif (ndims (x) == 3 && size_equal (x, y) && size_equal (x, z))
+    elseif (ndims (x) == 3 && size_equal (x, y, z))
       ## Do nothing.
     else
       error ("slice: X, Y, Z size mismatch")
@@ -114,7 +114,7 @@
 
   if (any ([isvector(sx), isvector(sy), isvector(sz)]))
     have_sval = true;
-  elseif (ndims(sx) == 2 && size_equal (sx, sy) && size_equal (sx, sz))
+  elseif (ndims(sx) == 2 && size_equal (sx, sy, sz))
     have_sval = false;
   else
     error ("slice: dimensional mismatch for (XI, YI, ZI) or (SX, SY, SZ)");
diff -u scripts.orig/plot/surface.m scripts/plot/surface.m
--- scripts.orig/plot/surface.m 2007-12-11 12:07:21.000000000 +0100
+++ scripts/plot/surface.m      2007-12-11 12:12:53.000000000 +0100
@@ -92,7 +92,7 @@
         error ("surface: rows (z) must be the same as length (y) and columns 
(z) must be the same as length (x)");
       endif
     elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
-      if (! (size_equal (x, y) && size_equal (x, z)))
+      if (! size_equal (x, y, z))
         error ("surface: x, y, and z must have same dimensions");
       endif
     else
@@ -111,7 +111,7 @@
         error ("surface: rows (z) must be the same as length (y) and columns 
(z) must be the same as length (x)");
       endif
     elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
-      if (! (size_equal (x, y) && size_equal (x, z)))
+      if (! size_equal (x, y, z))
         error ("surface: x, y, and z must have same dimensions");
       endif
     else


reply via email to

[Prev in Thread] Current Thread [Next in Thread]