octave-maintainers
[Top][All Lists]
Advanced

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

Patch: prod(size(x)) -> numel(x)


From: Bill Denney
Subject: Patch: prod(size(x)) -> numel(x)
Date: Sat, 06 Oct 2007 07:25:27 -0400
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)

Hi Everyone,

I haven't been able to work much recently, but I just noticed 2.9.14 came out and I glanced through the sources for my favorite "bug". Here is a patch that removes all uses of prod(size(x)) and replaces them with numel(x).

Thanks,

Bill


scripts/ChangeLog:

2007-10-06  Bill Denney <address@hidden>

* general/__splinen__.m, general/isscalar.m, general/rat.m, strings/dec2base.m: changed prod(size(x)) to numel(x)
? configure
Index: general/__splinen__.m
===================================================================
RCS file: /cvs/octave/scripts/general/__splinen__.m,v
retrieving revision 1.3
diff -u -r1.3 __splinen__.m
--- general/__splinen__.m       2 Oct 2007 20:47:22 -0000       1.3
+++ general/__splinen__.m       6 Oct 2007 11:20:28 -0000
@@ -30,7 +30,7 @@
   if (nargin != 5)
     error ("Incorrect number of arguments");
   endif
-  isvec = @(x) prod(size(x)) == length(x);   # ND isvector function
+  isvec = @(x) numel(x) == length(x);   # ND isvector function
   if (!iscell (x) || length(x) < ndims(y) || any (! cellfun (isvec, x)) ||
       !iscell (xi) || length(xi) < ndims(y) || any (! cellfun (isvec, xi)))
     error ("%s: non gridded data or dimensions inconsistent", f);
Index: general/isscalar.m
===================================================================
RCS file: /cvs/octave/scripts/general/isscalar.m,v
retrieving revision 1.6
diff -u -r1.6 isscalar.m
--- general/isscalar.m  10 Oct 2006 16:10:27 -0000      1.6
+++ general/isscalar.m  6 Oct 2007 11:20:29 -0000
@@ -28,7 +28,7 @@
 function retval = isscalar (x)
 
   if (nargin == 1)
-    retval = prod (size (x)) == 1;
+    retval = numel(x) == 1;
   else
     print_usage ();
   endif
Index: general/rat.m
===================================================================
RCS file: /cvs/octave/scripts/general/rat.m,v
retrieving revision 1.1
diff -u -r1.1 rat.m
--- general/rat.m       23 Jul 2007 22:05:30 -0000      1.1
+++ general/rat.m       6 Oct 2007 11:20:29 -0000
@@ -58,7 +58,7 @@
   lastd = zeros(size(y));
 
   nd = ndims(y);
-  nsz = prod (size (y));
+  nsz = numel(y);
   steps = zeros([nsz, 0]);
 
   ## grab new factors until all continued fractions converge
Index: strings/dec2base.m
===================================================================
RCS file: /cvs/octave/scripts/strings/dec2base.m,v
retrieving revision 1.12
diff -u -r1.12 dec2base.m
--- strings/dec2base.m  10 Oct 2006 16:10:31 -0000      1.12
+++ strings/dec2base.m  6 Oct 2007 11:20:29 -0000
@@ -53,7 +53,7 @@
     print_usage ();
   endif
 
-  if (prod (size (n)) != length (n))
+  if (numel(n) != length (n))
     n = n(:);
   elseif (any (n < 0 | n != fix (n)))
     error ("dec2base: can only convert non-negative integers")

reply via email to

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