bugGNU Octave - Bugs: bug #53765, "reverse" argument to...

 
 

bug #53765: "reverse" argument to cumsum for Matlab compatibility

Submitter:  CH <atcl>
Submitted:  Fri 27 Apr 2018 11:06:03 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 27 Apr 2018 05:17:59 PM UTC, comment #2: 

Marking as confirmed, and changing the category to "Matlab Compatibility".  I'm lowering the priority since there are easy workarounds.

You can't use linear indexing, because it will convert matrices to vectors, but you can use flip.

A suitable replacement is


r = flip (cumsum (flip (dat)))


If you are working on a specific dimension which is not the first singleton dimension then you have to give that dimension as an argument to both flip and cumsum (which you would have to do anyways).


r = flip (cumsum (flip (dat, dim), dim), dim)



Rik <rik5>
Group administrator
Fri 27 Apr 2018 03:01:26 PM UTC, comment #1: 

Workaround:


r = cumsum(dat(end:-1:1))(end:-1:1)


Unfortunately cumsum is not a .m-file, otherwise this option could be very easily added. Of course, it would be more efficient to do this natively.

Michael Leitner <mleitner>
Fri 27 Apr 2018 11:06:03 AM UTC, original submission:  

Matlab allows to pass the option 'reverse' to the cumsum function with the effect of the cumulative sum being summed with direction from back (end) to front:


r = cumsum(dat,'reverse')


CH <atcl>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by mleitner (Posted a comment)
  • -email is unavailable- added by atcl (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-04-27 rik5 Summary&quot;reverse&quot; argument for cumsum for Matlab compatibility "reverse" argument to cumsum for Matlab compatibility
    2018-04-27 rik5 CategoryNone Octave Function
        Priority5 - Normal 3 - Low
        Item GroupFeature Request Matlab Compatibility
        StatusNone Confirmed
        Summaryreverse cumulative sum "reverse" argument for cumsum for Matlab compatibility
    2018-04-27 jwe Item GroupMatlab Compatibility Feature Request
        Release4.4.0 dev

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code