bugGNU Octave - Bugs: bug #51682, No error issued for left division...

 
 

bug #51682: No error issued for left division of scalar_double_type \ integer_matrix_type, also wrong answer

Submitter:  Rik <rik5>
Submitted:  Mon 07 Aug 2017 03:26:37 PM UTC
   
 
Category:  Interpreter Severity:  4 - Important
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 08 Mar 2018 11:34:04 PM UTC, comment #4: 

Works for me!  Closing report.

And yes, we do need better test coverage.  For fundamental operators like this something in the test/ directory would be appropriate.

Rik <rik5>
Group administrator
Thu 08 Mar 2018 10:54:29 PM UTC, comment #3: 

It turns out that this was a one-line fix for a likely cut and paste error.  I pushed the following changeset to stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/dfc017e465f2

Now I see:


octave> is = int8 (10); im = int8 ([10, 20; 30, 40]);
octave> r = 5 \ is, class (r)
r = 2
ans = int8
octave> r = single (5) \ is, class (r)
r = 2
ans = int8
octave> r = 5 \ im, class (r)
r =

  2  4
  6  8

ans = int8
octave> r = single (5) \ im, class (r)
r =

  2  4
  6  8

ans = int8


and so on for other integer types.

Am I missing something, or do we not have a set of tests for integer arithmetic?  Maybe we can do something systematic and cover a large set of cases at once in one of the code sprints next week.

Please close this report if the problem is fixed for you.

John W. Eaton <jwe>
Group administrator
Tue 08 Aug 2017 04:29:51 PM UTC, comment #2: 

So for compatibility, Octave could support scalar_double \ scalar_int, scalar_float \ scalar_int, scalar_double \ int_matrix, scalar_float \ int_matrix if someone finds the time.

Rik <rik5>
Group administrator
Tue 08 Aug 2017 12:39:33 PM UTC, comment #1: 

For reference, in Matlab 2016b


&gt;&gt; x = int8 ([1 0; 1 1])

x =

  2×2 int8 matrix

   1   0
   1   1

&gt;&gt; 2 \ x

ans =

  2×2 int8 matrix

   1   0
   1   1

&gt;&gt; 2 \ double(x)

ans =

    0.5000         0
    0.5000    0.5000


Anonymous
Mon 07 Aug 2017 03:26:37 PM UTC, original submission:  

Left division incorrectly returns a scalar type, rather than a matrix type, for scalar_double \ integer_matrix.

Example code:


octave:1> x = int8 ([1 0; 1 1])
x =

  1  0
  1  1

octave:2> 2 \ x
ans =  0.50000
octave:3> 2 \ double (x)
ans =

   0.50000   0.00000
   0.50000   0.50000


Since left-division isn't implemented for integer data types (see bug #51650) this case should also just throw an error about an unimplemented operator rather than calculating a value which is misleading.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-08 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-03-08 jwe StatusConfirmed Ready For Test
    2017-08-07 rik5 Dependencies- Depends on bugs #51650

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code