From: <be...@us...> - 2012-08-03 15:19:47
|
Revision: 10804 http://octave.svn.sourceforge.net/octave/?rev=10804&view=rev Author: benjf5 Date: 2012-08-03 15:19:41 +0000 (Fri, 03 Aug 2012) Log Message: ----------- Tests, having been rewritten to match the manual, still broken. Modified Paths: -------------- trunk/octave-forge/extra/lssa/inst/lombcoeff.m trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m trunk/octave-forge/extra/lssa/inst/lscomplex.m trunk/octave-forge/extra/lssa/inst/lscorrcoeff.m trunk/octave-forge/extra/lssa/inst/lsreal.m trunk/octave-forge/extra/lssa/inst/lsrealwavelet.m Modified: trunk/octave-forge/extra/lssa/inst/lombcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lombcoeff.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lombcoeff.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -23,14 +23,14 @@ ## @end deftypefn %!test -%! shared t, x, o, maxfreq +%!shared t, x, o, maxfreq; %! maxfreq = 4 / ( 2 * pi ); -%! t = linspace(0,8); x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) -%! - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) -%! + cos((1/4)*maxfreq.*t)); o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; -%!assert( lombcoeff(t,x,o(1)),10788.9848389923,5e-10 ); -%!assert( lombcoeff(t,x,o(2)),12352.6413413457,5e-10 ); -%!assert( lombcoeff(t,x,o(3)),13673.4098969780,5e-10 ); +%! t = linspace(0,8); +%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); +%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; +%!assert( lombcoeff(t,x,maxfreq),10788.9848389923,5e-10 ); +%!assert( lombcoeff(t,x,3/4*maxfreq),12352.6413413457,5e-10 ); +%!assert( lombcoeff(t,x,1/4*maxfreq),13673.4098969780,5e-10 ); function coeff = lombcoeff(T, X, o) Modified: trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -22,6 +22,17 @@ ## ## @end deftypefn +%!test +%!shared t, x, o, maxfreq; +%! maxfreq = 4 / ( 2 * pi ); +%! t = linspace(0,8); +%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); +%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; +%!assert( lombnormcoeff(t,x,o(1)),63.3294946603949,5e-10 ); +%!assert( lombnormcoeff(t,x,o(2)),73.2601360674868,5e-10 ); +%!assert( lombnormcoeff(t,x,o(3)),53.0799752083903,5e-10 ); + + function coeff = lombnormcoeff(T,X,omega) tau = atan2( sum( sin( 2.*omega.*T)), sum(cos(2.*omega.*T))) / 2; coeff = ( ( sum ( X .* cos( omega .* T - tau ) ) .^ 2 ./ sum ( cos ( omega .* T - tau ) .^ 2 ) Modified: trunk/octave-forge/extra/lssa/inst/lscomplex.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lscomplex.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lscomplex.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -24,9 +24,12 @@ ## @end deftypefn %!test -%! shared t, x, o, maxfreq -%! maxfreq = 4 / ( 2 * pi ); t = [0:0.008:8]; x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t)- 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; -%! assert( lscomplex(t,x,maxfreq,2,2), [-0.400754376933531 - 2.366871097665244i, 1.226663545950135 - 2.243899314661490i, 1.936433327880238 - 1.515538553198501i, 2.125045509991203 - 0.954100898917708i ], 6e-14 ); +%!shared t, x, o, maxfreq +%! maxfreq = 4 / ( 2 * pi ); +%! t = [0:0.008:8]; +%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t)- 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); +%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; +%!assert( lscomplex(t,x,maxfreq,2,2), [-0.400754376933531 - 2.366871097665244i, 1.226663545950135 - 2.243899314661490i, 1.936433327880238 - 1.515538553198501i, 2.125045509991203 - 0.954100898917708i ], 6e-14 ); Modified: trunk/octave-forge/extra/lssa/inst/lscorrcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lscorrcoeff.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lscorrcoeff.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -50,7 +50,6 @@ endif ## The first solution that comes to mind is admittedly slightly ugly and has a data footprint of O(2n) ## but it is vectorised. - mask = ; mask = find( ( abs( x1 - t ) * so ) < wgtrad ); rx1 = x1(mask); ## I've kept the variable names from the R function here ry1 = y1(mask); ## Needs to have a noisy error if length(y1) != length(x1) -- add this! @@ -62,8 +61,7 @@ ## in particular to maintain an exact duplicate of the R function. s = sum( wgt( ( rx1 - t ) .* so ) ) * sum( wgt( ( rx2 - t ) .* so ) ); if s != 0 - coeff = sum( wgt((rx1-t).*so).*exp(i*o.*rx1).*ry1) * - sum(wgt((rx2-t).*so).*exp(i*o.*rx2).*conj(ry2)) / s; + coeff = sum( wgt((rx1-t).*so).*exp(i*o.*rx1).*ry1) * sum(wgt((rx2-t).*so).*exp(i*o.*rx2).*conj(ry2)) / s; else coeff = 0; endif Modified: trunk/octave-forge/extra/lssa/inst/lsreal.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lsreal.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lsreal.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -29,7 +29,7 @@ %! maxfreq = 4 / ( 2 * pi ); %! t = linspace(0,8); %! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); -%! assert(lsreal(t,x,maxfreq,2,2),[-1.68275915310663 + 4.70126183846743i, 1.93821553170889 + 4.95660209883437i, 4.38145452686697 + 2.14403733658600i, 5.27425332281147 - 0.73933440226597i],6e-14) +%!assert(lsreal(t,x,maxfreq,2,2),[-1.68275915310663 + 4.70126183846743i, 1.93821553170889 + 4.95660209883437i, 4.38145452686697 + 2.14403733658600i, 5.27425332281147 - 0.73933440226597i],6e-14) %! #In the assert here, I've got an error bound large enough to catch individual system errors which would present no real issue. function transform = lsreal( t, x, omegamax, ncoeff, noctave) Modified: trunk/octave-forge/extra/lssa/inst/lsrealwavelet.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lsrealwavelet.m 2012-08-03 12:22:15 UTC (rev 10803) +++ trunk/octave-forge/extra/lssa/inst/lsrealwavelet.m 2012-08-03 15:19:41 UTC (rev 10804) @@ -14,7 +14,7 @@ ## this program; if not, see <http://www.gnu.org/licenses/>. ##-*- texinfo -*- -## @deffun {Function File} {t =} lsrealwavelet( @var{time}, @var{mag}, +## @deftypefn {Function File} {t =} lsrealwavelet( @var{time}, @var{mag}, ## @var{maxfreq}, @var{coefficients}, @var{octaves}, @var{time_min}, ## @var{time_max}, @var{min_window_count} ) ## @@ -26,7 +26,7 @@ ## ## @seealso lscomplexwavelet lswaveletcoeff lscorrcoeff ## -## @end deffun +## @end deftypefn function transform = lsrealwavelet(T, X, maxfreq, ncoeff, noctave, t_min, t_max, minimum_window_number ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |