changeset 6156:a46f14cdbecd

[project @ 2006-11-13 19:20:23 by jwe]
author jwe
date Mon, 13 Nov 2006 19:20:23 +0000
parents ab5008998876
children 045038e0108a
files scripts/ChangeLog scripts/plot/mesh.m src/ChangeLog src/data.cc
diffstat 4 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Nov 13 18:49:52 2006 +0000
+++ b/scripts/ChangeLog	Mon Nov 13 19:20:23 2006 +0000
@@ -1,3 +1,7 @@
+2006-11-13  John W. Eaton  <jwe@octave.org>
+
+	* plot/mesh.m: Use size_equal to compare dimensions.
+
 2006-11-13  Søren Hauberg  <soren@hauberg.org>
 
 	* plot/mesh.m: Simplify.  Set hidden3d for the plot.
--- a/scripts/plot/mesh.m	Mon Nov 13 18:49:52 2006 +0000
+++ b/scripts/plot/mesh.m	Mon Nov 13 19:20:23 2006 +0000
@@ -50,8 +50,7 @@
         error (msg);
       endif
     elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
-      if (ndims (x) != ndims (y) || ndims (x) != ndims (z)
-	  || size (x) != size (y) || size (x) != size (z))
+      if (! (size_equal (x, y) && size_equal (x, z)))
         error ("mesh: x, y, and z must have same dimensions");
       endif
     else
--- a/src/ChangeLog	Mon Nov 13 18:49:52 2006 +0000
+++ b/src/ChangeLog	Mon Nov 13 19:20:23 2006 +0000
@@ -1,3 +1,7 @@
+2006-11-13  John W. Eaton  <jwe@octave.org>
+
+	* data.cc (Fsize_equal): New function.
+
 2006-11-13  Michael Goffioul  <michael.goffioul@swing.be>
 
 	* ov.cc (check_subsref_elements, Fsubsref, Fsubsasgn):
--- a/src/data.cc	Mon Nov 13 18:49:52 2006 +0000
+++ b/src/data.cc	Mon Nov 13 19:20:23 2006 +0000
@@ -1081,10 +1081,36 @@
   return retval;
 }
 
+DEFUN (size_equal, args, ,
+   "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} size_equal (@var{a}, @var{b})\n\
+Return true if the dimensions of @var{a} and @var{b} agree.\n\
+Trailing singleton dimensions are ignored.\n\
+@seealso{size, numel}\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () == 2)
+    {
+      dim_vector a_dims = args(0).dims ();
+      dim_vector b_dims = args(1).dims ();
+
+      a_dims.chop_trailing_singletons ();
+      b_dims.chop_trailing_singletons ();
+
+      retval = a_dims == b_dims;
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
+
 DEFUN (nnz, args, ,
    "-*- texinfo -*-\n\
-@deftypefn {Loadable Function} {@var{scalar} =} nnz (@var{a})\n\
-returns number of non zero elements in @var{a}.\n\
+@deftypefn {Built-in Function} {@var{scalar} =} nnz (@var{a})\n\
+Returns the number of non zero elements in @var{a}.\n\
 @seealso{sparse}\n\
 @end deftypefn")
 {
@@ -1100,7 +1126,7 @@
 
 DEFUN (nzmax, args, ,
    "-*- texinfo -*-\n\
-@deftypefn {Loadable Function} {@var{scalar} =} nzmax (@var{SM})\n\
+@deftypefn {Built-in Function} {@var{scalar} =} nzmax (@var{SM})\n\
 Return the amount of storage allocated to the sparse matrix @var{SM}.\n\
 Note that Octave tends to crop unused memory at the first oppurtunity\n\
 for sparse objects. There are some cases of user created sparse objects\n\