Commit 5b70da52 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP][FEATURE]: provide interval series with Tcoc base class

parent 44ea7697
......@@ -38,12 +38,12 @@
namespace psd {
Tdouble_series abs(const Tcomplex_double_series& s)
TDIseries abs(const TDCIseries& s)
{
Tdouble_series retval(s);
TDIseries retval(s);
aff::Iterator<Tdouble_series::Tseries> S(retval.data);
aff::Browser<Tcomplex_double_series::Tseries> C(s.data);
aff::Iterator<TDIseries::Tseries> S(retval.data);
aff::Browser<TDCIseries::Tseries> C(s.data);
while(S.valid() && C.valid())
{
......@@ -51,7 +51,7 @@ namespace psd {
++S; ++C;
}
return(retval);
} // Tdouble_series abs(const Tcomplex_double_series& s)
} // TDIseries abs(const TDCIseries& s)
} // namespace psd
......
......@@ -38,12 +38,12 @@
namespace psd {
Tdouble_series arg(const Tcomplex_double_series& s)
TDIseries arg(const TDCIseries& s)
{
Tdouble_series retval(s);
TDIseries retval(s);
aff::Iterator<Tdouble_series::Tseries> S(retval.data);
aff::Browser<Tcomplex_double_series::Tseries> C(s.data);
aff::Iterator<TDIseries::Tseries> S(retval.data);
aff::Browser<TDCIseries::Tseries> C(s.data);
while(S.valid() && C.valid())
{
......@@ -51,7 +51,7 @@ namespace psd {
++S; ++C;
}
return(retval);
} // Tdouble_series arg(const Tcomplex_double_series& s)
} // TDIseries arg(const TDCIseries& s)
} // namespace psd
......
......@@ -60,37 +60,75 @@ namespace psd {
/*! Container for series with sampling interval
*/
template<typename T> struct Samples
template<typename T>
struct ConstIntervalSeries
{
public:
//! type of series container
typedef typename aff::Series<T>::Tcoc Tseries;
protected:
aff::Series<T> Mdata;
public:
//! series
Tseries& data;
//! sampling interval (seconds for time series, Hz for spectral data)
double interval;
//! default constructor
ConstIntervalSeries(): data(Mdata), interval(0) { }
//! copy constructor
ConstIntervalSeries(const ConstIntervalSeries& s):
data(Mdata), interval(s.interval) { Mdata=s.Mdata; }
//! copy operator
ConstIntervalSeries& operator=(const ConstIntervalSeries& s)
{ Mdata=s.Mdata; interval=s.interval; return(*this); }
}; // template<typename T> struct ConstIntervalSeries
/*! Container for series with sampling interval
*/
template<typename T>
struct IntervalSeries: public ConstIntervalSeries<T>
{
//! type of series container
typedef aff::Series<T> Tseries;
//! default constructor
Samples() { }
//! Constructor
template<typename TS>
Samples(const Samples<TS>& s):
data(s.data.shape()), interval(s.interval) { }
//! series
Tseries data;
//! sampling interval (seconds for time series, Hz for spectral data)
double interval;
}; // template<typename T> struct Sampleѕ
public:
//! type of series container
typedef ConstIntervalSeries<T> Tbase;
//! container of constant sample values
typedef Tbase Tcoc;
//! type of series container
typedef aff::Series<T> Tseries;
public:
//! series
Tseries& data;
//! sampling interval (seconds for time series, Hz for spectral data)
double interval;
//! default constructor
IntervalSeries(): data(Tbase::Mdata), interval(0) { }
//! copy constructor
IntervalSeries(const IntervalSeries& s):
data(Tbase::Mdata), interval(s.interval) { Tbase::Mdata=s.Mdata; }
//! copy operator
IntervalSeries& operator=(const IntervalSeries& s)
{ this->Tbase::operator=(s); return(*this); }
}; // template<typename T> struct IntervalSeries
/* ====================================================================== */
// containers for equally spaced data providing sampling information
//! time series and real spectral values (PSD and coherency)
typedef Samples<double> Tdouble_series;
typedef IntervalSeries<double> TDISeries;
//! complex coefficients
typedef Samples<std::complex<double> > Tcomplex_double_series;
typedef IntervalSeries<std::complex<double> > TDCIseries;
/* ====================================================================== */
//! return absolute value (magnitude) of complex values
Tdouble_series abs(const Tcomplex_double_series& s);
TDIseries abs(const TDCIseries& s);
//! return argument of complex values
Tdouble_series arg(const Tcomplex_double_series& s);
TDIseries arg(const TDCIseries& s);
/* ====================================================================== */
......@@ -126,13 +164,13 @@ namespace psd {
bool verbose() const { return(Mverbose); }
//! compute power spectral density
Tdouble_series psd(const Tdouble_series& s) const;
TDIseries psd(const TDIseries& s) const;
//! compute cross power spectrum
Tcomplex_double_series cross_psd(const Tdouble_series& s1,
const Tdouble_series& s2) const;
TDCIseries cross_psd(const TDIseries& s1,
const TDIseries& s2) const;
//! compute coherency
Tdouble_series coherency(const Tdouble_series& s1,
const Tdouble_series& s2) const;
TDIseries coherency(const TDIseries& s1,
const TDIseries& s2) const;
private:
//! number of segments split input time series
......@@ -153,13 +191,13 @@ namespace psd {
//! container for return value of general processor (internal use only)
struct SpectralValues
{
Tcomplex_double_series psd1, psd2;
Tcomplex_double_series cpsd;
TDIseries psd1, psd2;
TDCIseries cpsd;
}; // struct SpectralValues
//! general processor (internal use only)
SpectralValues processor(const Tdouble_series& s1,
const Tdouble_series& s2,
SpectralValues processor(const TDIseries& s1,
const TDIseries& s2,
const bool& cpsd_flag,
const bool& psd_flag) const;
}; // class DPSDComputer
......
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