|
From: <be...@us...> - 2012-07-05 14:12:08
|
Revision: 10732
http://octave.svn.sourceforge.net/octave/?rev=10732&view=rev
Author: benjf5
Date: 2012-07-05 14:11:58 +0000 (Thu, 05 Jul 2012)
Log Message:
-----------
Working on tests; they are all works in progress.
Modified Paths:
--------------
trunk/octave-forge/extra/lssa/lombcoeff.m
trunk/octave-forge/extra/lssa/lscomplex.m
trunk/octave-forge/extra/lssa/lsreal.m
Modified: trunk/octave-forge/extra/lssa/lombcoeff.m
===================================================================
--- trunk/octave-forge/extra/lssa/lombcoeff.m 2012-07-05 13:51:57 UTC (rev 10731)
+++ trunk/octave-forge/extra/lssa/lombcoeff.m 2012-07-05 14:11:58 UTC (rev 10732)
@@ -22,7 +22,16 @@
## @seealso{lombnormcoeff}
## @end deftypefn
+%!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)) = );
+%! assert( lombcoeff(t,x,o(2)) = );
+%! assert( lombcoeff(t,x,o(3)) = );
+
function coeff = lombcoeff(T, X, o)
theta = atan2(sum(sin(2 .* o .* T )), sum(cos(2.*o.*T)))/ (2 * o );
coeff = ( sum(X .* cos(o .* T - tau))**2)/(sum(cos(o.*T-tau).**2)) +
Modified: trunk/octave-forge/extra/lssa/lscomplex.m
===================================================================
--- trunk/octave-forge/extra/lssa/lscomplex.m 2012-07-05 13:51:57 UTC (rev 10731)
+++ trunk/octave-forge/extra/lssa/lscomplex.m 2012-07-05 14:11:58 UTC (rev 10732)
@@ -23,7 +23,13 @@
## @seealso{lsreal}
## @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.40075 - 2.36687i , 1.22666 - 2.24390i , 1.93643 - 1.51554i , 2.12505 - 0.95410i ] );
+
+
function transform = lscomplex( t , x , omegamax , ncoeff , noctave )
n = length(t); ## VECTOR ONLY, and since t and x have the same number of entries, there's no problem.
transform = zeros(1,ncoeff*noctave);
Modified: trunk/octave-forge/extra/lssa/lsreal.m
===================================================================
--- trunk/octave-forge/extra/lssa/lsreal.m 2012-07-05 13:51:57 UTC (rev 10731)
+++ trunk/octave-forge/extra/lssa/lsreal.m 2012-07-05 14:11:58 UTC (rev 10732)
@@ -23,6 +23,12 @@
##
## @end deftypefn
+%!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 ];
+
function transform = lsreal( t, x, omegamax, ncoeff, noctave)
## the R function runs the following command:
## nureal( double X, double Y, int min(X,Y), int ncoeff, int noctave, double omegamax, complex rp)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|