bugGNU Octave - Bugs: bug #61098, Many functions should now accept...

 
 

bug #61098: Many functions should now accept vector dimension argument

Submitter:  Kai Torben Ohlhus <siko1056>
Submitted:  Wed 01 Sep 2021 05:35:13 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  In Progress 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
   

Jump to the original submission

Thu 07 Oct 2021 04:06:18 AM UTC, comment #10: 

Thank you 🙂

Kai Torben Ohlhus <siko1056>
Group Member
Thu 07 Oct 2021 03:54:33 AM UTC, comment #9: 

I updated the commit message and pushed here:

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

Marking as "in progress" instead of "ready for test" since this report is now also about other functions accepting DIM as a vector.

John W. Eaton <jwe>
Group administrator
Thu 07 Oct 2021 02:48:05 AM UTC, comment #8: 

@jwe, shall I push your cset with my modification?  Or is further work necessary?

Kai Torben Ohlhus <siko1056>
Group Member
Thu 30 Sep 2021 06:15:01 AM UTC, comment #7: 

Thanks for the patch @jwe.  I added several BIST that are checked with Matlab R2021a and made a small change to pass them all:


   if (nargin == 1)
     {
-      if (nargout > 1 && nargout < ndims)
+      if (nargout > 1)
         {


caused the extra queried dimensions e1 and e2 in


[nr, nc, e1, e2] = size ([1, 2; 3, 4; 5, 6])


to be undefined.

Kai Torben Ohlhus <siko1056>
Group Member
Fri 24 Sep 2021 08:27:11 PM UTC, comment #6: 

I'm attaching a patch for the originally reported issue of the size function not allowing multiple dimensions to be queried at once.  Would someone like to look at adding a set of tests for this new feature?  If that turns up additional problems, I'll try to fix and then commit a changeset.

(file #51959)

John W. Eaton <jwe>
Group administrator
Thu 02 Sep 2021 03:56:55 PM UTC, comment #5: 

i think we could probably combine.  This one started about size, bug #58089 is about sum, bug #56153 covers any/all. None have had any work done yet. I would maybe also combining with bug #58116 which pointed out that "all" was added as a DIM option at the same time as vector dims to a number of functions.  seems similar enough to lump together as a single 'handle all the new dimension stuff in these functions' report.

Nicholas Jankowski <nrjank>
Group Member
Wed 01 Sep 2021 05:07:55 PM UTC, comment #4: 

Should we merge these bug reports or keep this one just about the size function?

The problem with size should be easy to fix since it is just about reporting some info that is easily accessible.

It will be somewhat harder to fix the other functions that now accept vectors of dimensions because we have to do computations over all the listed dimensions.

Still changing this back to a feature request since it is a new feature.

John W. Eaton <jwe>
Group administrator
Wed 01 Sep 2021 04:43:59 PM UTC, comment #3: 

The other functions are also listed in bug #58089.

Guillaume <gyom>
Wed 01 Sep 2021 04:31:04 PM UTC, comment #2: 

in addition to size, this change apparently affects other functions as well.

looking through release notes going back to 2018:
https://www.mathworks.com/help/matlab/release-notes.html

2018b

Vector Dimension Argument: Operate on multiple dimensions at a time for selected reduction functions
These functions now accept a vector dimension argument to specify multiple operating dimensions at a time, as well as the option 'all' to specify all dimensions of an array.

all        min
any        mode
bounds        prod
max        std
mean        sum
median        var


2019b

You can now use a vector dimension argument to query multiple array dimension lengths at a time with the size function.


A quick google search for vecdim shows it also applies to many other functions (zscore, range, quantile, skewness, etc...) but unsure if this is the same implementation as for the ones above.

Nicholas Jankowski <nrjank>
Group Member
Wed 01 Sep 2021 04:27:17 PM UTC, comment #1: 

I'm also marking this as a feature request since it is really a new feature in Matlab, not something that we already have in Octave with reasonable but different behavior.

I expect this should be a fairly easy feature to add.

John W. Eaton <jwe>
Group administrator
Wed 01 Sep 2021 05:35:13 AM UTC, original submission:  

The `size` function can be called in new ways since Matlab R2019b:

> Starting in R2019b, you can also specify dim as a vector of positive integers to query multiple dimension lengths at a time. For example, size(A,[2 3]) returns the lengths of the second and third dimensions of A in the 1-by-2 row vector szdim.


https://www.mathworks.com/help/matlab/ref/size.html


sz = size(A)
szdim = size(A,dim)
szdim = size(A,dim1,dim2,…,dimN)
[sz1,...,szN] = size(___)


This change seems reasonable to me and mostly backward compatible.

Non-existing dimensions get filled up with "1"s, as the example illustates:


>> A = eye (3);
>> size (A, 4,2,3,1)

ans =

     1     3     1     3

>> size (A, [4,2,3,1])

ans =

     1     3     1     3


However this is a very elementary function and Octave should adapt soon.

Kai Torben Ohlhus <siko1056>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51959:  size-diffs.txt added by jwe (4KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by siko1056 (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-07 jwe StatusPatch Reviewed In Progress
    2021-09-30 siko1056 StatusPatch Submitted Patch Reviewed
    2021-09-30 siko1056 Attached File- Added size-diffs-with-bist.patch, #51986
    2021-09-30 siko1056 Attached File#51985 Removed
    2021-09-30 siko1056 Attached File- Added size-diffs-with-bist.patch, #51985
    2021-09-24 jwe Attached File- Added size-diffs.txt, #51959
        StatusConfirmed Patch Submitted
    2021-09-01 jwe Item GroupMatlab Compatibility Feature Request
    2021-09-01 nrjank SummaryFunction `size` changed in Matlab R2019b Many functions should now accept vector dimension argument
    2021-09-01 nrjank Item GroupFeature Request Matlab Compatibility
    2021-09-01 jwe Item GroupMatlab Compatibility Feature Request
    2021-09-01 rik5 Severity4 - Important 3 - Normal

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code