[Kst] kdeextragear-2/kst/plugins/crossspectrum
Barth Netterfield
netterfield at astro.utoronto.ca
Mon Aug 16 16:04:14 CEST 2004
CVS commit by netterfield:
cross spectrum plugin was incorrect mathematically... this fixes it.
M +9 -3 crossspectrum.cpp 1.2
M +4 -1 crossspectrum.xml 1.2
--- kdeextragear-2/kst/plugins/crossspectrum/crossspectrum.cpp #1.1:1.2
@@ -63,6 +63,8 @@ int crossspectrum(const double *const in
outArrays[0] = (double *) realloc(outArrays[0], xps_len*sizeof(double));
outArrays[1] = (double *) realloc(outArrays[1], xps_len*sizeof(double));
+ outArrays[2] = (double *) realloc(outArrays[2], xps_len*sizeof(double));
outArrayLens[0] = xps_len;
outArrayLens[1] = xps_len;
+ outArrayLens[2] = xps_len;
}
@@ -70,6 +72,7 @@ int crossspectrum(const double *const in
df = SR/( 2.0*double( xps_len-1 ) );
for ( i=0; i<xps_len; i++ ) {
- outArrays[1][i] = double( i ) * df;
+ outArrays[2][i] = double( i ) * df;
outArrays[0][i] = 0.0;
+ outArrays[1][i] = 0.0;
}
@@ -124,7 +127,9 @@ int crossspectrum(const double *const in
outArrays[0][xps_len-1] += ( a[1]*b[1] );
for (i_samp=1; i_samp<xps_len-1; i_samp++) {
- outArrays[0][i_samp]+= ( a[i_samp*2] * b[i_samp*2] +
+ outArrays[0][i_samp]+= ( a[i_samp*2] * b[i_samp*2] -
a[i_samp*2+1] * b[i_samp*2+1] );
- }
+ outArrays[1][i_samp]+= ( -a[i_samp*2] * b[i_samp*2+1] +
+ a[i_samp*2+1] * b[i_samp*2] );
+ }// (a+ci)(b+di)* = ab+cd +i(-ad + cb)
}
@@ -133,4 +138,5 @@ int crossspectrum(const double *const in
for ( i=0; i<xps_len; i++ ) {
outArrays[0][i]*=norm_factor;
+ outArrays[1][i]*=norm_factor;
}
--- kdeextragear-2/kst/plugins/crossspectrum/crossspectrum.xml #1.1:1.2
@@ -26,5 +26,8 @@
<output>
-<table type="float" name="Cross Spectrum" descr="The cross power spectrum." />
+<table type="float" name="Cross Spectrum: Real" descr="The cross power spectrum." />
+</output>
+<output>
+<table type="float" name="Cross Spectrum: Imaginary" descr="The cross power spectrum." />
</output>
<output>
More information about the Kst
mailing list