changeset 10663:eddb56678a93 octave-forge

Updated tests, DESCRIPTION, etc. for lssa release.
author benjf5
date Thu, 09 Aug 2012 16:08:18 +0000
parents 5a1d6bf38c33
children 574c3439d1d2
files extra/lssa/DESCRIPTION extra/lssa/NEWS extra/lssa/inst/cubicwgt.m extra/lssa/inst/lombcoeff.m extra/lssa/inst/lscomplex.m extra/lssa/inst/lscorrcoeff.m extra/lssa/inst/lsreal.m extra/lssa/inst/lswaveletcoeff.m
diffstat 8 files changed, 80 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/extra/lssa/DESCRIPTION	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/DESCRIPTION	Thu Aug 09 16:08:18 2012 +0000
@@ -1,6 +1,6 @@
 Name: lssa
-Version: 0.1.0
-Date: 2012-07-28
+Version: 0.1.1
+Date: 2012-08-09
 Author: Ben Lewis <benjf5@gmail.com>
 Maintainer: Ben Lewis <benjf5@gmail.com>
 Title: Least squares spectral analysis
--- a/extra/lssa/NEWS	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/NEWS	Thu Aug 09 16:08:18 2012 +0000
@@ -1,4 +1,4 @@
-Welcome to the first release of lssa, 0.1.0
+Welcome to the first release of lssa, 0.1.1
 
 Current status:
  
@@ -18,3 +18,7 @@
     functional; this is an ongoing struggle for me, and if anyone can suggest
     what I might do to improve them, please! By all means, send me an email.
 
+ ** For all the working functions, tests have been written and formatted to
+    Octave coding standards. These tests should pass on any given architecture
+    (there was some question about that previously) and often provide examples
+    of how the function operates. For a few functions, there are demo scripts.
--- a/extra/lssa/inst/cubicwgt.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/cubicwgt.m	Thu Aug 09 16:08:18 2012 +0000
@@ -19,19 +19,22 @@
 ## 1 + ( x ^ 2 * ( 2 x - 3 ) ), assuming x is in [-1,1].
 ## @end deftypefn
 
-%!shared h, m, k
-%! h = 2; m = 0.01;
-%! k = [ 0 , 3 , 1.5, -1, -0.5, -0.25, 0.75 ];
-%!assert( cubicwgt(h), 0 );
-%!assert( cubicwgt(m), 1 + m ^ 2 * ( 2 * m - 3 ));
-%!assert( cubicwgt(k), [ 1.00000   0.00000   0.00000   0.00000   0.50000   0.84375   0.15625], 1E-6);
-%! ## Tests cubicwgt on two scalars and two vectors; cubicwgt will work on any array input.
-
-
-## This function implements the windowing function on page 10 of the doc.
+## This function implements the windowing function on page 10 of the paper.
 ## if t is in [-1,1] then the windowed term is a = 1 + ( |t|^2 * ( 2|t| - 3 )
 ## else the windowed term is 0.
 function a = cubicwgt(s) ## where s is the value to be windowed
   a = abs(s);
   a = ifelse( ( a < 1 ), 1 + ( ( a .^ 2 ) .* ( 2 .* a - 3 ) ), a = 0);
 endfunction
+
+%!test
+%!shared h, m, k
+%! h = 2;
+%! m = 0.01;
+%! k = [ 0 , 3 , 1.5, -1, -0.5, -0.25, 0.75 ];
+%!assert( cubicwgt(h), 0 );
+%!assert( cubicwgt(m), 1 + m ^ 2 * ( 2 * m - 3 ));
+%!assert( cubicwgt(k), [ 1.00000, 0.00000, 0.00000, 0.00000, 0.50000,
+%! 0.84375, 0.15625], 1e-6); 
+%! ## Tests cubicwgt on two scalars and two vectors; cubicwgt will work
+%! ## on any array input. 
\ No newline at end of file
--- a/extra/lssa/inst/lombcoeff.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/lombcoeff.m	Thu Aug 09 16:08:18 2012 +0000
@@ -47,6 +47,6 @@
 %!      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);
+%!assert (lombcoeff (t, x, maxfreq), 1076.77574184435, 5e-10);
+%!assert (lombcoeff (t, x, 3/4*maxfreq), 1226.53572492183, 5e-10);
+%!assert (lombcoeff (t, x, 1/4*maxfreq), 1341.63962181896, 5e-10);
--- a/extra/lssa/inst/lscomplex.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/lscomplex.m	Thu Aug 09 16:08:18 2012 +0000
@@ -23,15 +23,6 @@
 ## @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.400754376933531 - 2.366871097665244i, 1.226663545950135 - 2.243899314661490i, 1.936433327880238 - 1.515538553198501i, 2.125045509991203 - 0.954100898917708i ], 6e-14 );
-
-
 
 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.
@@ -45,3 +36,19 @@
   endfor
 
 endfunction 
+
+%!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.400924546169395 - 2.371555305867469i,
+%!    1.218065147708429 - 2.256125004156890i,
+%!    1.935428592212907 - 1.539488163739336i,
+%!    2.136692292751917 - 0.980532175174563i ], 5e-10 );
\ No newline at end of file
--- a/extra/lssa/inst/lscorrcoeff.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/lscorrcoeff.m	Thu Aug 09 16:08:18 2012 +0000
@@ -68,7 +68,7 @@
 
 endfunction
 
-
+%!test
 %!shared t, p, x, y, z, o, maxfreq
 %! maxfreq = 4 / (2 * pi);
 %! t = linspace (0, 8);
--- a/extra/lssa/inst/lsreal.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/lsreal.m	Thu Aug 09 16:08:18 2012 +0000
@@ -26,13 +26,6 @@
 ## @seealso{lscomplex}
 ## @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));
-%!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)
   ## the R function runs the following command:
   ## nureal( double X, double Y, int min(X,Y), int ncoeff, int noctave, double omegamax, complex rp)
@@ -65,6 +58,22 @@
     o = o .* od;
   endfor
   
-  ##  transform = rp;
+endfunction
 
-endfunction
+%!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 ) );
+%!assert (lsreal (t,x,maxfreq,2,2),
+%!  [-1.68275915310663 + 4.70126183846743i,
+%!    1.93821553170889 + 4.95660209883437i,
+%!    4.38145452686697 + 2.14403733658600i,
+%!    5.27425332281147 - 0.73933440226597i ],
+%!  5e-10)
+%! # In the assert here, I've got an error bound large enough to catch
+%! # individual system errors which would present no real issue. 
\ No newline at end of file
--- a/extra/lssa/inst/lswaveletcoeff.m	Thu Aug 09 12:58:55 2012 +0000
+++ b/extra/lssa/inst/lswaveletcoeff.m	Thu Aug 09 16:08:18 2012 +0000
@@ -53,3 +53,25 @@
   coeff = ifelse( s != 0 , sum( wgt( ( rx - t ) .* so) .* exp( i .* o .* ( rx - t ) ) .* ry ) ./ s , 0 );
   
 endfunction
+
+%!test
+%!shared t, p, x, y, z, 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));
+%! y = - x;
+%! p = linspace (0, 8, 500);
+%! z = (2 .* sin (maxfreq .* p) + 
+%!      3 .* sin ((3/4) * maxfreq .* p) - 
+%!      0.5 .* sin ((1/4) * maxfreq .* p) - 
+%!      0.2 .* cos (maxfreq .* p) + 
+%!      cos ((1/4) * maxfreq .* p));
+%! o = [maxfreq , (3/4 * maxfreq) , (1/4 * maxfreq)];
+%!assert (lswaveletcoeff (t, x, 0.5, maxfreq), 0.383340407638780 +
+%!  2.385251997545446i , 5e-10);
+%!assert (lswaveletcoeff (t, y, 3.3, 3/4 * maxfreq), -2.35465091096084 +
+%!  1.01892561714824i, 5e-10);
\ No newline at end of file