help-octave
[Top][All Lists]
Advanced

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

Re: max([],1)


From: David Bateman
Subject: Re: max([],1)
Date: Fri, 08 Jun 2007 15:47:33 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Gerd Bürger wrote:
> In octave-2.9 I get
>
> max(1,[]) = 1, max([],1) = [].
>
> Is that on purpose?
>
> Gerd
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>
>   
I get the same behavior in 2.9.12+, but MatlabR2007a gives..

>> max(1,[])

ans =

     []

>>  max([],1)

ans =

     []

>> max(1,[],1)

ans =

     1

In fact I think the matlab behavior is rather stupid as "max(1,[])"
should probably be treated as "max(1,[],1)". In any case the attached
patch makes the behavior compatible.. John, make your choice whether you
want to apply it or not...

D.




-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

--- src/DLD-FUNCTIONS/minmax.cc.~1.23.~ 2006-10-17 15:39:23.000000000 +0200
+++ src/DLD-FUNCTIONS/minmax.cc 2007-06-08 15:44:36.812698395 +0200
@@ -99,7 +99,7 @@
        dim = 0; \
     } \
  \
-  bool single_arg = (nargin == 1) || arg2.is_empty();  \
+  bool single_arg = (nargin == 1) || (arg2.is_empty() && nargin == 3); \
  \
   if (single_arg && (nargout == 1 || nargout == 0)) \
     { \

reply via email to

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