comparison query.cpp @ 439:5294ea1b1bf2 api-inversion

audioDB::initialize_arrays no longer depends on anything in the C++ class. static void audiodb_initialize_arrays() it is.
author mas01cr
date Wed, 24 Dec 2008 10:56:16 +0000
parents 8c1d8a40db91
children cb44e57a96fa
comparison
equal deleted inserted replaced
438:8c1d8a40db91 439:5294ea1b1bf2
44 } 44 }
45 if(usingTimes) { 45 if(usingTimes) {
46 qspec.refine.flags |= ADB_REFINE_DURATION_RATIO; 46 qspec.refine.flags |= ADB_REFINE_DURATION_RATIO;
47 qspec.refine.duration_ratio = timesTol; 47 qspec.refine.duration_ratio = timesTol;
48 } 48 }
49 /* FIXME: not sure about this any more; maybe it belongs in query_id */ 49 /* FIXME: not sure about this any more; maybe it belongs in
50 query_id? Or maybe we just don't need a flag for it? */
51 qspec.refine.hopsize = sequenceHop;
50 if(sequenceHop != 1) { 52 if(sequenceHop != 1) {
51 qspec.refine.flags |= ADB_REFINE_HOP_SIZE; 53 qspec.refine.flags |= ADB_REFINE_HOP_SIZE;
52 qspec.refine.hopsize = sequenceHop;
53 } 54 }
54 55
55 /* FIXME qspec.qid.datum */ 56 /* FIXME qspec.qid.datum */
56 qspec.qid.sequence_length = sequenceLength; 57 qspec.qid.sequence_length = sequenceLength;
57 qspec.qid.flags = usingQueryPoint ? 0 : ADB_QUERY_ID_FLAG_EXHAUSTIVE; 58 qspec.qid.flags = usingQueryPoint ? 0 : ADB_QUERY_ID_FLAG_EXHAUSTIVE;
174 } 175 }
175 176
176 reporter->report(fileTable, adbQueryResponse); 177 reporter->report(fileTable, adbQueryResponse);
177 } 178 }
178 179
179 void audioDB::initialize_arrays(adb_t *adb, adb_query_spec_t *spec, int track, unsigned int numVectors, double *query, double *data_buffer, double **D, double **DD) { 180 static void audiodb_initialize_arrays(adb_t *adb, adb_query_spec_t *spec, int track, unsigned int numVectors, double *query, double *data_buffer, double **D, double **DD) {
180 unsigned int j, k, l, w; 181 unsigned int j, k, l, w;
181 double *dp, *qp, *sp; 182 double *dp, *qp, *sp;
182 183
183 const unsigned HOP_SIZE = sequenceHop; 184 const unsigned HOP_SIZE = spec->refine.hopsize;
184 const unsigned wL = spec->qid.sequence_length; 185 const unsigned wL = spec->qid.sequence_length;
185 186
186 for(j = 0; j < numVectors; j++) { 187 for(j = 0; j < numVectors; j++) {
187 // Sum products matrix 188 // Sum products matrix
188 D[j] = new double[(*adb->track_lengths)[track]]; 189 D[j] = new double[(*adb->track_lengths)[track]];
193 } 194 }
194 195
195 // Dot product 196 // Dot product
196 for(j = 0; j < numVectors; j++) 197 for(j = 0; j < numVectors; j++)
197 for(k = 0; k < (*adb->track_lengths)[track]; k++){ 198 for(k = 0; k < (*adb->track_lengths)[track]; k++){
198 qp = query + j * dbH->dim; 199 qp = query + j * adb->header->dim;
199 sp = data_buffer + k * dbH->dim; 200 sp = data_buffer + k * adb->header->dim;
200 DD[j][k] = 0.0; // Initialize matched filter array 201 DD[j][k] = 0.0; // Initialize matched filter array
201 dp = &D[j][k]; // point to correlation cell j,k 202 dp = &D[j][k]; // point to correlation cell j,k
202 *dp = 0.0; // initialize correlation cell 203 *dp = 0.0; // initialize correlation cell
203 l = dbH->dim; // size of vectors 204 l = adb->header->dim; // size of vectors
204 while(l--) 205 while(l--)
205 *dp += *qp++ * *sp++; 206 *dp += *qp++ * *sp++;
206 } 207 }
207 208
208 // Matched Filter 209 // Matched Filter
794 error("failed to read data"); 795 error("failed to read data");
795 if(wL <= trackTable[track]) { // test for short sequences 796 if(wL <= trackTable[track]) { // test for short sequences
796 797
797 VERB_LOG(7,"%u.%jd.%u | ", track, (intmax_t) trackIndexOffset, trackTable[track]); 798 VERB_LOG(7,"%u.%jd.%u | ", track, (intmax_t) trackIndexOffset, trackTable[track]);
798 799
799 initialize_arrays(adb, spec, track, qpointers.nvectors, query, data_buffer, D, DD); 800 audiodb_initialize_arrays(adb, spec, track, qpointers.nvectors, query, data_buffer, D, DD);
800 801
801 if(spec->refine.flags & ADB_REFINE_DURATION_RATIO) { 802 if(spec->refine.flags & ADB_REFINE_DURATION_RATIO) {
802 VERB_LOG(3,"meanQdur=%f meanDBdur=%f\n", qpointers.mean_duration[0], dbpointers.mean_duration[track]); 803 VERB_LOG(3,"meanQdur=%f meanDBdur=%f\n", qpointers.mean_duration[0], dbpointers.mean_duration[track]);
803 } 804 }
804 805