Commit 18bd88a7 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

ts/wf/cross [FEATURE]: let cross oprionally operate in the Fourier domain

For large time series operation in the Fourier domain is computationally more
efficient than discrete time domain convolution or cross-correlation.
parent 80412a19
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* *
* \author Thomas Forbriger * \author Thomas Forbriger
* \date 16/11/2016 * \date 22/11/2016
* *
* cross correlation * cross correlation
* *
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
* - 16/11/2016 V1.2 provide new features: * - 16/11/2016 V1.2 provide new features:
* - full libdatrwxx support * - full libdatrwxx support
* - trace selectors * - trace selectors
* - 21/11/2016 V1.3 operate in the Fourier domain to speed up * - 22/11/2016 V1.3 operate in the Fourier domain to speed up
* computation for large time series * computation for large time series
* *
* ============================================================================ * ============================================================================
*/ */
#define CROSS_VERSION \ #define CROSS_VERSION \
"CROSS V1.3X cross correlation and convolution" "CROSS V1.3 cross correlation and convolution"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
...@@ -256,17 +256,21 @@ FourierProcessor::Tspectrum ...@@ -256,17 +256,21 @@ FourierProcessor::Tspectrum
{ {
TFXX_assert(sref.size() == ssig.size(), TFXX_assert(sref.size() == ssig.size(),
"inconsistent sets of coefficients"); "inconsistent sets of coefficients");
// imaginary unit time pi (shift factor)
const std::complex<double> expfac(0.,M_PI);
FourierProcessor::Tspectrum result(sref.size()); FourierProcessor::Tspectrum result(sref.size());
result=FourierProcessor::Tspectrum::Tvalue(0.); result=FourierProcessor::Tspectrum::Tvalue(0.);
aff::Browser<FourierProcessor::Tspectrum::Tcoc> BR(sref); aff::Browser<FourierProcessor::Tspectrum::Tcoc> BR(sref);
aff::Browser<FourierProcessor::Tspectrum::Tcoc> BD(ssig); aff::Browser<FourierProcessor::Tspectrum::Tcoc> BD(ssig);
aff::Iterator<FourierProcessor::Tspectrum> IR(result); aff::Iterator<FourierProcessor::Tspectrum> IR(result);
int l=0;
while (BR.valid() && BD.valid() && IR.valid()) while (BR.valid() && BD.valid() && IR.valid())
{ {
*IR = (*BR) * conj(*BD); *IR = conj(*BR) * (*BD) * std::exp(double(l)*expfac);
++IR; ++IR;
++BR; ++BR;
++BD; ++BD;
++l;
} }
return(result); return(result);
} // FourierProcessor::Tspectrum } // FourierProcessor::Tspectrum
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment