help-octave
[Top][All Lists]
Advanced

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

prod([]) in 2.9.4 vs. 2.9.8


From: John W. Eaton
Subject: prod([]) in 2.9.4 vs. 2.9.8
Date: Fri, 25 Aug 2006 16:11:59 -0400

On 25-Aug-2006, Gerd Bürger wrote:

| in 2.9.4, I get
| 
| prod([]) = 1.
| 
| In 2.9.8 it is
| 
| prod([]) = [].
| 
| Is this ok? (My butterworth filter stopped to work.)

It looks like a bug.  It seems that I accidentally removed this
special feature when I was trying to fix some problems with prod, sum,
cumprod, cumsum, etc. functions and empty N-d array arguments.

Please try the following patch.

BTW, it seems odd to me that in Matlab (and now Octave)

  prod (zeros (0, 0, 0))  ==>  [](1x0x0)

but

  prod (zeros (0, 0))  ==>  1
  prod ([])            ==>  1

Am I missing something?  Why is this justified?

jwe


liboctave/ChangeLog:

2006-08-25  John W. Eaton  <address@hidden>

        * mx-inlines.cc (MX_ND_REDUCTION): Special case for 0x0 arrays.


Index: liboctave/mx-inlines.cc
===================================================================
RCS file: /cvs/octave/liboctave/mx-inlines.cc,v
retrieving revision 1.49
diff -u -u -r1.49 mx-inlines.cc
--- liboctave/mx-inlines.cc     22 Aug 2006 18:37:43 -0000      1.49
+++ liboctave/mx-inlines.cc     25 Aug 2006 19:49:40 -0000
@@ -383,6 +383,12 @@
         } \
     } \
  \
+  if (nd == 2 && dv(0) == 0 && dv(1) == 0) \
+    { \
+      retval.resize (dim_vector (1, 1), INIT_VAL); \
+      return retval; \
+    } \
+ \
   /* We need to find first non-singleton dim.  */ \
  \
   if (dim == -1) \



reply via email to

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