patchGNU Octave - Patches: patch #10119, functions sumsqr, sumabs, meansqr,...

 
 

patch #10119: functions sumsqr, sumabs, meansqr, meanabs

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Fri 08 Oct 2021 03:51:03 PM UTC
 
Category:  Core : new function Priority:  5 - Normal
Status:  In Progress Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Fri 08 Oct 2021 04:04:06 PM UTC, comment #1: 

looking at matlab, these functions reside in the neural net / deep learning toolbox. sumsq is in core Octave /scripts/general and meansq is in /scripts/statistics. those belonging to core octave makes me think these should as well despite where they live in matlab.  but not sure about exact location.

attached is a patch that adds it to /scripts/statistics, along with changes to NEWS, etc.  if it would be better placed somewhere else, that's an easy change.  alternatively, it could probably be added to a package instead.

(file #52076)

Nicholas Jankowski <nrjank>
Project Member
Fri 08 Oct 2021 03:51:03 PM UTC, original submission:  

attached are matlab compatible implementations of the functions sumsqr, sumabs, meansqr, and meanabs.  they are all fairly similar in behavior and were introduced in matlab <2010.  After some input handling, they all just call elementwise sqr or abs followed by sum or mean over all elements to return a scalar, skipping over anything failing an isfinite() test.

I noticed there are sumsq and meansq functions that were probably introduced a long time ago that are not compatible with the matlab sumsqr and meansqr functions. their behavior is different enough it's probably worth keeping the separate functions rather than just modifying the octave functions, since the names don't match anyway. (similar to what was done with repelem and repelems).

Of note these functions can handle numeric, char, and logical inputs, as well as arbitrarily shaped cell arrays of the same. 

I did verify that these functions work with complex inputs, whereas the matlab functions error for any complex valued inputs, and Octave's meansq & sumsq functions produce odd results with complex values. (meansq appears to ignore complex numbers, sumsq appears to apply sum((abs(Z))^2) )

will generate and a patch once i have a number.

Nicholas Jankowski <nrjank>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52076:  patch10119_new_summean_fns.diff added by nrjank (21KiB - application/octet-stream)
file #52072:  sumsqr.m added by nrjank (4KiB - text/plain - Matlab compatible functions)
file #52073:  meanabs.m added by nrjank (5KiB - text/plain - Matlab compatible functions)
file #52074:  sumabs.m added by nrjank (4KiB - text/plain - Matlab compatible functions)
file #52075:  meansqr.m added by nrjank (5KiB - text/plain - Matlab compatible functions)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (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 logged-in users can vote.

     

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-10-26 nrjank StatusDone In Progress
    2021-10-26 nrjank StatusIn Progress Done
    2021-10-08 nrjank Attached File- Added patch10119_new_summean_fns.diff, #52076
    2021-10-08 nrjank Attached File- Added sumsqr.m, #52072
        Attached File- Added meanabs.m, #52073
        Attached File- Added sumabs.m, #52074
        Attached File- Added meansqr.m, #52075

    Back to the top


    Powered by Savane 3.9