bugGNU Octave - Bugs: bug #51145, convn: incompatible results on...

 
 

bug #51145: convn: incompatible results on empty inputs

Submitter:  Hartmut <hardy>
Submitted:  Tue 30 May 2017 06:12:29 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  WTF, Matlab?!?
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 4.2.1 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 01 Jun 2017 12:56:23 AM UTC, comment #5: 

Okay, thanks for testing.  This is just weird, but I am marking it as confirmed.  I'm lowering the priority since I don't see this as critical.

Rik <rik5>
Group administrator
Wed 31 May 2017 11:29:05 PM UTC, comment #4: 

MATLAB 2016a


>> version

ans =

9.0.0.341360 (R2016a)

>> conv2([], ones(5))

ans =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> conv2(ones(5),[])

ans =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> conv2([], ones(5),'same')

ans =

     []

>> conv2(ones(5),[],'same')

ans =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> conv2([], ones(5),'valid')

ans =

     []

>> conv2(ones(5),[],'valid')

ans =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0


I would also like to take this opportunity to plug a feature request for "cyclic" / "circular" convolution :)

Ceral Paquet <octavebugs>
Wed 31 May 2017 07:51:28 PM UTC, comment #3: 

Sorry, I do not have access to a newer Matlab version.

I am also unsure if this is worth fixing, or at least changing, at all. Having either empty data or an empty filter with conv doesn't make much sense to me. This issue is really only about "compatibility" in this case.

Maybe a user's intuitive understanding might be: If I have an empty filter, then I expect to get my unchanged data back, since I am not filtering at all in this case. But his isn't quite what Matlab (R2014b) does, either.

Hartmut <hardy>
Wed 31 May 2017 06:18:02 PM UTC, comment #2: 

Is it possible to test the Matlab behavior in a newer version, R2016b or R2017a?  I wonder if they have fixed this.

Rik <rik5>
Group administrator
Wed 31 May 2017 12:39:57 AM UTC, comment #1: 

I think this is a Matlab bug.  Even if the output ought to be of size "size(A)+size(B)-1" then it should return something of size [4 4], and not [5 5].  We can have Octave return that [4 4] by simply removing those checks on oct-conv.cc http://hg.savannah.gnu.org/hgweb/octave/file/0e4ceda8fbcf/liboctave/numeric/oct-convn.cc#l135

But I am still unsure. If the point of full convolution is to include even elements affected by padding, since there was no convolution done at all, the return should be empty?

I am removing the filter2 part of the bug title, since that behaviour is inherited from the conv functions.

Carnë Draug <carandraug>
Group Member
Tue 30 May 2017 06:12:29 PM UTC, original submission:  

This happens in Octave 4.2.1:

>> conv2([], ones(5))
ans = [](0x0)

>> conv2(ones(5),[])
ans = [](0x0)

>> filter2([], ones(5))
ans = [](0x0)

>> filter2(ones(5),[])
ans = [](0x0)


This is the corresponding Matlab (R2014b) output:

>> conv2([], ones(5))
ans =
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> conv2(ones(5),[])
ans =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> filter2([], ones(5))
ans =
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0

>> filter2(ones(5),[])
ans =
     []


So the Octave version of the functions conv2 and filter2 always return an empty matrix if any input value is an empty matrix. But the Matlab version returns mostly (except for one of four cases, funny) a full zero matrix in this case.

Hartmut <hardy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by octavebugs (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-06-01 rik5 Priority5 - Normal 3 - Low
        Item GroupMatlab Compatibility WTF, Matlab?!?
        StatusNeed Info Confirmed
    2017-05-31 rik5 StatusNone Need Info
    2017-05-31 carandraug Summaryconv2 and filter2: incompatible results on empty inputs convn: incompatible results on empty inputs

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code