From 3cd3a9f82068bea3a37e4efe0ee3752ecb044cce Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 13 Jul 2023 08:49:31 +0930 Subject: rm misc directory --- misc/vq_binary_switch.c | 296 ------------------------------------------------ 1 file changed, 296 deletions(-) delete mode 100644 misc/vq_binary_switch.c (limited to 'misc/vq_binary_switch.c') diff --git a/misc/vq_binary_switch.c b/misc/vq_binary_switch.c deleted file mode 100644 index 4270c3d..0000000 --- a/misc/vq_binary_switch.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - vq_binary_switch.c - David Rowe Dec 2021 - - C implementation of [1], that re-arranges VQ indexes so they are robust to single - bit errors. - - [1] Pseudo Gray Coding, Zeger & Gersho 1990 -*/ - -#include -#include -#include -#include -#include -#include -#include -#include "mbest.h" - -#define MAX_DIM 20 -#define MAX_ENTRIES 4096 - -// equation (33) of [1], total cost of all hamming distance 1 vectors of vq index k -float cost_of_distance_one(float *vq, int n, int dim, float *prob, int k, int st, int en, int verbose) { - int log2N = log2(n); - float c = 0.0; - for (int b=0; b best_delta) { - best_delta = fabs(delta); - best_j = j; - } - } - // unswitch - swap(vq, dim, prob, A[i], j); - } - } //next j - - // printf("best_delta: %f best_j: %d\n", best_delta, best_j); - if (best_delta == 0.0) { - // Hmm, no improvement, lets try the next vector in the sorted cost list - if (i == n-1) finished = 1; else i++; - } else { - // OK keep the switch that minimised the distortion - swap(vq, dim, prob, A[i], best_j); - switches++; - - // save results - FILE *fq=fopen(argv[dx+1], "wb"); - if (fq == NULL) { - fprintf(stderr, "Couldn't open: %s\n", argv[dx+1]); - exit(1); - } - int nwr = fwrite(vq, sizeof(float), n*dim, fq); - assert(nwr == n*dim); - fclose(fq); - - // set up for next iteration - iteration++; - float distortion = distortion_of_current_mapping(vq, n, dim, prob, st, en); - fprintf(stderr, "it: %3d dist: %f %3.2f i: %3d sw: %3d\n", iteration, distortion, - distortion/distortion0, i, switches); - if (iteration >= max_iter) finished = 1; - i = 0; - } - } - - return 0; -} - -- cgit v1.2.3