SBB Host
Host communication with the self balancing bike.
Loading...
Searching...
No Matches
spectra.h
Go to the documentation of this file.
1/*
2spectra analysis implementation using fftw and std::vector
3*/
4
5#ifndef SPECTRA_H
6#define SPECTRA_H
7
8#include <vector>
9#include <fftw3.h>
10#include <math.h>
11
18namespace spectra {
19
20 //constants
21 constexpr int REAL = 0;
22 constexpr int IMAG = 1;
23
29 std::vector<double> abs(std::vector<fftw_complex> vals);
30
36 std::vector<double> abs2(std::vector<fftw_complex> vals);
37
43 std::vector<double> arg(std::vector<fftw_complex> vals);
44
50 std::vector<double> argd(std::vector<fftw_complex> vals);
51
59 void polar(std::vector<fftw_complex> vals, std::vector<double> *mag, std::vector<double> *phase);
60
68 void polard(std::vector<fftw_complex> vals, std::vector<double> *mag, std::vector<double> *phase);
69
77 void bode(std::vector<fftw_complex> vals, std::vector<double> *mag, std::vector<double> *phase);
78
86 void boded(std::vector<fftw_complex> vals, std::vector<double> *mag, std::vector<double> *phase);
87
94 std::vector<double> frequency(size_t size, double fmax = 0.5);
95
102 std::vector<fftw_complex> fft(std::vector<double> vals);
103
110 std::vector<double> psd(std::vector<double> vals);
111
112}
113
114#endif
A namespace providing wrappers for FFTW library.
Definition: spectra.h:18
std::vector< double > arg(std::vector< fftw_complex > vals)
Compute the phase in radiants.
constexpr int IMAG
Position of the imag part in fftw_complex type.
Definition: spectra.h:22
constexpr int REAL
Position of the real part in fftw_complex type.
Definition: spectra.h:21
void boded(std::vector< fftw_complex > vals, std::vector< double > *mag, std::vector< double > *phase)
Compute the bode coordinates.
void polard(std::vector< fftw_complex > vals, std::vector< double > *mag, std::vector< double > *phase)
Compute the polar coordinates.
void bode(std::vector< fftw_complex > vals, std::vector< double > *mag, std::vector< double > *phase)
Compute the bode coordinates.
std::vector< double > argd(std::vector< fftw_complex > vals)
Compute the phase in degrees.
std::vector< double > psd(std::vector< double > vals)
Compute the power-spectra-density.
std::vector< double > abs2(std::vector< fftw_complex > vals)
Compute the magnitute squared.
void polar(std::vector< fftw_complex > vals, std::vector< double > *mag, std::vector< double > *phase)
Compute the polar coordinates.
std::vector< fftw_complex > fft(std::vector< double > vals)
Compute the spectra.
std::vector< double > frequency(size_t size, double fmax=0.5)
Compute the frequency vector.
std::vector< double > abs(std::vector< fftw_complex > vals)
Compute the magnitute.