comparison audioDB.cpp @ 66:4c4c4ca6b59e

Fix bugs revealed by test 0009 * initialize the distances (point and track) to something "impossible"; * take the mean of only those points that have actually been found.
author mas01cr
date Wed, 26 Sep 2007 12:47:20 +0000
parents 128f065fd250
children c3f7ee73bdde
comparison
equal deleted inserted replaced
65:00c3326e8242 66:4c4c4ca6b59e
1139 unsigned j=numVectors; // number of query points 1139 unsigned j=numVectors; // number of query points
1140 unsigned k,l,n, track, trackOffset=0, processedTracks=0; 1140 unsigned k,l,n, track, trackOffset=0, processedTracks=0;
1141 double thisDist; 1141 double thisDist;
1142 1142
1143 for(k=0; k<pointNN; k++){ 1143 for(k=0; k<pointNN; k++){
1144 distances[k]=0.0; 1144 distances[k]=-DBL_MAX;
1145 qIndexes[k]=~0; 1145 qIndexes[k]=~0;
1146 sIndexes[k]=~0; 1146 sIndexes[k]=~0;
1147 } 1147 }
1148 1148
1149 for(k=0; k<trackNN; k++){ 1149 for(k=0; k<trackNN; k++){
1150 trackDistances[k]=0.0; 1150 trackDistances[k]=-DBL_MAX;
1151 trackQIndexes[k]=~0; 1151 trackQIndexes[k]=~0;
1152 trackSIndexes[k]=~0; 1152 trackSIndexes[k]=~0;
1153 trackIDs[k]=~0; 1153 trackIDs[k]=~0;
1154 } 1154 }
1155 1155
1267 query+=dbH->dim; 1267 query+=dbH->dim;
1268 } // query 1268 } // query
1269 // Take the average of this track's distance 1269 // Take the average of this track's distance
1270 // Test the track distances 1270 // Test the track distances
1271 thisDist=0; 1271 thisDist=0;
1272 n=pointNN; 1272 for (n = 0; n < pointNN; n++) {
1273 while(n--) 1273 if (distances[n] == -DBL_MAX) break;
1274 thisDist+=distances[pointNN-n-1]; 1274 thisDist += distances[n];
1275 thisDist/=pointNN; 1275 }
1276 thisDist /= n;
1277
1276 n=trackNN; 1278 n=trackNN;
1277 while(n--){ 1279 while(n--){
1278 if(thisDist>=trackDistances[n]){ 1280 if(thisDist>=trackDistances[n]){
1279 if((n==0 || thisDist<=trackDistances[n-1])){ 1281 if((n==0 || thisDist<=trackDistances[n-1])){
1280 // Copy all values above up the queue 1282 // Copy all values above up the queue
1293 } 1295 }
1294 else 1296 else
1295 break; 1297 break;
1296 } 1298 }
1297 for(unsigned k=0; k<pointNN; k++){ 1299 for(unsigned k=0; k<pointNN; k++){
1298 distances[k]=0.0; 1300 distances[k]=-DBL_MAX;
1299 qIndexes[k]=~0; 1301 qIndexes[k]=~0;
1300 sIndexes[k]=~0; 1302 sIndexes[k]=~0;
1301 } 1303 }
1302 } // tracks 1304 } // tracks
1303 gettimeofday(&tv2, NULL); 1305 gettimeofday(&tv2, NULL);