master
Ondřej Hruška 9 years ago
parent 2672a88a89
commit bb71551e6b
  1. 4
      main.c
  2. 7
      src/vec_match.c

@ -9,12 +9,12 @@
static float reference[DATA_LEN] = { static float reference[DATA_LEN] = {
//0, 10, 20, 30, 40, 50, 40, 30, 20, 10, 0 //0, 10, 20, 30, 40, 50, 40, 30, 20, 10, 0
0, 15.7, 0, 0, 0.1, 0.2, 0.1, 10, 24.242, 0, 0, 2, 0.2, 0.4, 0.5, 0 0, 15.7, 0, 0, 0.1, 0.2, 0.1, 10, 24.242, 7, 0, 2, 0.2, 0.4, 0.5, 0
}; };
static float data[DATA_LEN] = { static float data[DATA_LEN] = {
//0, 10, 20, 30, 40, 50, 50, 35, 15, 15, 0 //0, 10, 20, 30, 40, 50, 50, 35, 15, 15, 0
0, 15.7, 0, 0, 0.1, 0.2, 0.1, 10, 24, 0, 2, 2, 0.2, 0.4, 0.5, 0 0, 15.7, 0, 0, 0.1, 0.2, 0.1, 10, 24, 6, 3, 2, 0.2, 0.4, 0.5, 0
}; };
static float ref_p[REF_LEN]; static float ref_p[REF_LEN];

@ -53,12 +53,13 @@ bool vec_match_do(const float *data, const float *ref, uint32_t ref_p_len,
} }
// find base and peak // find base and peak
for (uint32_t j = a; j <= b; j++) { for (uint32_t j = a; j <= b; j++) {
f = packed ? pw_get(&w, j) : ref[j]; f = packed ? pw_get(&w, j) : ref[j];
if (peak < f) peak = f; if (peak < f) peak = f;
if (f < base) base = f; if (f < base) {
base = f;
}
} }
ref_at = packed ? pw_get(&w, i) : ref[i]; ref_at = packed ? pw_get(&w, i) : ref[i];
@ -77,8 +78,6 @@ bool vec_match_do(const float *data, const float *ref, uint32_t ref_p_len,
// within limits // within limits
continue; continue;
} else { } else {
//printf("data[%d] out of range: %f, [%f ; %f]\n", i, data[i], base, peak);
if (data[i] < base) env_err += SQ(base - data[i]); if (data[i] < base) env_err += SQ(base - data[i]);
if (data[i] > peak) env_err += SQ(data[i] - peak); if (data[i] > peak) env_err += SQ(data[i] - peak);

Loading…
Cancel
Save