bugGNU Octave - Bugs: bug #47173, mtimes allows arguments with >=...

 
 

bug #47173: mtimes allows arguments with >= 3 dimensions

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Tue 16 Feb 2016 09:19:01 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Patch Submitted Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 29 Nov 2022 06:28:55 PM UTC, comment #10: 

bug still present in Octave 8.0.1.

I'd wager Lachlan's 2016 patch will no longer apply cleanly. Is the approach sufficiently satisfactory to make it it worth revisiting and trying to refresh?

Nicholas Jankowski <nrjank>
Group Member
Tue 15 Dec 2020 01:17:42 AM UTC, comment #9: 

Octave 6.1.0 behavior unchanged from comment #6.

Nicholas Jankowski <nrjank>
Group Member
Mon 17 Feb 2020 03:01:03 AM UTC, comment #8: 

behavior still present in Octave 5.2.0

Nicholas Jankowski <nrjank>
Group Member
Tue 05 Sep 2017 05:02:22 PM UTC, comment #7: 

Thanks for testing.  I'm switching the Item Group to Regression since this used to produce an error (even if not exactly on topic).

Rik <rik5>
Group administrator
Tue 05 Sep 2017 03:55:04 PM UTC, comment #6: 

Appears to still be relevant.

Matlab 2017a:


>> ones(2,3)*ones(3,1)

ans =

     3
     3

>> ones(2,3)*ones(3,1,2)
Error using  *
Arguments must be 2-D, or at least one argument must be scalar. Use TIMES (.*) for elementwise
multiplication.

>> ones(2,3)*ones(3,1,2,2)
Error using  *
Arguments must be 2-D, or at least one argument must be scalar. Use TIMES (.*) for elementwise
multiplication.

>> ones(2,3)*ones(3,1,2,2,2)
Error using  *
Arguments must be 2-D, or at least one argument must be scalar. Use TIMES (.*) for elementwise
multiplication.


Octave 4.2.1:

>> ones(2,3)*ones(3,1)
ans =

   3
   3

>> ones(2,3)*ones(3,1,2)
ans =

   3   3
   3   3

>> ones(2,3)*ones(3,1,2,2)
ans =

   3   3   3   3
   3   3   3   3

>> ones(2,3)*ones(3,1,2,2,2)
ans =

   3   3   3   3   3   3   3   3
   3   3   3   3   3   3   3   3


Nicholas Jankowski <nrjank>
Group Member
Sun 03 Sep 2017 12:58:23 AM UTC, comment #5: 

Since Matlab has added broadcasting in 2016B, is their behavior still the same as reported in the original submission which was for version 2015B?

I just want to make sure this bug is still relevant.

Rik <rik5>
Group administrator
Thu 18 Feb 2016 01:51:45 AM UTC, comment #4: 

I'm attaching a patch, and the shell+awk scripts I used to generate it.

The operators are created by a maze of nested macros to minimize repeated code.  It may be able to be simplified using templates, but my guess is that it would still require quite a bit of special-case code.  For example "A * B'" doesn't just transpose B and then multiply; it uses a particular library call that performs them together.  Multiplication by a sparse, diagonal or permutation matrix clearly needs different code from multiplication by a full matrix etc.

This is right in the heart of Octave, and so it will probably take a lot of time and testing to get the patch approved.  Any suggestions of how to test the hundreds of operators would be welcomed!

(file #36370, file #36371, file #36372)

Lachlan Andrew <lachlan>
Wed 17 Feb 2016 02:53:04 PM UTC, comment #3: 

Yikes. repeated code? or not identical enough for it to be functionalized and addressed in one place?

Nicholas Jankowski <nrjank>
Group Member
Wed 17 Feb 2016 02:01:35 AM UTC, comment #2: 

Yes, the arguments are being flattened to 2D implicitly, through a maze of macros in libinterp/operators/op-??-??.cc

I'm preparing a patch, but there are lots of functions to fix (all combinations of single/double, real/complex, sparse, diagonal, ..., for half a dozen operators (A*B, A/B,   A*B', A'*B, A\B, A'\B)).

Lachlan Andrew <lachlan>
Tue 16 Feb 2016 11:13:45 PM UTC, comment #1: 

Confirmed. FTR, did produce an error in 3.8.x and earlier, although it was not a non-conformant argument error:


octave:1> ones (2, 3) * ones (3, 1, 2, 2, 2)
error: invalid conversion of NDArray to Matrix


Mike Miller <mtmiller>
Group Member
Tue 16 Feb 2016 09:19:01 PM UTC, original submission:  

This just came up on the help mailing list. I think the following example presents the issue concisely:


octave:15> ones(2,3)*ones(3,1)
ans =

   3
   3

octave:16> ones(2,3)*ones(3,1,2)
ans =

   3   3
   3   3

octave:17> ones(2,3)*ones(3,1,2,2)
ans =

   3   3   3   3
   3   3   3   3

octave:18> ones(2,3)*ones(3,1,2,2,2)
ans =

   3   3   3   3   3   3   3   3
   3   3   3   3   3   3   3   3


Each of those except the first should produce a non-conformant argument error. (Matlab 2015b errors out in these cases)

The email discussion thought maybe the issue had to do with broadcasting, but it now seems unrelated (and should be, since .* is uninvolved). 

Is mtimes flattening the argument to 2D (from nxm mxpxq to nxm mx(p*q) ) and skipping any conformance checking?

(verified still exists in 4.0.1rc3)

Nicholas Jankowski <nrjank>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #36370:  bug_47173_mtimes.cset added by lachlan (36KiB - application/octet-stream)
file #36371:  add_check.awk added by lachlan (704B - application/x-awk)
file #36372:  traverse_files.sh added by lachlan (2KiB - application/x-shellscript)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-11-29 nrjank Assigned tolachlan None
    2020-02-17 mtmiller Carbon-CopyRemoved 80942 -
    2017-09-05 rik5 Item GroupIncorrect Result Regression
    2016-02-18 lachlan Attached File- Added bug_47173_mtimes.cset, #36370
        Attached File- Added add_check.awk, #36371
        Attached File- Added traverse_files.sh, #36372
        StatusIn Progress Patch Submitted
    2016-02-17 lachlan StatusConfirmed In Progress
        Assigned toNone lachlan
        Release4.0.1-rc1 dev
        Summarymtimes allows non-conformant arguments, looks similar to unexpected broadcasting mtimes allows arguments with >= 3 dimensions
    2016-02-16 mtmiller StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
    2016-02-16 nrjank Carbon-Copy- Added juanpi
        Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added caliari

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code