From: <be...@us...> - 2012-05-26 01:07:14
|
Revision: 10523 http://octave.svn.sourceforge.net/octave/?rev=10523&view=rev Author: benjf5 Date: 2012-05-26 01:07:07 +0000 (Sat, 26 May 2012) Log Message: ----------- Written complex function, updated others for lssa. Modified Paths: -------------- trunk/octave-forge/extra/lssa/lscorrcoeff.m trunk/octave-forge/extra/lssa/lsreal.m trunk/octave-forge/extra/lssa/lswaveletcoeff.m Added Paths: ----------- trunk/octave-forge/extra/lssa/lscomplex.m Added: trunk/octave-forge/extra/lssa/lscomplex.m =================================================================== --- trunk/octave-forge/extra/lssa/lscomplex.m (rev 0) +++ trunk/octave-forge/extra/lssa/lscomplex.m 2012-05-26 01:07:07 UTC (rev 10523) @@ -0,0 +1,39 @@ +## Copyright (C) 2012 Benjamin Lewis <be...@gm...> +## +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 2 of the License, or (at your option) any later +## version. +## +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. +## +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {t =} lscomplex ( time, mag, maxfreq, numcoeff, numoctaves) +## +## Return the complex least-squares transform of the (@var{time},@var{mag}) +## series, considering frequencies up to @var{maxfreq}, over @var{numoctaves} +## octaves and @var{numcoeff} coefficients. +## +## @end deftypefn + + +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. + n1 = 1 / n; + transform = zeros(1,ncoeff*noctave); + o = omegamax; + omul = 2 ^ ( - 1 / ncoeff ); + for iter = 1:ncoeff*noctave + ot = o .* t; + transform(iter) = sum( ( cos(ot) .- ( sin(ot) .* i ) ) .* x ); ## See the paper for the expression + o *= omul; ## To advance the transform to the next coefficient in the octave + endfor + transform .* n1; + +endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/lssa/lscorrcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/lscorrcoeff.m 2012-05-25 23:14:13 UTC (rev 10522) +++ trunk/octave-forge/extra/lssa/lscorrcoeff.m 2012-05-26 01:07:07 UTC (rev 10523) @@ -14,9 +14,9 @@ ## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {c =} nucorrcoeff (abc1, ord1, abc2, ord2, time, freq) -## @deftypefnx {Function File} {c =} nucorrcoeff (abc1, ord1, abc2, ord2, time, freq, window) -## @deftypefnx {Function File} {c =} nucorrcoeff (abc1, ord1, abc2, ord2, time, freq, window, winradius) +## @deftypefn {Function File} {c =} lscorrcoeff (abc1, ord1, abc2, ord2, time, freq) +## @deftypefnx {Function File} {c =} lscorrcoeff (abc1, ord1, abc2, ord2, time, freq, window) +## @deftypefnx {Function File} {c =} lscorrcoeff (abc1, ord1, abc2, ord2, time, freq, window, winradius) ## ## Return the coefficient of the wavelet correlation of time ## series (@var{abc1}, @var{ord1}) and (@var{abc2}, @var{ord2}). @@ -31,13 +31,13 @@ %! x = 1:10; %! y = sin(x); %! z = cos(x); -%! a = nucorrcoeff(x,y,x,z,0.5,0.9) +%! a = lscorrcoeff(x,y,x,z,0.5,0.9) %! ## This generates the correlation coefficient at time 0.5 and circular freq. 0.9 ## nucorrcoeff, computes a coefficient of the wavelet correlation of two time series -function coeff = nucorrcoeff(x1, y1, x2, y2, t, o, wgt = @cubicwgt, wgtrad = 1) +function coeff = lscorrcoeff(x1, y1, x2, y2, t, o, wgt = @cubicwgt, wgtrad = 1) so = 0.05 * o; ## This code can only, as of currently, work on vectors; I haven't figured out a way to make it work on a matrix. if( ( ndims(x1) == 2 ) && ! ( rows(x1) == 1 ) ) Modified: trunk/octave-forge/extra/lssa/lsreal.m =================================================================== --- trunk/octave-forge/extra/lssa/lsreal.m 2012-05-25 23:14:13 UTC (rev 10522) +++ trunk/octave-forge/extra/lssa/lsreal.m 2012-05-26 01:07:07 UTC (rev 10523) @@ -23,7 +23,7 @@ ## ## @end deftypefn -function transform = nureal( t, x, omegamax, ncoeff, noctave) +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 means that in the C, *tptr is X and *xptr is Y. Yes, I know. I think I'll rename them. Modified: trunk/octave-forge/extra/lssa/lswaveletcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/lswaveletcoeff.m 2012-05-25 23:14:13 UTC (rev 10522) +++ trunk/octave-forge/extra/lssa/lswaveletcoeff.m 2012-05-26 01:07:07 UTC (rev 10523) @@ -14,9 +14,9 @@ ## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {c =} nuwaveletcoeff (abc, ord, time, freq) -## @deftypefnx {Function File} {c =} nuwaveletcoeff (abc, ord, time, freq, window) -## @deftypefnx {Function File} {c =} nuwaveletcoeff (abc, ord, time, freq, window, winradius) +## @deftypefn {Function File} {c =} lswaveletcoeff (abc, ord, time, freq) +## @deftypefnx {Function File} {c =} lswaveletcoeff (abc, ord, time, freq, window) +## @deftypefnx {Function File} {c =} lswaveletcoeff (abc, ord, time, freq, window, winradius) ## ## Return the coefficient of the wavelet transform of the ## time series (@var{abc}, @var{ord}) at time @var{time} @@ -32,12 +32,12 @@ %! y = sin(x); %! xt = x'; %! yt = y'; -%! a = nuwaveletcoeff(x,y,0.5,0.9) -%! b = nuwaveletcoeff(xt,yt,0.5,0.9) +%! a = lswaveletcoeff(x,y,0.5,0.9) +%! b = lswaveletcoeff(xt,yt,0.5,0.9) %! ## Generates the wavelet transform coefficient for time 0.5 and circ. freq. 0.9, for row & column vectors. -function coeff = nuwaveletcoeff( x , y , t , o , wgt = @cubicwgt , wgtrad = 1 ) +function coeff = lswaveletcoeff( x , y , t , o , wgt = @cubicwgt , wgtrad = 1 ) so = 0.05 .* o; if ( ( ndims(x) == 2 ) && ! ( rows(x) == 1 ) ) x = reshape(x,1,length(x)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |