bugGNU Octave - Bugs: bug #63698, sum behavior when second argument...

 
 

bug #63698: sum behavior when second argument is a vector

Submitter:  Michele Ginesi <m_ginesi>
Submitted:  Tue 24 Jan 2023 04:21:26 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * stable Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 24 Jan 2023 04:38:27 PM UTC, comment #1: 

Thank you. this remains a known incompatibility since matlab introduced the VECDIM (vector dimension) and 'all' options around 2018. It is gradually being added to the numerous functions involved, but has not yet made it into sum.  See other bug reports:

bug #58089 - missing vecdim option
bug #58116 - missing 'all' option

It is something we hope to address in the not too distant future.

the "All" option at least has the not-too-difficult workaround of just calling the function as sum(A(:)).

if you are able to help contribute missing functionality it is always appreciated.

closing as duplicate.

Nicholas Jankowski <nrjank>
Group Member
Tue 24 Jan 2023 04:21:26 PM UTC, original submission:  

In Matlab, it is possible to compress sums over multiple dimensions of a matrix by giving a vector as the second argument so that, for instance,


sum(A, [1,2])


is equivalent to


sum(sum(A, 1), 2)


In octave, this is not true, and only the first entry of the second argument is considered.
Consider this minimal example:


A = reshape(1:9, [3,3]);
sum(A, [1,2]);


in Matlab it gives 45, in octave it gives [6 15 24].

Also, Matlab allows the syntax


sum(A,'all')


while octave doesn't

Michele Ginesi <m_ginesi>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by m_ginesi (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
    2023-01-24 nrjank StatusNone Duplicate
        Open/ClosedOpen Closed
        Dependencies- Depends on bugs #58116
        Dependencies- Depends on bugs #58089

    Back to the top

    Powered by Savane 3.13-89af.
    Corresponding source code