From: <mtm...@us...> - 2012-07-28 00:40:26
|
Revision: 10778 http://octave.svn.sourceforge.net/octave/?rev=10778&view=rev Author: mtmiller Date: 2012-07-28 00:40:20 +0000 (Sat, 28 Jul 2012) Log Message: ----------- Fix rceps to work correctly on odd-length inputs Reported by Sergei Steshenko on the mailing list. Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/rceps.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-07-26 23:07:34 UTC (rev 10777) +++ trunk/octave-forge/main/signal/NEWS 2012-07-28 00:40:20 UTC (rev 10778) @@ -4,6 +4,8 @@ signal-1.1.4 Release Date: 2012-XX-XX Release Manager: =============================================================================== + ** The function `rceps' was fixed to work correctly with odd-length inputs. + ** The following functions are new: movingrms schtrig clustersegment Modified: trunk/octave-forge/main/signal/inst/rceps.m =================================================================== --- trunk/octave-forge/main/signal/inst/rceps.m 2012-07-26 23:07:34 UTC (rev 10777) +++ trunk/octave-forge/main/signal/inst/rceps.m 2012-07-28 00:40:20 UTC (rev 10778) @@ -34,18 +34,22 @@ if (nargin != 1) print_usage; end - y = real(ifft(log(abs(fft(x))))); + f = abs(fft(x)); + if (any (f == 0)) + error ("rceps: the spectrum of x contains zeros, unable to compute real cepstrum"); + endif + y = real(ifft(log(f))); if nargout == 2 n=length(x); if rows(x)==1 if rem(n,2)==1 - ym = [y(1), 2*y(2:n/2), zeros(1,n/2-1)]; + ym = [y(1), 2*y(2:n/2+1), zeros(1,n/2)]; else ym = [y(1), 2*y(2:n/2), y(n/2+1), zeros(1,n/2-1)]; endif else if rem(n,2)==1 - ym = [y(1,:); 2*y(2:n/2,:); zeros(n/2-1,columns(y))]; + ym = [y(1,:); 2*y(2:n/2+1,:); zeros(n/2,columns(y))]; else ym = [y(1,:); 2*y(2:n/2,:); y(n/2+1,:); zeros(n/2-1,columns(y))]; endif @@ -77,6 +81,13 @@ %! assert(yt.', y, tol); %! assert(xmt.', xm, tol); +%% Test that an odd-length input produces an odd-length output +%!test +%! x = randn(33, 4); +%! [y, xm] = rceps(x); +%! assert(size(y) == size(x)); +%! assert(size(xm) == size(x)); + %!demo %! f0=70; Fs=10000; # 100 Hz fundamental, 10kHz sampling rate %! a=real(poly(0.985*exp(1i*pi*[0.1, -0.1, 0.3, -0.3]))); # two formants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mtm...@us...> - 2012-08-05 23:05:42
|
Revision: 10831 http://octave.svn.sourceforge.net/octave/?rev=10831&view=rev Author: mtmiller Date: 2012-08-05 23:05:36 +0000 (Sun, 05 Aug 2012) Log Message: ----------- residued: fix failing test reported at bug #3553263 (Debian bug #664694). Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/residued.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-05 21:22:05 UTC (rev 10830) +++ trunk/octave-forge/main/signal/NEWS 2012-08-05 23:05:36 UTC (rev 10831) @@ -4,6 +4,8 @@ signal-1.1.4 Release Date: 2012-XX-XX Release Manager: =============================================================================== + ** Fixed failing test for the function `residued'. + ** The function `rceps' was fixed to work correctly with odd-length inputs. ** The following functions are new: Modified: trunk/octave-forge/main/signal/inst/residued.m =================================================================== --- trunk/octave-forge/main/signal/inst/residued.m 2012-08-05 21:22:05 UTC (rev 10830) +++ trunk/octave-forge/main/signal/inst/residued.m 2012-08-05 23:05:36 UTC (rev 10831) @@ -157,5 +157,9 @@ %!test %! B=[1 0 0 0 1]; A=[1 0 0 0 -1]; %! [r,p,f,m] = residued(B,A); -%! assert({r,p,f,m},{[-j/2;j/2;1/2;-1/2],[-j;j;1;-1],1,[1;1;1;1]},100*eps); +%! [~,is] = sort(angle(p)); +%! assert(r(is),[-1/2;-j/2;1/2;j/2],100*eps); +%! assert(p(is),[-1;-j;1;j],100*eps); +%! assert(f,1,100*eps); +%! assert(m,[1;1;1;1],100*eps); % Verified in maxima: ratsimp(%I/2/(1-%I * d) - %I/2/(1+%I * d)); etc. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mtm...@us...> - 2012-08-09 02:00:03
|
Revision: 10846 http://octave.svn.sourceforge.net/octave/?rev=10846&view=rev Author: mtmiller Date: 2012-08-09 01:59:56 +0000 (Thu, 09 Aug 2012) Log Message: ----------- fir2: fix treatment of optional grid size argument for ML compatibility Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/fir2.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-09 01:56:37 UTC (rev 10845) +++ trunk/octave-forge/main/signal/NEWS 2012-08-09 01:59:56 UTC (rev 10846) @@ -4,6 +4,8 @@ signal-1.1.4 Release Date: 2012-XX-XX Release Manager: =============================================================================== + ** Improved Matlab compability for the function `fir2'. + ** Fixed failing test for the function `residued'. ** The function `rceps' was fixed to work correctly with odd-length inputs. Modified: trunk/octave-forge/main/signal/inst/fir2.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir2.m 2012-08-09 01:56:37 UTC (rev 10845) +++ trunk/octave-forge/main/signal/inst/fir2.m 2012-08-09 01:59:56 UTC (rev 10846) @@ -26,7 +26,7 @@ ## m: magnitude at band edges ## m is a vector of length(f) ## grid_n: length of ideal frequency response function -## defaults to 512, should be a power of 2 bigger than n +## defaults to 512, should be a power of 2 bigger than n/2 ## ramp_n: transition width for jumps in filter response ## defaults to grid_n/20; a wider ramp gives wider transitions ## but has better stopband characteristics. @@ -63,21 +63,30 @@ (nargin>5 && (length(grid_n)>1 || length(ramp_n)>1)) usage("grid_n and ramp_n must be integers"); endif - if nargin < 4, grid_n=512; endif - if nargin < 5, ramp_n=grid_n/20; endif + if nargin < 4, grid_n=[]; endif + if nargin < 5, ramp_n=[]; endif ## find the window parameter, or default to hamming w=[]; - if length(grid_n)>1, w=grid_n; grid_n=512; endif - if length(ramp_n)>1, w=ramp_n; ramp_n=grid_n/20; endif + if length(grid_n)>1, w=grid_n; grid_n=[]; endif + if length(ramp_n)>1, w=ramp_n; ramp_n=[]; endif if nargin < 6, window=w; endif if isempty(window), window=hamming(n+1); endif if !isreal(window) || ischar(window), window=feval(window, n+1); endif if length(window) != n+1, usage("window must be of length n+1"); endif - ## make sure grid is big enough for the window - if 2*grid_n < n+1, grid_n = 2^nextpow2(n+1); endif + if isempty (grid_n), grid_n = 512; endif + ## ML behavior appears to always round the grid size up to a power of 2 + grid_n = 2 ^ nextpow2 (grid_n); + + ## Error out if the grid size is not big enough for the window + if 2*grid_n < n+1 + error ("fir2: grid size must be greater than half the filter order"); + endif + + if isempty (ramp_n), ramp_n = fix (grid_n / 20); endif + ## Apply ramps to discontinuities if (ramp_n > 0) ## remember original frequency points prior to applying ramps @@ -125,6 +134,17 @@ endif endfunction +%% Test that the grid size is rounded up to the next power of 2 +%!test +%! f = [0 0.6 0.6 1]; m = [1 1 0 0]; +%! b9 = fir2 (30, f, m, 9); +%! b16 = fir2 (30, f, m, 16); +%! b17 = fir2 (30, f, m, 17); +%! b32 = fir2 (30, f, m, 32); +%! assert ( isequal (b9, b16)) +%! assert ( isequal (b17, b32)) +%! assert (~isequal (b16, b17)) + %!demo %! f=[0, 0.3, 0.3, 0.6, 0.6, 1]; m=[0, 0, 1, 1/2, 0, 0]; %! [h, w] = freqz(fir2(100,f,m)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mtm...@us...> - 2012-08-15 14:41:04
|
Revision: 10879 http://octave.svn.sourceforge.net/octave/?rev=10879&view=rev Author: mtmiller Date: 2012-08-15 14:40:58 +0000 (Wed, 15 Aug 2012) Log Message: ----------- pei_tseng_notch: fix failing tests reported at bug #3553263 (Debian bug #664694). Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/pei_tseng_notch.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-15 13:41:35 UTC (rev 10878) +++ trunk/octave-forge/main/signal/NEWS 2012-08-15 14:40:58 UTC (rev 10879) @@ -9,7 +9,9 @@ column), the default values for grid_n and ramp_n, and returning an error when invalid values are used (instead of silently adjusting them). - ** Fixed failing test for the function `residued'. + ** Fixed failing tests for the following functions: + pei_tseng_notch + residued ** The function `rceps' was fixed to work correctly with odd-length inputs. Modified: trunk/octave-forge/main/signal/inst/pei_tseng_notch.m =================================================================== --- trunk/octave-forge/main/signal/inst/pei_tseng_notch.m 2012-08-15 13:41:35 UTC (rev 10878) +++ trunk/octave-forge/main/signal/inst/pei_tseng_notch.m 2012-08-15 14:40:58 UTC (rev 10879) @@ -91,7 +91,7 @@ %! [b, a] = pei_tseng_notch ( 50 / sf2, 2 / sf2 ); %! filtered = filter ( b, a, data ); %! damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); -%! assert ( damp_db, [ -3 -251.9 -3 ], 0.1 ) +%! assert ( damp_db, [ -3 -251.9 -3 ], -0.1 ) %!test %! ##1Hz bandwidth @@ -100,7 +100,7 @@ %! [b, a] = pei_tseng_notch ( 50 / sf2, 1 / sf2 ); %! filtered = filter ( b, a, data ); %! damp_db = 20 * log10 ( max ( filtered ( end - 1000 : end, : ) ) ); -%! assert ( damp_db, [ -3 -240.4 -3 ], 0.1 ) +%! assert ( damp_db, [ -3 -240.4 -3 ], -0.1 ) %!demo %! sf = 800; sf2 = sf/2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-08-29 02:45:19
|
Revision: 10925 http://octave.svn.sourceforge.net/octave/?rev=10925&view=rev Author: carandraug Date: 2012-08-29 02:45:12 +0000 (Wed, 29 Aug 2012) Log Message: ----------- xcorr2: remove old coeff option code, replace by new method Modified Paths: -------------- trunk/octave-forge/main/signal/NEWS trunk/octave-forge/main/signal/inst/xcorr2.m Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-08-27 13:28:45 UTC (rev 10924) +++ trunk/octave-forge/main/signal/NEWS 2012-08-29 02:45:12 UTC (rev 10925) @@ -18,8 +18,8 @@ ** Bugfix in `xcorr2' introduced in 1.1.2 that would not accept "none" as scale option. - ** `xcorr2' accepts a new scale option, "norm", to return the normalized - cross correlation. + ** `xcorr2' scaling option "coeff" was changed to return the normalized + cross-correlation. ** The following functions are new: movingrms schtrig clustersegment Modified: trunk/octave-forge/main/signal/inst/xcorr2.m =================================================================== --- trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-27 13:28:45 UTC (rev 10924) +++ trunk/octave-forge/main/signal/inst/xcorr2.m 2012-08-29 02:45:12 UTC (rev 10925) @@ -41,10 +41,6 @@ ## element. ## ## @item "coeff" -## Normalizes the sequence dividing by the max of the cross-correlation, so that -## the largest cross-correlation element is 1. -## -## @item "norm" ## Returns the normalized cross-correlation. ## @end table ## @@ -75,7 +71,7 @@ ## bias routines by Dave Cogdell (cog...@as...) ## optimized by Paul Kienzle (pki...@us...) - ## norm routine by Carnë Draug (car...@gm...) + ## coeff routine by Carnë Draug (car...@gm...) switch lower (biasflag) case {"none"} ## do nothing, it's all done @@ -94,15 +90,10 @@ c = c./bias; case {"coeff"} - c = c/max(c(:))'; - - case {"norm"} - ## FIXME maybe these conversions for double can be removed when - ## https://savannah.gnu.org/bugs/?37199 gets fixed? a = double (a); b = double (b); a = conv2 (a.^2, ones (size (b))); - b = dot (b(:), b(:)); + b = sumsq (b(:)); c(:,:) = c(:,:) ./ sqrt (a(:,:) * b); otherwise @@ -110,7 +101,7 @@ endswitch endfunction -%!test +%!test # basic usage %! a = magic (5); %! b = [6 13 22; 10 18 23; 8 15 23]; %! c = [391 807 519 391 473 289 120 @@ -121,3 +112,22 @@ %! 473 1006 1643 1457 946 347 108 %! 242 539 850 477 374 129 54]; %! assert (xcorr2 (a, b), c); + +%!shared a, b, c, row_shift, col_shift +%! row_shift = 18; +%! col_shift = 20; +%! a = randi (255, 30, 30); +%! b = a(row_shift-10:row_shift, col_shift-7:col_shift); +%! c = xcorr2 (a, b, "coeff"); +%!assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # should return exact coordinates +%! m = rand (size (b)) > 0.5; +%! b(m) = b(m) * 0.95; +%! b(!m) = b(!m) * 1.05; +%! c = xcorr2 (a, b, "coeff"); +%!assert (nthargout ([1 2], @find, c == max (c(:))), {row_shift, col_shift}); # even with some small noise, should return exact coordinates + +%!test # coeff of autocorrelation must be same as negavtive of correlation by additive inverse +%! a = 10 * randn (100, 100); +%! auto = xcorr2 (a, "coeff"); +%! add_in = xcorr2 (a, -a, "coeff"); +%! assert ([min(auto(:)), max(auto(:))], -[max(add_in(:)), min(add_in(:))]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-21 13:22:21
|
Revision: 11066 http://octave.svn.sourceforge.net/octave/?rev=11066&view=rev Author: carandraug Date: 2012-09-21 13:22:15 +0000 (Fri, 21 Sep 2012) Log Message: ----------- signal: bump version for release Modified Paths: -------------- trunk/octave-forge/main/signal/DESCRIPTION trunk/octave-forge/main/signal/NEWS Modified: trunk/octave-forge/main/signal/DESCRIPTION =================================================================== --- trunk/octave-forge/main/signal/DESCRIPTION 2012-09-21 13:18:41 UTC (rev 11065) +++ trunk/octave-forge/main/signal/DESCRIPTION 2012-09-21 13:22:15 UTC (rev 11066) @@ -1,11 +1,12 @@ Name: Signal -Version: 1.1.3 -Date: 2012-05-12 +Version: 1.2.0 +Date: 2012-09-21 Author: various authors Maintainer: Octave-Forge community <oct...@li...> Title: Signal Processing. Description: Signal processing tools, including filtering, windowing and display functions. Depends: octave (>= 3.6.0), optim (>= 1.0.0), specfun, control (>= 2.2.3), general (>= 1.3.2) +## depends on specfun because of ellipke. When it moves to octave core, dependency can be removed Autoload: no License: GPLv3+, public domain Url: http://octave.sf.net Modified: trunk/octave-forge/main/signal/NEWS =================================================================== --- trunk/octave-forge/main/signal/NEWS 2012-09-21 13:18:41 UTC (rev 11065) +++ trunk/octave-forge/main/signal/NEWS 2012-09-21 13:22:15 UTC (rev 11066) @@ -1,7 +1,7 @@ Summary of important user-visible changes for releases of the signal package =============================================================================== -signal-1.1.4 Release Date: 2012-XX-XX Release Manager: +signal-1.2.0 Release Date: 2012-09-21 Release Manager: Carnë Draug =============================================================================== ** Improved Matlab compability for the function `fir2'. This changes include This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |