Mercurial > hg > audiodb
comparison audioDB.cpp @ 190:f56c530750da no-big-mmap
remove two more uses of dataBuf
Instead of using the newly-inserted vectors to compute the L2 norms, we
can use the input files' data.
author | mas01cr |
---|---|
date | Fri, 16 Nov 2007 18:21:37 +0000 |
parents | 0280c3f57b6f |
children | b7400fabbb94 |
comparison
equal
deleted
inserted
replaced
189:0280c3f57b6f | 190:f56c530750da |
---|---|
617 | 617 |
618 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); | 618 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); |
619 | 619 |
620 // Norm the vectors on input if the database is already L2 normed | 620 // Norm the vectors on input if the database is already L2 normed |
621 if(dbH->flags & O2_FLAG_L2NORM) | 621 if(dbH->flags & O2_FLAG_L2NORM) |
622 unitNormAndInsertL2((double*)(((char *) dataBuf) + insertoffset), dbH->dim, numVectors, 1); // append | 622 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors, 1); // append |
623 | 623 |
624 // Report status | 624 // Report status |
625 status(dbName); | 625 status(dbName); |
626 if(verbosity) { | 626 if(verbosity) { |
627 cerr << COM_INSERT << " " << dbName << " " << numVectors << " vectors " | 627 cerr << COM_INSERT << " " << dbName << " " << numVectors << " vectors " |
788 | 788 |
789 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); | 789 insert_data_vectors(insertoffset, indata + sizeof(int), statbuf.st_size - sizeof(int)); |
790 | 790 |
791 // Norm the vectors on input if the database is already L2 normed | 791 // Norm the vectors on input if the database is already L2 normed |
792 if(dbH->flags & O2_FLAG_L2NORM) | 792 if(dbH->flags & O2_FLAG_L2NORM) |
793 unitNormAndInsertL2((double*)(((char *) dataBuf) + insertoffset), dbH->dim, numVectors, 1); // append | 793 unitNormAndInsertL2((double *)(indata + sizeof(int)), dbH->dim, numVectors, 1); // append |
794 | 794 |
795 totalVectors+=numVectors; | 795 totalVectors+=numVectors; |
796 | 796 |
797 // Copy the header back to the database | 797 // Copy the header back to the database |
798 memcpy (db, dbH, sizeof(dbTableHeaderT)); | 798 memcpy (db, dbH, sizeof(dbTableHeaderT)); |
1083 initTables(dbName, inFile); | 1083 initTables(dbName, inFile); |
1084 | 1084 |
1085 // For each input vector, find the closest pointNN matching output vectors and report | 1085 // For each input vector, find the closest pointNN matching output vectors and report |
1086 // we use stdout in this stub version | 1086 // we use stdout in this stub version |
1087 unsigned numVectors = (statbuf.st_size-sizeof(int))/(sizeof(double)*dbH->dim); | 1087 unsigned numVectors = (statbuf.st_size-sizeof(int))/(sizeof(double)*dbH->dim); |
1088 | 1088 |
1089 double* query = (double*)(indata+sizeof(int)); | 1089 double* query = (double*)(indata+sizeof(int)); |
1090 double* data = dataBuf; | 1090 double* data = dataBuf; |
1091 double* queryCopy = 0; | 1091 double* queryCopy = 0; |
1092 | 1092 |
1093 if( dbH->flags & O2_FLAG_L2NORM ){ | 1093 if( dbH->flags & O2_FLAG_L2NORM ){ |
2638 while(d--){ | 2638 while(d--){ |
2639 *l2ptr+=*p**p; | 2639 *l2ptr+=*p**p; |
2640 p++; | 2640 p++; |
2641 } | 2641 } |
2642 l2ptr++; | 2642 l2ptr++; |
2643 /* | |
2644 oneOverL2 = 1.0/(*l2ptr++); | |
2645 d=dim; | |
2646 while(d--){ | |
2647 *X*=oneOverL2; | |
2648 X++; | |
2649 } | |
2650 */ | |
2651 X+=dim; | 2643 X+=dim; |
2652 } | 2644 } |
2653 unsigned offset; | 2645 unsigned offset; |
2654 if(append) { | 2646 if(append) { |
2655 // FIXME: a hack, a very palpable hack: the vectors have already | 2647 // FIXME: a hack, a very palpable hack: the vectors have already |