octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #63950] trapz error with empty inputs


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #63950] trapz error with empty inputs
Date: Tue, 21 Mar 2023 12:08:02 -0400 (EDT)

Follow-up Comment #2, bug #63950 (project octave):

checking matlab compatibility for different types of empty inputs:

matlab 2022b:

>> a = []
a =
     []
>> b = 1:0
b =
  1×0 empty double row vector
>> c = ones(0,1)
c =
  0×1 empty double column vector
>> d = ones(0,0,0)
d =
  0×0×0 empty double array
>> trapz(a,a)
Error using trapz
X must be a vector. 
>> trapz(b,a)
ans =
     0
>> trapz(a,c)
Error using trapz
X must be a vector. 
>> trapz(c,a)
ans =
     0
>> trapz(b,c)
ans =
     0
>> trapz(c,b)
ans =
     0
>> trapz(d,a)
Error using trapz
X must be a vector. 
>> trapz(d,b)
Error using trapz
X must be a vector. 
>> trapz(d,c)
Error using trapz
X must be a vector. 
>> trapz(d,d)
Error using trapz
X must be a vector. 
>> trapz(a,d)
Error using trapz
X must be a vector. 
>> trapz(b,d)
ans =
  1×0×0 empty double array
>> trapz(c,d)
ans =
  1×0×0 empty double array


same commands in Octave 8.1.0:

>> a = []
a = [](0x0)
>> b = 1:0
b = [](1x0)
>> c = ones(0,1)
c = [](0x1)
>> d = ones(0,0,0)
d = [](0x0x0)
>> trapz(a,a)
ans = 0
>> trapz(a,b)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(b,a)
ans = 0
>> trapz(a,c)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(c,a)
ans = 0
>> trapz(b,c)
ans = 0
>> trapz(c,b)
error: trapz: length of X and length of Y along DIM must match
error: called from
    trapz at line 117 column 7
>> trapz(d,a)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(d,b)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(d,c)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(d,d)
ans = [](1x0x0)
>> trapz(a,d)
error: trapz: X and Y must have same shape
error: called from
    trapz at line 126 column 7
>> trapz(b,d)
ans = [](1x0x0)
>> trapz(c,d)
ans = [](1x0x0)


Octave tries to produce compatible output for inputs that don't result in
errors. Note that [], ones(0,1), and ones(1,0) are not necessarily equivalent,
and they sometimes can and should produce different outputs for certain
functions.  In this case, however, matlab produces errors for a number of
input combinations. And judging by brevity in some of the messages (e.g.,
"Error using trapz" sans any detail), this one has probably been around for a
long time without being revisited by mathworks like some of the other
functions we've recently been trying to bring back into empty-input
compatibility. 

Anyway, for inputs where matlab isn't producing an error,  we appear to be
producing compatible output.  Maybe we could be more consistent on some of the
others either in error message or by producing an actual output, but I'm not
seeing a specific problem here.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63950>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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