bugGNU Octave - Bugs: bug #66440, have structfun accept multiple...

 
 

bug #66440: have structfun accept multiple structures as argument

Submitter:  Muhali <muhali>
Submitted:  Thu 14 Nov 2024 12:48:40 PM UTC
   
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  None 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
   

Thu 14 Nov 2024 01:52:18 PM UTC, comment #1: 

this was the first time i realized structfun didn't work like cellfun that way.  strange design choice, but that does match matlab behavior and it's been that way for ~20yrs.  Looking at how the current function works, you can always call cellfun(@fun, struct2cell(A), struct2cell(B),...) as a workaround.  obviously the structs will have to 'match' according to whatever @fun wants.

Since the current struct2fun doesn't accept anything but name/value pairs after the struct input, in theory an extension could be written that allows multiple struct inputs, and then the first char/string input is assumed to be the start of the name-value pairs. How much input checking to do on the structs (making sure they match) etc would be a decision to make. I guess it could stop at them having the same fieldnames, and any other checks would be dependent on fun.

updating metadata and marking as a marking this as low severity.  structfun is an m-file, so anyone wanting to take a stab at a patch to implement this is welcome to do so even if it wouldn't make it into core octave.

Nicholas Jankowski <nrjank>
Group Member
Thu 14 Nov 2024 12:48:40 PM UTC, original submission:  

It would be nice to have structfun accept more than one argument, similar to cellfun. It should work along the following lines:

a.a = 1 ; a.b = 0 ;
b.a = 0 ; b.b = 1 ;
structfun ("atan2", a, b) = cellfun ("atan2", {a.a, a.b}, {b.a, b.b}) ;


Muhali <muhali>

 

(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 nrjank (Posted a comment)
  • -email is unavailable- added by muhali (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-11-14 nrjank CategoryNone Octave Function
        Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code