C function for matching numeric vectors and calculating error / difference. This was used to detect difference between FFT results
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
759 B

9 years ago
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "src/vec_match.h"
9 years ago
#define DATA_LEN 11
9 years ago
static float reference[DATA_LEN] = {
0, 10, 20, 30, 40, 50, 40, 30, 20, 10, 0
};
static float data[DATA_LEN] = {
0, 10, 20, 30, 40, 50, 50, 40, 30, 30, 10
9 years ago
};
int main()
{
// example
9 years ago
printf("REF: ");
for (int i = 0; i < DATA_LEN; i++) {
printf("%.0f, ", reference[i]);
}
printf("\n");
9 years ago
printf("MEAS: ");
for (int i = 0; i < DATA_LEN; i++) {
printf("%.0f, ", data[i]);
}
printf("\n");
// error metric fields
9 years ago
float env_e, abs_e;
bool ok = vec_match(data, reference, DATA_LEN, 1, 5, &env_e, &abs_e);
9 years ago
printf("%s", ok ? "MATCH OK" : "MATCH FAILED");
printf("\n");
printf("Error rate: ENV %.2f, ABS %.2f\n", env_e, abs_e);
}