octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #8864] add smooth3


From: Rik
Subject: [Octave-patch-tracker] [patch #8864] add smooth3
Date: Mon, 18 Jul 2016 22:44:25 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of patch #8864 (project octave):

                  Status:                    None => Done                   
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #6:

I committed your patch to add smooth3 to Octave in this cset
(http://hg.savannah.gnu.org/hgweb/octave/rev/62208397b99e).

Some changes:

1) No validation of nargout.  We check for the correct number of input
arguments, but don't bother to check outputs.  If a user calls a function
which doesn't return enough outputs they will get a message from the
interpreter about that error already.

2) Simplified input processing by using default arguments to function. 
Instead of 


  if (nargin < 2), method = "box"; endif
  if (nargin < 3), sz = 3; endif
  if (nargin < 4), st_dev = .65; endif


I just declared the function as used 


function smoothed_data = smooth3 (data, method = "box", sz = 3, std_dev =
0.65)


3) I tightened up the input validation.  For example, there was no checking
that METHOD was a string before using it in the switch statement which caused
problems when it was a cell.  And originally the input matrix was only tested
for size, but a cell array of the right dimensions would pass so I added
isnumeric


  if (! isnumeric (data) || ndims (data) != 3)
    error ("smooth3: DATA must be a 3-D numeric matrix");


4) I used in-place operators where possible because they are much more
efficient.


<  gaussian3 /= sum (gaussian3(:));  # normalize
---
>  gaussian3 = gaussian3 / sum (gaussian3(:)); ## normalize


5) In the %!demo blocks I used Matlab syntax so that they will run correctly
under Matlab for the compare_plot_demos script.  This meant changing double
quotes to single quotes.

6) I change the %!error tests to be smaller and fit on a single line.  This
was mostly just about being concise and having line lengths less than 80
characters.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8864>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]