********************************************************************
function: utility main for building codebooks from lattice descriptions
- last mod: $Id$
********************************************************************/
/* The purpose of this util is just to finish packaging the
description into a static codebook. It used to count hits for a
histogram, but I've divorced that out to add some flexibility (it
- currently generates an equal probability codebook)
+ currently generates an equal probability codebook)
command line:
latticebuild description.vql
<n> <dim> <multiplicitavep> <sequentialp>
<value_0> <value_1> <value_2> ... <value_n-1>
-
+
a threshmap (or pigeonmap) struct is generated by latticehint;
there are fun tricks one can do with the threshmap and cascades,
but the utils don't know them...
fprintf(stderr,"Could not open input file %s\n",filename);
exit(1);
}
-
+
ptr=strrchr(filename,'.');
if(ptr){
*ptr='\0';
}
}
-
+
/* read the description */
line=get_line(in);
if(sscanf(line,"%d %d %d %d",&quantvals,&dim,&addmul,&sequencep)!=4){
reset_next_value();
line=setup_line(in);
- for(j=0;j<quantvals;j++){
+ for(j=0;j<quantvals;j++){
char *temp;
if(!line || sscanf(line,"%lf",quantlist+j)!=1){
fprintf(stderr,"Ran out of data on line 2 of description file\n");
for(j=1;j<quantvals;j++)if(quantlist[j]<min)min=quantlist[j];
for(j=0;j<quantvals;j++)
for(i=j+1;i<quantvals;i++)
- if(mindel==-1 || fabs(quantlist[j]-quantlist[i])<mindel)
- mindel=fabs(quantlist[j]-quantlist[i]);
+ if(mindel==-1 || fabs(quantlist[j]-quantlist[i])<mindel)
+ mindel=fabs(quantlist[j]-quantlist[i]);
j=0;
while(j<quantvals){
for(j=0;j<quantvals;j++){
- double test=fac*(quantlist[j]-min)/mindel;
- if( fabs(rint(test)-test)>.00001f) break;
+ double test=fac*(quantlist[j]-min)/mindel;
+ if( fabs(rint(test)-test)>.00001f) break;
}
if(fac>100)break;
if(j<quantvals)fac++;
/* save the book in C header form */
write_codebook(stdout,name,&c);
fprintf(stderr,"\r "
- "\nDone.\n");
+ "\nDone.\n");
exit(0);
}