/* WriteVQTable: Create VQ table in memory then write to file */ void WriteVQTable(ClusterSet *cs[], char *fn) { int s; VQTable vq; vq = CreateVQTab(fn,(short)info.tgtPK,tType,ck,swidth); for (s=1;s<=swidth[0];s++){ if (cs[s]->isTree) vq->tree[s] = AddBinEntries(cs[s],1,s); else vq->tree[s] = AddLinEntries(cs[s],s); if (trace&T_TOP) printf("[%d] ",cs[s]->numClust); } StoreVQTab(vq,fn); if (trace&T_TOP) printf("entries -> %s\n",fn); if(trace & T_TAB) PrintVQTab(vq); }
/* EXPORT->LoadVQTab: create a VQTable using defs in tabFN */ VQTable LoadVQTab(char *tabFN, short magic) { VQTable vq; Source src; short fmagic, numNodes, swidth[SMAX]; TreeType type; CovKind ck; VQNode n; int s,i; /* See if this VQ table already loaded */ if ((vq=FindVQTable(tabFN,magic)) != NULL) return vq; /* Load Definition Header Info and create table */ if(InitSource(tabFN,&src,NoFilter)<SUCCESS) HError(6110,"LoadVQTab: Can't open file %s", tabFN); fmagic = GetVal(&src,0,0,"magic number"); if (magic != 0 && magic != fmagic) HError(6170,"LoadVQTab: %s has magic=%d but reqd magic=%d", tabFN,fmagic,magic); type = (TreeType) GetVal(&src,linTree,binTree,"tree type"); ck = CKCheck((CovKind) GetVal(&src,DIAGC,NULLC,"cov kind")); numNodes = GetVal(&src,1,MAXVQNODES,"number of nodes"); swidth[0] = GetVal(&src,1,SMAX,"number of streams"); for (s=1; s<=swidth[0]; s++) swidth[s] = GetVal(&src,1,10000,"stream width"); vq = CreateVQTab(tabFN, fmagic, type, ck, swidth); /* Load Entries as unordered list */ for (i=1; i<=numNodes; i++){ s = GetVal(&src,1,SMAX,"stream index"); n = GetNode(&src,ck,swidth[s]); n->right = vq->tree[s]; vq->tree[s] = n; } vq->numNodes = numNodes; /* Sort Entries according to id numbers */ for (s=1; s<=swidth[0]; s++){ n = vq->tree[s]; vq->tree[s] = SortEntries(&n,1); } /* Close definition file and leave */ FClose(src.f,src.isPipe); return vq; }