Voice Lab
distortion
double distortion(double **cb_vector, int cb_length, int vector_width, double **vector, int number_vectors, int *vector_index, int options)
{
int i, opt;
double total_distortion;
// vector_classify(cb_vector, cb_length, vector_width, vector, number_vectors, vector_index);
total_distortion = 0.0;
//if(opt == 0) distance = distance;
//if(opt == 2) distance = sqrt(distance);
//if(opt == 8) distance /= vector_width;
opt = 2;
for(i = 0; i < number_vectors; i++) {
total_distortion += vector_distance(vector[i], cb_vector[vector_index[i]], vector_width, opt);
number_adds++;
}
number_adds--;
/*
** Compensate the number of additions, subtractions, and multiplications
** that are not necessary for the total distortion calculation
*/
for(i = 0; i < (number_vectors*vector_width); i++) {
number_subs--;
number_muls--;
}
for(i = 0; i < (number_vectors*(vector_width-1)); i++) {
number_adds--;
}
if(options == 1) total_distortion /= number_vectors;
return(total_distortion);
}
No comments:
Post a Comment