1 /*
2   tvq_mbest.c
3   David Rowe Dec 2019
4 
5   Generate some test vectors to exercise misc/vq_mbest.c
6 */
7 
8 #include <assert.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11 
write_float_file(char fn[],float * values,int n)12 void write_float_file(char fn[], float *values, int n) {
13     FILE *f=fopen(fn,"wb");
14     assert(f != NULL);
15     assert(fwrite(values, sizeof(float), n, f) == n);
16     fclose(f);
17 }
18 
main(void)19 int main(void) {
20     /* we're only interested in searching the inner 2 values, outer elements should be
21        ignored */
22     float target[] = {0.0,1.0,1.0,0.0};
23     write_float_file("target.f32", target, 4);
24     float vq1[] = {1.0,0.9,0.9,1.0,  /* this will be a better match on first stage */
25 		   2.0,0.8,0.8,2.0}; /* but after second stage should choose this  */
26     write_float_file("vq1.f32", vq1, 8);
27     float vq2[] = {10.0,0.3,0.3,10.0,
28 		   20.0,0.2,0.2,20.0}; /* 0.8+0.2 == 1.0 so best 2nd stage entry     */
29     write_float_file("vq2.f32", vq2, 8);
30     return 0;
31 }
32