3#include <dsplib/array.h>
11template<
typename T1,
typename T2,
typename T3>
12using enable_if_some_float_t = std::enable_if<std::is_floating_point<T1>::value || std::is_floating_point<T2>::value ||
13 std::is_floating_point<T3>::value>;
15template<typename T1, typename T2, typename T3, class R = typename enable_if_some_float_t<T1, T2, T3>::type>
16arr_real arange(T1 start, T2 stop, T3 step = 1) {
17 const auto n = (int)(std::round((stop - start) /
double(step)));
19 for (
int i = 0; i < n; ++i) {
20 r[i] = start + (i * step);
25inline arr_real arange(real_t stop) {
26 return arange(real_t(0), stop, real_t(1));
29inline arr_real arange(
int start,
int stop,
int step = 1) {
30 const auto n = (int)std::round((stop - start) / double(step));
32 for (
int i = 0; i < n; ++i) {
39inline arr_real arange(
int stop) {
40 return arange(0, stop, 1);
45arr_real concatenate(span_real x1, span_real x2, span_real x3 = {}, span_real x4 = {}, span_real x5 = {});
46arr_cmplx concatenate(span_cmplx x1, span_cmplx x2, span_cmplx x3 = {}, span_cmplx x4 = {}, span_cmplx x5 = {});
49inline arr_real zeros(
int n) {
54inline arr_real ones(
int n) {
56 std::fill(r.begin(), r.end(), 1.0);
61arr_real repelem(
const arr_real& x,
int n);
62arr_cmplx repelem(
const arr_cmplx& x,
int n);
65arr_real flip(
const arr_real& x);
66arr_cmplx flip(
const arr_cmplx& x);
67void flip(inplace_real x);
68void flip(inplace_cmplx x);
84arr_real from_file(
const std::string& file, dtype type = dtype::int16, endian order = endian::little,
long offset = 0,
85 long count = std::numeric_limits<long>::max());
88arr_real zeropad(span_real x,
int n);
89arr_cmplx zeropad(span_cmplx x,
int n);
94base_array<T> delayseq(
const base_array<T>& data,
int delay) {
99 const int N = data.size();
100 if (abs(delay) >= N) {
104 base_array<T> res = zeros(N);
106 res.slice(delay, N) = data.slice(0, N - delay);
108 res.slice(0, N - abs(delay)) = data.slice(abs(delay), N);
114real_t peakloc(span_real x,
int idx,
bool cyclic =
true);
115real_t peakloc(span_cmplx x,
int idx,
bool cyclic =
true);
118int finddelay(span_real x1, span_real x2);
119int finddelay(span_cmplx x1, span_cmplx x2);
132arr_real linspace(real_t x1, real_t x2,
size_t n);
std::vector< real_t > wds
peak widths
Definition utils.h:125
std::vector< real_t > pks
local maxima
Definition utils.h:123
std::vector< real_t > locs
peak locations
Definition utils.h:124