32uword
gcd(uword, uword);
46template<WindowType T> vec
fir_low_pass(uword,
double) {
throw invalid_argument(
"unknown window type"); }
60template<WindowType T> vec
fir_high_pass(uword,
double) {
throw invalid_argument(
"unknown window type"); }
74template<WindowType T> vec
fir_band_pass(uword,
double,
double) {
throw invalid_argument(
"unknown window type"); }
88template<WindowType T> vec
fir_band_stop(uword,
double,
double) {
throw invalid_argument(
"unknown window type"); }
102template<WindowType T> vec
upsampling(
const vec& in,
const uword up_rate,
const uword window_size) {
103 const vec coef =
static_cast<double>(up_rate) * fir_low_pass<T>(window_size * up_rate, 1. /
static_cast<double>(up_rate));
105 vec out(up_rate * in.n_elem, fill::zeros);
107 for(
auto I = 0llu, J = 0llu; I < in.n_elem; ++I, J += up_rate) out(J) = in(I);
109 return conv(out, coef,
"same");
112template<WindowType T> mat
upsampling(
const string& file_name,
const uword up_rate,
const uword window_size) {
114 if(std::error_code code; !fs::exists(file_name, code) || !ext_data.load(file_name, raw_ascii) || ext_data.empty() || ext_data.n_cols < 2) {
119 const vec time_diff = diff(ext_data.col(0));
126 const auto upsampled_data = upsampling<T>(ext_data.col(1), up_rate, window_size);
128 mat result(upsampled_data.n_elem, 2, fill::none);
130 result.col(1) = upsampled_data;
132 const auto time_size = mean(time_diff) /
static_cast<double>(up_rate);
134 for(
auto I = 0llu; I < result.n_rows; ++I) result(I, 0) =
static_cast<double>(I) * time_size;
139mat
upsampling(
const string&,
const string&, uword, uword = 8llu);
std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > approx_equal(T x, T y, int ulp=2)
Definition utility.h:60
vec fir_high_pass< WindowType::FlatTop >(uword, double)
Definition resampling.cpp:152
vec fir_band_stop< WindowType::BlackmanHarris >(uword, double, double)
Definition resampling.cpp:174
vec fir_low_pass< WindowType::Hann >(uword, double)
Definition resampling.cpp:132
vec fir_band_stop< WindowType::Hann >(uword, double, double)
Definition resampling.cpp:168
vec fir_low_pass< WindowType::FlatTop >(uword, double)
Definition resampling.cpp:140
vec fir_band_stop< WindowType::Blackman >(uword, double, double)
Definition resampling.cpp:170
vec hann(uword)
Definition resampling.cpp:46
vec fir_low_pass< WindowType::BlackmanHarris >(uword, double)
Definition resampling.cpp:138
vec blackman_harris(uword)
Definition resampling.cpp:52
WindowType
Definition resampling.h:23
vec fir_high_pass< WindowType::Hann >(uword, double)
Definition resampling.cpp:144
vec fir_low_pass< WindowType::BlackmanNuttall >(uword, double)
Definition resampling.cpp:136
vec fir_band_stop< WindowType::FlatTop >(uword, double, double)
Definition resampling.cpp:176
vec upsampling(const vec &in, const uword up_rate, const uword window_size)
Definition resampling.h:102
uword gcd(uword, uword)
Definition resampling.cpp:20
vec fir_band_pass< WindowType::BlackmanHarris >(uword, double, double)
Definition resampling.cpp:162
vec fir_low_pass(uword, double, vec(*)(uword))
Definition resampling.cpp:56
vec hamming(uword)
Definition resampling.cpp:44
vec fir_band_stop< WindowType::BlackmanNuttall >(uword, double, double)
Definition resampling.cpp:172
vec fir_high_pass< WindowType::BlackmanNuttall >(uword, double)
Definition resampling.cpp:148
vec fir_band_pass< WindowType::Hann >(uword, double, double)
Definition resampling.cpp:156
vec fir_band_pass< WindowType::Blackman >(uword, double, double)
Definition resampling.cpp:158
vec fir_high_pass< WindowType::Blackman >(uword, double)
Definition resampling.cpp:146
vec fir_low_pass< WindowType::Blackman >(uword, double)
Definition resampling.cpp:134
vec fir_band_pass(uword, double, double, vec(*)(uword))
Definition resampling.cpp:89
vec fir_high_pass< WindowType::BlackmanHarris >(uword, double)
Definition resampling.cpp:150
vec fir_band_pass< WindowType::BlackmanNuttall >(uword, double, double)
Definition resampling.cpp:160
vec blackman_nuttall(uword)
Definition resampling.cpp:50
vec fir_band_pass< WindowType::Hamming >(uword, double, double)
Definition resampling.cpp:154
vec fir_band_stop< WindowType::Hamming >(uword, double, double)
Definition resampling.cpp:166
vec fir_band_stop(uword, double, double, vec(*)(uword))
Definition resampling.cpp:110
vec fir_high_pass(uword, double, vec(*)(uword))
Definition resampling.cpp:68
vec fir_high_pass< WindowType::Hamming >(uword, double)
Definition resampling.cpp:142
vec fir_low_pass< WindowType::Hamming >(uword, double)
Definition resampling.cpp:130
vec blackman(uword)
Definition resampling.cpp:48
vec flat_top(uword)
Definition resampling.cpp:54
vec fir_band_pass< WindowType::FlatTop >(uword, double, double)
Definition resampling.cpp:164