23 arma::cx_vec
spectrum(
const arma::Col<T1> &x,
const arma::vec &W)
25 arma::cx_vec Pxx(x.size());
27 Pxx = fft(x % W) / wc;
37 template <
class T1> arma::vec
psd(
const arma::Col<T1> &x,
const arma::vec &W)
39 arma::cx_vec X(x.size());
40 arma::vec Pxx(x.size());
42 Pxx = real(X % conj(X));
51 template <
class T1> arma::vec
psd(
const arma::Col<T1> &x)
68 arma::cx_mat
specgram_cx(
const arma::Col<T1> &x,
const arma::uword Nfft = 512,
69 const arma::uword Noverl = 256)
74 arma::uword N = x.size();
75 arma::uword D = Nfft - Noverl;
79 arma::Col<T1> xk(Nfft);
83 arma::uword U =
static_cast<arma::uword
>(floor((N - Noverl) /
double(D)));
88 for (arma::uword k = 0; k < N - Nfft; k += D)
90 xk = x.rows(k, k + Nfft - 1);
114 arma::mat
specgram(
const arma::Col<T1> &x,
const arma::uword Nfft = 512,
115 const arma::uword Noverl = 256)
120 Sg = real(Pw % conj(Pw));
134 arma::mat
specgram_ph(
const arma::Col<T1> &x,
const arma::uword Nfft = 512,
135 const arma::uword Noverl = 256)
155 arma::vec
pwelch_ph(
const arma::Col<T1> &x,
const arma::uword Nfft = 512,
156 const arma::uword Noverl = 256)
160 return arma::mean(Ph, 1);
175 arma::vec
pwelch(
const arma::Col<T1> &x,
const arma::uword Nfft = 512,
176 const arma::uword Noverl = 256)
180 return arma::mean(Pxx, 1);
193 std::complex<double>
goertzel(
const arma::Col<T1> &x,
const double f)
196 arma::uword N = x.size();
199 double B = 2 * cos(A);
200 std::complex<double> C(cos(A), -sin(A));
207 for (arma::uword n = 0; n < N; n++)
210 s0 = x(n) + B * s1 - s2;
233 arma::cx_vec
goertzel(
const arma::Col<T1> &x,
const arma::vec f)
235 arma::uword N = f.size();
237 for (arma::uword n = 0; n < N; n++)
arma::mat specgram(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Power spectrogram calculation.
arma::vec pwelch_ph(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Phase spectrum calculation using Welch's method.
double angle(const std::complex< T > &x)
Calculates angle in radians for complex input.
arma_inline arma::vec hamming(const arma::uword N)
Hamming window.
arma::mat specgram_ph(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Phase spectrogram calculation.
arma::cx_vec spectrum(const arma::Col< T1 > &x, const arma::vec &W)
Windowed spectrum calculation.
arma::vec pwelch(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Power spectrum calculation using Welch's method.
arma::vec psd(const arma::Col< T1 > &x, const arma::vec &W)
Power spectrum density calculation using windowed data.
std::complex< double > goertzel(const arma::Col< T1 > &x, const double f)
DFT calculation of a single frequency using Goertzel's method.
arma::cx_mat specgram_cx(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Spectrogram calculation using Hamming windowed data.