On Tue, Jul 3, 2012 at 10:50 AM, Carnë Draug <carandraug+...@gmail.com> wrote:
> Hi
>
> I was looking at the built-in forums of sourceforge and found the
> following reported 2 years ago (these forums have since been hidden
> and blocked to prevent posting). Could someone please review the
> following?

Hey Carnë, I've taken a look at this function and run some test cases
against it, I do not think there is a (serious) bug here, see below.

> Reported by jmiles1: possible typo in main/signal/inst/fir2.m:
>
> ## make sure grid is big enough for the window
> if 2*grid_n < n+1, grid_n = 2^nextpow2(n+1); endif
>
> should probably be
>
> ## make sure grid is big enough for the window
> if grid_n < n+1, grid_n = 2^nextpow2(n+1); endif
>
> Otherwise it looks like there's a range of grid sizes between n/2 and
> n that will be smaller than n, and generate an overlapped impulse
> response in line 122. Apologies in advance if this was the intent, but
> it definitely doesn't jibe with the comment in line 29.

The comment is surely not clear about what "big enough" means, but the
test for 2*grid_n < n+1 is correct when compared with the rest of the
function as well as comparing the ML fir2 help text [1]: "npt must be
greater than 1/2 the filter order (npt>n/2)".

[1] http://www.mathworks.com/help/toolbox/signal/ref/fir2.html

Line 105 interpolates the input to a length (grid_n+1) vector, and
lines 111 and 116 replicate this for even spectral symmetry
(2*grid_n), and this is the length that must be >= n+1.

The only thing that is not clear to me is whether this matches ML
behavior, and whether we care, e.g. if the caller passes in a 4th arg
too small, does ML generate an error or silently make it larger like
this line 29 does?

-- 
mike

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to