/* Add the points in the low utility cell to its closest cell. Split the high utility cell, putting the separed points in the (now empty) low utility cell. */
static void shift_codebook(elbg_data *elbg, int *indexes, int *newcentroid[3])
/* Add the points in the low utility cell to its closest cell. Split the high utility cell, putting the separed points in the (now empty) low utility cell. */
static void shift_codebook(elbg_data *elbg, int *indexes, int *newcentroid[3])
{
    cell *tempdata;
    cell **pp = &elbg->cells[indexes[2]];
    while(*pp)
        pp= &(*pp)->next;
    *pp = elbg->cells[indexes[0]];
    elbg->cells[indexes[0]] = NULL;
    tempdata = elbg->cells[indexes[1]];
    elbg->cells[indexes[1]] = NULL;
    while(tempdata) {
        cell *tempcell2 = tempdata->next;
        int idx = distance_limited(elbg->points + tempdata->index*elbg->dim,
                           newcentroid[0], elbg->dim, INT_MAX) >
                  distance_limited(elbg->points + tempdata->index*elbg->dim,
                           newcentroid[1], elbg->dim, INT_MAX);
        tempdata->next = elbg->cells[indexes[idx]];
        elbg->cells[indexes[idx]] = tempdata;
        tempdata = tempcell2;
    }
}