[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #58089] [Feature Request] sum along multiple d
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #58089] [Feature Request] sum along multiple dimensions |
Date: |
Fri, 3 Apr 2020 11:31:16 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko |
Update of bug #58089 (project octave):
Item Group: Incorrect Result => Feature Request
Status: None => Confirmed
Summary: sum along multiple dimensions => [Feature Request]
sum along multiple dimensions
_______________________________________________________
Follow-up Comment #2:
Changing category to Feature Request. This is something that Matlab has added
relatively recently as you point out.
If you really want to use this functionality in your code in the meantime it
wouldn't be that hard to add an m-file to override sum(). Below is an example
which is also attached as sum.m
function s = sum (x, dim)
if (nargin < 1 || nargin > 2)
print_usage ("sum");
endif
if (nargin == 1)
s = builtin ("sum", x);
else
if (! isnumeric (dim) || ! isvector (dim))
error ("sum: DIM must be a numeric scalar or vector");
endif
s = builtin ("sum", x, dim(1));
for i = 2:numel (dim)
s = builtin ("sum", s, dim(i));
endfor
endif
endfunction
(file #48747)
_______________________________________________________
Additional Item Attachment:
File name: sum.m Size:0 KB
<https://savannah.gnu.org/file/sum.m?file_id=48747>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?58089>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #58089] [Feature Request] sum along multiple dimensions,
Rik <=