Mercurial > hg > audiodb
changeset 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 | 00c3326e8242 |
children | e13b4f62b4f5 |
files | audioDB.cpp |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Wed Sep 26 12:45:51 2007 +0000 +++ b/audioDB.cpp Wed Sep 26 12:47:20 2007 +0000 @@ -1141,13 +1141,13 @@ double thisDist; for(k=0; k<pointNN; k++){ - distances[k]=0.0; + distances[k]=-DBL_MAX; qIndexes[k]=~0; sIndexes[k]=~0; } for(k=0; k<trackNN; k++){ - trackDistances[k]=0.0; + trackDistances[k]=-DBL_MAX; trackQIndexes[k]=~0; trackSIndexes[k]=~0; trackIDs[k]=~0; @@ -1269,10 +1269,12 @@ // Take the average of this track's distance // Test the track distances thisDist=0; - n=pointNN; - while(n--) - thisDist+=distances[pointNN-n-1]; - thisDist/=pointNN; + for (n = 0; n < pointNN; n++) { + if (distances[n] == -DBL_MAX) break; + thisDist += distances[n]; + } + thisDist /= n; + n=trackNN; while(n--){ if(thisDist>=trackDistances[n]){ @@ -1295,7 +1297,7 @@ break; } for(unsigned k=0; k<pointNN; k++){ - distances[k]=0.0; + distances[k]=-DBL_MAX; qIndexes[k]=~0; sIndexes[k]=~0; }