bugGNU Octave - Bugs: bug #53232, Range type should implement...

 
 

bug #53232: Range type should implement element-by-element multiplication operator with a scalar

Submitter:  Rik <rik5>
Submitted:  Tue 27 Feb 2018 01:50:47 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
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 22 Mar 2018 05:58:57 PM UTC, comment #3: 

I committed this change to the stable branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/ef8df0a8b358).  This will be a part of the 4.4.0 release coming very soon.

I changed the first sentence of the commit message to summarize what was done.


Add element-by-element multiplication operator for ranges (bug #53232).


When you use 'hg log' whatever is the first line of the commit message is prepended with "summary: ".  Hence, 'hg log' for this now reports


changeset:   24972:ef8df0a8b358
branch:      stable
user:        maorshutman <maorus12@gmail.com>
date:        Thu Mar 22 12:03:54 2018 +0200
summary:     Add element-by-element multiplication operator for ranges (bug #53232).


Thanks for the second improvement patch for Ranges.  I'm marking this as fixed and closing report.


Rik <rik5>
Group administrator
Tue 27 Feb 2018 07:34:54 PM UTC, comment #2: 

As an additional data point, see bug #53199 where the extra accuracy of a Range, versus a Matrix, data type was crucial to resolving the bug.

Rik <rik5>
Group administrator
Tue 27 Feb 2018 04:02:56 AM UTC, comment #1: 

See also bug #50924.  Some care needs to be used when implementing these operators.  Otherwise, if accuracy and/or compatibility is important, we should probably limit the range type to be used in only a few cases (for loop ranges, for example), same as Matlab.

John W. Eaton <jwe>
Group administrator
Tue 27 Feb 2018 01:50:47 AM UTC, original submission:  

The Range class already implements addition, subtraction, and multiplication operators with a scalar.  And it implements the corresponding element-by-elment operators for addition (.+) and subtraction (.-).  But it does not implement element-by-elment multiplication.

For example:


octave:2> x = 1:5
x =

   1   2   3   4   5

octave:3> typeinfo (x)
ans = range
octave:4> y = x * 2
y =

    2    4    6    8   10

octave:5> typeinfo (y)
ans = range
octave:6> z = x .* 2
z =

    2    4    6    8   10

octave:7> typeinfo (z)
ans = matrix
octave:2> x = 1:5
x =

   1   2   3   4   5

octave:3> typeinfo (x)
ans = range
octave:4> y = x * 2
y =

    2    4    6    8   10

octave:5> typeinfo (y)
ans = range
octave:6> z = x .* 2
z =

    2    4    6    8   10

octave:7> typeinfo (z)
ans = matrix
octave:2> x = 1:5
x =

   1   2   3   4   5

octave:3> typeinfo (x)
ans = range
octave:4> y = x * 2
y =

    2    4    6    8   10

octave:5> typeinfo (y)
ans = range
octave:6> z = x .* 2
z =

    2    4    6    8   10

octave:7> typeinfo (z)
ans = matrix
octave:2> x = 1:5
x =

   1   2   3   4   5

octave:3> typeinfo (x)
ans = range
octave:4> y = x * 2
y =

    2    4    6    8   10

octave:5> typeinfo (y)
ans = range
octave:6> z = x .* 2
z =

    2    4    6    8   10

octave:7> typeinfo (z)
ans = matrix


This seems like an oversight and should be easy to fix as the element-by-element operator should just map to the same routine that ordinary multiplication is using.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43628:  53232.cset added by maors (1KiB - application/octet-stream - Fix for bug #53232. Added an element-by-element multiplication operator that is mapped to ordinary multiplication.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by maors (Updated the item)
  • -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-22 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-03-22 maors Attached File- Added 53232.cset, #43628
    2018-02-27 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code