/* Initialise: set up global data storage */ void Initialise(char *datafn) { ParmBuf pbuf; int s; Boolean eSep; CreateHeap(&iStack,"inBuf", MSTAK, 1, 0.5, 100000, LONG_MAX); CreateHeap(&dStack,"seqStack", MSTAK, 1, 0.5, 100000, LONG_MAX); CreateHeap(&cStack,"clustStack",MSTAK, 1, 0.5, 100000, LONG_MAX); /* Peek at first data file to get observation format */ if((pbuf = OpenBuffer(&iStack, datafn, 0, UNDEFF, FALSE_dup, FALSE_dup))==NULL) HError(2550,"Initialise: Config parameters invalid"); GetBufferInfo(pbuf, &info); CloseBuffer(pbuf); ResetHeap(&iStack); /* set/validate stream widths */ if(swidth[0] > 0) CheckStreamWidths(info); else ZeroStreamWidths(1,swidth); /* Create an observation to hold the input parameters */ SetStreamWidths(info.tgtPK,info.tgtVecSize,swidth,&eSep); obs = MakeObservation(&gstack,swidth,info.tgtPK,FALSE,eSep); if (segLab != NULL) segId = GetLabId(segLab,TRUE); /* Create sequences to hold all data*/ for (s=1;s<=swidth[0];s++) dSeq[s] = CreateSequence(&dStack,4096); }
// Implement the command interface void ARec::ExecCommand(const string & cmdname) { char buf[100]; if (cmdname == "start") StartCmd(); else if (cmdname == "stop") StopCmd(); else if (cmdname == "setmode") SetModeCmd(); else if (cmdname == "usegrp") UseGrpCmd(); else if (cmdname == "setnbest") { if(nBest==0) { CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); } int nb; if (!GetIntArg(nb, 1, 100000)) HPostMessage(HThreadSelf(),"Setnbest, n-best num expected\n"); nBest=nb; } else { sprintf(buf,"Unknown command %s\n", cmdname.c_str()); HPostMessage(HThreadSelf(),buf); } }
/* EXPORT->InitLabel: initialise module */ void InitLabel(void) { int i; Boolean b; double d; char str[MAXSTRLEN]; Register(hlabel_version,hlabel_vc_id); CreateHeap(&namecellHeap,"namecellHeap",MSTAK,1,0.5,5000,20000); for (i=0;i<HASHSIZE;i++) hashtab[i] = NULL; CreateHeap(&mlfHeap,"mlfHeap",MSTAK,1,0.5,10000,50000); numParm = GetConfig("HLABEL", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,numParm,"STRIPTRIPHONES",&b)) stripTriPhones = b; if (GetConfBool(cParm,numParm,"V1COMPAT",&b)) compatMode = b; if (GetConfStr(cParm,numParm,"LABELSQUOTE",str)) labelQuote=str[0]; if (GetConfInt(cParm,numParm,"TRANSALT",&i)) transAlt = i; if (GetConfInt(cParm,numParm,"TRANSLEV",&i)) transLev = i; if (GetConfFlt(cParm,numParm,"HTKLABELTIMESCALE",&d)) htkLabelTimeScale = d; } }
la->end = lat->lnodes+2+i; la->lmlike = log(1.0/(float) (voc->nwords)); la++; } for (i = 0; i < voc->nwords; i++) { la->start = lat->lnodes+2+i; la->end = lat->lnodes+nNode-2; la->lmlike = 0.0; la++; } /* finally overwrite start/end !NULL words if sil at start/end */ if (bStartId != NULL) { wd = GetWord(voc,bStartId,TRUE); ln = lat->lnodes; ln->word = wd; wd = GetWord(voc,bEndId,TRUE); ln = lat->lnodes+nNode-1; ln->word = wd; } return lat; } /*ProcessBoBiGram: Convert back-off bigram in nLM into lattice */ Lattice *ProcessBoBiGram(MemHeap *latHeap, Vocab *voc, NGramLM *nLM) { int nNode,nArc; NEntry *ne; SEntry *se; Word wd,fromWd,toWd; LNode *ln,*fromNode,*toNode;
// ARec constructor ARec::ARec(const string & name, ABuffer *inb, ABuffer *outb, ARMan *armgr, int nnToks) : AComponent(name,(HasRealConsole()?2:ARECPRBUFSIZE)) { ConfParam *cParm[MAXGLOBS]; /* config parameters */ int numParm; int i; double f; Boolean b; char buf[100]; in = inb; out = outb; rmgr = armgr; strcpy(buf,name.c_str()); for (i=0; i<int(strlen(buf)); i++) buf[i] = toupper(buf[i]); numParm = GetConfig(buf, TRUE, cParm, MAXGLOBS); trace=0; width = 400; height=120; showRD = FALSE; sampPeriod = 100000.0; stTime = 0.0; rdx0 = 420; rdy0 =280; runmode = RunMode(CONTINUOUS_MODE+FLUSH_TOMARK+STOP_ATMARK+RESULT_ATEND); runstate = WAIT_STATE; laststate = RunState(-1); nToks = nnToks; wordPen = 0.0; lmScale = 1.0; ngScale=0.0; prScale = 1.0; genBeam = nBeam = 225.0; wordBeam = 200.0; maxActive = 0; grpName = ""; trbakFreq = 5; outseqnum = 0; inlevel = -1; trbakFrame = 0; trbakAc = 0.0; trbakCount = 0; trbakLastWidth=0; nBest=0; if (numParm>0){ if (GetConfBool(cParm,numParm,"DISPSHOW",&b)) showRD = b; if (GetConfInt(cParm,numParm,"DISPXORIGIN",&i)) rdx0 = i; if (GetConfInt(cParm,numParm,"DISPYORIGIN",&i)) rdy0 = i; if (GetConfInt(cParm,numParm,"DISPWIDTH",&i)) width = i; if (GetConfInt(cParm,numParm,"DISPHEIGHT",&i)) height = i; if (GetConfInt(cParm,numParm,"RUNMODE",&i)) runmode = RunMode(i); if (GetConfInt(cParm,numParm,"NTOKS",&i)) nToks = i; if (GetConfFlt(cParm,numParm,"WORDPEN",&f)) wordPen = float(f); if (GetConfFlt(cParm,numParm,"LMSCALE",&f)) lmScale = float(f); if (GetConfFlt(cParm,numParm,"NGSCALE",&f)) ngScale = float(f); if (GetConfFlt(cParm,numParm,"PRSCALE",&f)) prScale = float(f); if (GetConfFlt(cParm,numParm,"GENBEAM",&f)) genBeam = float(f); if (GetConfFlt(cParm,numParm,"WORDBEAM",&f)) wordBeam = float(f); if (GetConfFlt(cParm,numParm,"NBEAM",&f)) nBeam = float(f); if (GetConfInt(cParm,numParm,"MAXBEAM",&i)) maxActive = i; if (GetConfStr(cParm,numParm,"GRPNAME",buf)) grpName=string(buf); if (GetConfInt(cParm,numParm,"TRBAKFREQ",&i)) trbakFreq = i; if (GetConfFlt(cParm,numParm,"TARGETRATE",&f)) sampPeriod = float(f); if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfInt(cParm,numParm,"NBEST",&i)) nBest = i; } if (nBeam < genBeam) nBeam = genBeam; if ((runmode&RESULT_ASAP) || (runmode&RESULT_IMMED)) runmode = RunMode(runmode|RESULT_ATEND); if(nBest>0){ CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); } }
HError(-1189,"HList: Warning ALIEN src file format set"); break; case 'T': trace = GetChkedInt(0,077,s); break; default: HError(1119,"HList: Unknown switch %s",s); } } if (NumArgs() == 0 ) ListSpeech(NULL); else while (NumArgs() > 0 ) { if (NextArg() != STRINGARG) HError(1119,"HList: List file name expected"); ListSpeech(GetStrArg()); } Exit(0); return (0); /* never reached -- make compiler happy */ } /* -------------------- Display Routines ------------------- */ typedef struct{ /* gather together basic header info */ char *name; Boolean isSource; Boolean isAudio; FileFormat fmt;
/* EXPORT->InitUtil: initialise configuration parameters */ void InitUtil(void) { int i; Register(hutil_version); nParm = GetConfig("HUTIL", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; } CreateHeap(&itemHeap,"HUtil: ItemList Heap",MHEAP,sizeof(ItemRec), 1.0,200,8000); CreateHeap(&setHeap,"HUtil: IntSet Heap",MSTAK,1,1.0,2000,16000); }
void Initialise(char *hmmListFn) { /* Stacks for global structures requiring memory allocation */ CreateHeap(&aSetStack,"ASetStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&sSetStack,"SSetStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&wsStack,"WsStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&labIdStack,"LabIdStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&wtAccStack,"WtAccStore", MSTAK, 1, 0.0, 1000, 1000); /* Load HMMs and init HMMSet related global variables */ if(MakeHMMSet( &hset, hmmListFn )<SUCCESS) HError(2429,"Initialise: MakeHMMSet failed"); if(LoadHMMSet( &hset,hmmDir,newExt)<SUCCESS) HError(2429,"Initialise: LoadHMMSet failed"); AttachAccs(&hset, &gstack,uFlags); ZeroAccs(&hset,uFlags); nPhyHmms = hset.numPhyHMM; nLogHmms = hset.numLogHMM; vSize = hset.vecSize; nStreams = hset.swidth[0]; maxMixes = MaxMixInSet(&hset); maxStates = MaxStatesInSet(&hset); hsKind = hset.hsKind; /* Store for mix weights accs from each input acc file */ CreateWtStore(&wtAccStack); if ((hsKind != TIEDHS) && (hsKind != DISCRETEHS)) HError(2421,"Initialise: HMM's must be full Tied Mixture or Discrete"); if (trace&T_TOP) { printf("HSmooth Updating: "); if (uFlags&UPTRANS) printf("Transitions "); if (uFlags&UPMEANS) printf("Means "); if (uFlags&UPVARS) printf("Variances "); if (uFlags&UPMIXES && maxMixes>1) printf("MixWeights "); printf("\n "); printf(" Max Steps: %d, Epsilon : %f, Max Mixes: %d\n", maxStep,epsilon,maxMixes); printf("%d Logical/%d Physical Models Loaded, VecSize=%d\n",nLogHmms,nPhyHmms,vSize); fflush(stdout); } SetVFloor( &hset, vFloor, minVar); aSet=(HLink *)New(&aSetStack, nPhyHmms*sizeof(HLink)); --aSet; sSet=(StreamElem **)New(&sSetStack, nPhyHmms*sizeof(StreamElem *)); --sSet; }
/* EXPORT->InitMem: Initialise the module. */ void InitMem(void) { int i; Boolean b; Register(hmem_version, hmem_vc_id); CreateHeap(&gstack, "Global Stack", MSTAK, 1, 0.0, 100000, ULONG_MAX ); /* #### should be max size_t */ CreateHeap(&gcheap, "Global C Heap", CHEAP, 1, 0.0, 0, 0 ); numParm = GetConfig("HMEM", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; if (GetConfBool(cParm,numParm,"PROTECTSTAKS",&b)) protectStaks = b; } }
/* EXPORT->InitVocab: Initialise voc data structure */ void InitVocab(Vocab *voc) { CreateHeap(&voc->wordHeap,"Word Heap",MHEAP,sizeof(DictEntry), 0.4,200,2000); CreateHeap(&voc->pronHeap,"Pron Heap",MHEAP,sizeof(WordPron), 0.4,200,2000); CreateHeap(&voc->phonesHeap,"Phones Heap",MSTAK,1,0.4,400,4000); voc->wtab = (Word*) New(&voc->phonesHeap,sizeof(Word)*VHASHSIZE); for (int i=0; i<VHASHSIZE; i++) voc->wtab[i] = NULL; voc->nullWord = GetWord(voc, GetLabId("!NULL",TRUE), TRUE); voc->subLatWord = GetWord(voc, GetLabId("!SUBLATID",TRUE), TRUE); voc->nwords = voc->nprons = 0; }
/* EXPORT-> MakeXGraf: Create and open window, initialization */ void MakeXGraf(char *wname, int x, int y, int w, int h, int bw) /* WIN32: bw is ignored. */ { WNDCLASS WindowClass; char sbuf[256], *hgraf = "HGraf"; HDC dc; if (winCreated) HError(6870, "MakeXGraf: Attempt to recreate the graphics window"); WindowClass.hInstance = GetModuleHandle(NULL); WindowClass.lpszClassName = hgraf; WindowClass.lpfnWndProc = HGWinFunc; WindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; WindowClass.hIcon = NULL; WindowClass.hCursor = LoadCursor(NULL,IDC_ARROW); WindowClass.lpszMenuName = NULL; WindowClass.cbClsExtra = 0; WindowClass.cbWndExtra = 0; WindowClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); RegisterClass(&WindowClass); strcpy(sbuf, hgraf); strcat(sbuf, ": "); strcat(sbuf, wname); theWindow = CreateWindow(hgraf, sbuf, WS_OVERLAPPEDWINDOW | WS_VISIBLE, x,y, w,h, HWND_DESKTOP, NULL, WindowClass.hInstance, NULL); /* adjust window size so that the client rectangle is the size requested */ /* by the caller of MakeXGraf() --- Win32 interprets w and h as the dimensions */ /* of the overall window. */ GetClientRect(theWindow,&ClientRect); MoveWindow(theWindow,x,y,w+w-ClientRect.right,h+h-ClientRect.bottom,TRUE); GetClientRect(theWindow,&ClientRect); /* Obtain and initialize device contexts */ dc = GetDC(theWindow); memDC = CreateCompatibleDC(dc); SetArcDirection(memDC,AD_COUNTERCLOCKWISE); SetArcDirection(dc,AD_COUNTERCLOCKWISE); SetPolyFillMode(memDC,WINDING); SetPolyFillMode(memDC,WINDING); SetTextAlign(memDC,TA_BASELINE | TA_LEFT); SetTextAlign(dc,TA_BASELINE | TA_LEFT); SetBkMode(memDC,TRANSPARENT); SetBkMode(dc,TRANSPARENT); theBitmap = CreateCompatibleBitmap(dc,w,h); SelectObject(memDC,theBitmap); ReleaseDC(theWindow,dc); CreateHeap(&btnHeap, "Button heap", MHEAP, sizeof(HButton), 1.0, 100, 100); InitGlobals(); InstallColours(); winCreated = TRUE; HSetColour(WHITE); HFillRectangle(0,0,ClientRect.right,ClientRect.bottom); }
int main(){ printf("\nLets create heap\n"); getch(); Heap* heap=CreateHeap(1); int n; printf("\nEnter the number of elements you want to create array with : "); scanf("%d",&n); int* Array=(int*)malloc(sizeof(int)*n); int i; printf("\nEnter elements of array\n"); for(i=0;i<n;i++){ scanf("%d",&Array[i]); } printf("\nEnter the value of k : "); int k; scanf("%d",&k); BuildHeap(heap,Array,k+1); printf("\nPress enter to get sort elements\n"); getch(); SortAll(heap,Array,n,k); printf("\nSorted\n\n"); //In place sorting in Array itself for(i=0;i<n;i++){ printf("%d ",Array[i]); } getch(); return 0; }
/* LoadMgeTrnHmmFile: */ static void LoadMgeTrnHmmFile(int nIter) { char hext[15], hmmFile[255]; ResetHeap(&hmmStack); CreateHeap(&hmmStack, "Model Stack", MSTAK, 1, 1.0, 80000, 400000); sprintf(hext, "mmf%d", nIter); MakeFN(mmfFn, outDir, hext, hmmFile); CreateHMMSet(&hset, &hmmStack, TRUE); AddMMF(&hset, hmmFile); if (trace & T_TOP) printf("Loading MGE-trained HMM in iteration %d ... ... \n", nIter); if (MakeHMMSet(&hset, hmmListFn) < SUCCESS) HError(2321, "Initialise: MakeHMMSet failed"); if (LoadHMMSet(&hset, hmmDir, hmmExt) < SUCCESS) HError(2321, "Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); /* variance inversion, MGE training only support INVDIAGC case */ ConvDiagC(&hset, TRUE); if (funcType == MGE_TRAIN) AttachAccToModel(); }
/* EXPORT->InitLVRec: register module & set configuration parameters */ void InitLVRec(void) { double f; int i; Boolean b; Register (hlvrec_version, hlvrec_vc_id); nParm = GetConfig("HLVREC", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfFlt (cParm, nParm, "MAXLMLA", &f)) maxLMLA = f; if (GetConfBool (cParm, nParm, "BUILDLATSENTEND",&b)) buildLatSE = b; if (GetConfBool (cParm, nParm, "FORCELATOUT",&b)) forceLatOut = b; if (GetConfInt (cParm, nParm,"GCFREQ", &i)) gcFreq = i; if (GetConfBool (cParm, nParm, "PDE",&b)) pde = b; } #if 0 printf ("sizeof(Token) = %d\n", sizeof (Token)); printf ("sizeof(LexNodeInst) = %d\n", sizeof (LexNodeInst)); printf ("sizeof(WordendHyp) = %d\n\n", sizeof (WordendHyp)); #endif CreateHeap (&recCHeap, "Decoder CHEAP", CHEAP, 1, 1.5, 10000, 100000); }
/* EXPORT->InitLVRec: register module & set configuration parameters */ void InitLVRec(void) { double f; int i; Boolean b; Register (hlvrec_version, hlvrec_vc_id); nParm = GetConfig("HLVREC", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i; if (GetConfFlt (cParm, nParm, "MAXLMLA", &f)) maxLMLA = f; if (GetConfBool (cParm, nParm, "BUILDLATSENTEND",&b)) buildLatSE = b; if (GetConfBool (cParm, nParm, "FORCELATOUT",&b)) forceLatOut = b; if (GetConfInt (cParm, nParm,"GCFREQ", &i)) gcFreq = i; if (GetConfBool (cParm, nParm, "PDE",&b)) pde = b; if (GetConfBool (cParm, nParm, "USEOLDPRUNE",&b)) useOldPrune = b; if (GetConfBool (cParm, nParm, "MERGETOKONLY",&b)) mergeTokOnly = b; if (GetConfFlt (cParm, nParm, "MAXLNBEAMFLR", &f)) maxLNBeamFlr = f; if (GetConfFlt (cParm, nParm, "DYNBEAMINC", &f)) dynBeamInc = f; if (useOldPrune) { mergeTokOnly = FALSE; maxLNBeamFlr = 0.0; dynBeamInc = 1.1; } } #if 0 printf ("sizeof(Token) = %d\n", sizeof (Token)); printf ("sizeof(LexNodeInst) = %d\n", sizeof (LexNodeInst)); printf ("sizeof(WordendHyp) = %d\n\n", sizeof (WordendHyp)); #endif CreateHeap (&recCHeap, "Decoder CHEAP", CHEAP, 1, 1.5, 10000, 100000); }
int main() { int a[16]={1,2,3,4,5,6,7,8,9}; CreateHeap(a); heaptravel(head); displayheap1(head); printf("\n"); displayheap2(head); getchar(); }
/* EXPORT->InitVQ: initialise the VQ module */ void InitVQ(void) { int i; Register(hvq_version); numParm = GetConfig("HVQ", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; } CreateHeap(&vqHeap,"vqHeap",MSTAK,1,0.2,2000,10000); }
/* ----------------------------------------------------------- */ char *lutil_version = "!HVER!LUtil: 3.4 [CUED 25/04/06]"; char *lutil_vc_id = "$Id: LUtil.c,v 1.1.1.1 2006/10/11 09:54:43 jal58 Exp $";
/* EXPORT->InitSigP: initialise the SigP module */ void InitSigP(void) { int i; Register(hsigp_version,hsigp_vc_id); numParm = GetConfig("HSIGP", TRUE, cParm, MAXGLOBS); if (numParm>0){ if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i; } CreateHeap(&sigpHeap,"sigpHeap",MSTAK,1,0.0,5000,5000); }
printf(" -i n add id n to filter list none\n"); printf(" -f w add word w to filter list none\n"); PrintStdOpts(""); printf("\n\n"); }
MemoryManager::MemoryManager() { heaps = (HeapData *)malloc(sizeof(HeapData) * MM_MAX_NUM_HEAPS); #if MM_LOG_MEMORY_LEAKS for(int heapIndex = 0; heapIndex < MM_MAX_NUM_HEAPS; ++heapIndex) { // We must explicitly call the HeapLog constructor because the memory was malloc'd new (&heaps[heapIndex].log) HeapLog(); } #endif InitializeCriticalSection(&criticalSection); CreateHeap(32 * 1024 * 1024, "Main Game Thread Heap1"); }
NBNodeHeap *CreateNodeHeap(size_t nehSize,size_t fhiSize) { NBNodeHeap *nodeheap; nodeheap=New(&gcheap,MRound(sizeof(NBNodeHeap))+MRound(fhiSize)); CreateHeap(&nodeheap->nehHeap,"NodeHeap Entries", MHEAP, sizeof(NBNodeEntry)+nehSize, 0.0, 200, 4000); nodeheap->info=(Ptr)(((char*)nodeheap)+MRound(sizeof(NBNodeHeap))); nodeheap->isize=nehSize; nodeheap->count=nodeheap->exps=nodeheap->length=0; nodeheap->head=NULL; nodeheap->id=1; return nodeheap; }
void LoadNetwork() { FILE *nf; Boolean isPipe; int n=0; CreateHeap(&wdNetHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); if ( (nf = FOpen(wdNetFn,NetFilter,&isPipe)) == NULL) HError(3210,"LoadNetwork: Cannot open Word Net file %s",wdNetFn); if((wdNet = ReadLattice(nf,&wdNetHeap,&vocab,TRUE,FALSE))==NULL) HError(3210,"LoadNetwork: ReadLattice failed"); FClose(nf,isPipe); printf("Read Word Network with %d nodes / %d arcs\n",wdNet->nn,wdNet->na); CreateHeap(&netHeap,"Net heap",MSTAK,1,0, wdNet->na*sizeof(NetLink),wdNet->na*sizeof(NetLink)); net = ExpandWordNet(&netHeap,wdNet,&vocab,&hset); printf("Created network with %d nodes / %d links\n", net->numNode,net->numLink); }
int main() { SetWindow(); Castle ct; // define Castle ct.Xstrt = CastleXStrt; ct.Ystrt = CastleYStrt; ct.W = CastleWidth; ct.L = CastleLength; int NA = 0, NB = 0, NC = 0, ND = 0; int DA = 0, DB = 0, DC = 0, DD = 0; int DAL = 0, DBL = 0, DCL = 0, DDL = 0; int EnemiesNumber = GetEnemiesNumber(NA, NB, NC, ND); Heap *ActiveA=CreateHeap(NA); Heap *ActiveB = CreateHeap(NB); Heap *ActiveC = CreateHeap(NC); Heap *ActiveD = CreateHeap(ND); Queue *Inactive = CreateQueue(); DLL *Dead = CreateDLL(); Constants C = { 0, 0, 0 }; if (Read(Inactive, &ct, C)) { int Mode; cout << "Please Choose Game Mode: \n1: Interactive Mode\n2: Step-by-step Mode\n3: Silent Mode\n"; cin >> Mode; int Result = 0; for (int GameTime = 1; Result == 0; GameTime++) { Result = SimulateBattle(&ct, Inactive, Dead, ActiveA, ActiveB, ActiveC, ActiveD, GameTime, C, Mode, NA, NB, NC, ND, DA, DB, DC, DD, DAL, DBL, DCL, DDL); if (Mode == 1) _getch(); else if (Mode == 2) Sleep(1000); } PrintFile(Dead, &ct,Result,EnemiesNumber); }
int main(int argc, char *argv[]) { char *s; Initialise(argc,argv); CreateHeap(&modelHeap, "Model heap", MSTAK, 1, 0.0, 100000, 800000 ); CreateHMMSet(&hset,&modelHeap,TRUE); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(3219,"HNetTest: Bad switch %s; must be single letter",s); switch(s[0]){ case 'H': if (NextArg() != STRINGARG) HError(3219,"HNetTest: MMF File name expected"); AddMMF(&hset,GetStrArg()); break; default: HError(3219,"HNetTest: Unknown switch %s",s); } } if (NextArg()!=STRINGARG) HError(999,"HNetTest: Dictionary file name expected"); dictFn = GetStrArg(); if (NextArg()!=STRINGARG) HError(999,"HNetTest: Word Net file name expected"); wdNetFn = GetStrArg(); if (NextArg()!=STRINGARG) HError(999,"HNetTest: HMM list file name expected"); hmmListFn = GetStrArg(); if(MakeHMMSet(&hset,hmmListFn)<SUCCESS) HError(999,"HNetTest: MakeHMMSet failed"); if(LoadHMMSet(&hset,NULL,NULL)<SUCCESS) HError(999,"HNetTest: LoadHMMSet failed"); InitVocab(&vocab); if(ReadDict(dictFn,&vocab)<SUCCESS) HError(3213, "HNetTest: ReadDict failed"); LoadNetwork(); }
HTime period; int sampSize; int numComps; long nSamples; }HeadInfo; /* PrBar: print a horizantal bar of length n including title */ void PrBar(char *title) { int i,len,n; if (rawOut) return; len = strlen(title); n = (barwidth - len)/2; for (i=1; i<n; i++) putchar(barc); printf(" %s ",title); n = barwidth - n - len; for (i=1; i<n; i++) putchar(barc); putchar('\n'); } /* SetBarWidth: set bar width according to nItems and item type */ void SetBarWidth(int itemWidth)
static LMCache *CreateLMCache (DecoderInst *dec, MemHeap *heap) { LMCache *cache; int i; cache = (LMCache *) New (heap, sizeof (LMCache)); CreateHeap (&cache->nodeHeap, "LMNodeCache Heap", MHEAP, sizeof (LMNodeCache), 1.0, 1000, 2000); cache->nNode = dec->net->laTree->nNodes + dec->net->laTree->nCompNodes; cache->node = (LMNodeCache **) New (heap, cache->nNode * sizeof (LMNodeCache *)); for (i = 0; i < cache->nNode; ++i) cache->node[i] = NULL; cache->transHit = cache->transMiss = 0; cache->laHit = cache->laMiss = 0; return cache; }
int main(){ int N; scanf("%d", &N); Heap H = CreateHeap(N); ElementType * data = (ElementType *)malloc(sizeof(ElementType)*N); for(int i = 0; i<N; i++){ scanf("%d", data+i); Insert(H, data[i]); Show(H); } printf("Insert Finished\n"); int M = H->Size; while(!IsEmpty(H)){ printf("Max is: %d ", DeleteMax(H)); printf("Heap is:"); Show(H); } }
/* Initialise: load hmm and initialise global data structures */ void Initialise(void) { LabId hmmId; char base[MAXSTRLEN]; char path[MAXSTRLEN]; char ext[MAXSTRLEN]; int s; /* Stacks for global structures requiring memory allocation */ CreateHeap(&segmentStack,"SegStore", MSTAK, 1, 0.0, 100000, LONG_MAX); CreateHeap(&sequenceStack,"SeqStore", MSTAK, 1, 0.0, 10000, 10000); CreateHeap(&clustSetStack,"ClustSetStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&transStack,"TransStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&traceBackStack,"TraceBackStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&bufferStack,"BufferStore", MSTAK, 1, 0.0, 1000, 1000); CreateHeap(&msdinfoStack,"MSDInfoStore", MSTAK, 1, 0.0, 1000, 1000); /* Load HMM def */ if(MakeOneHMM( &hset, BaseOf(hmmfn,base))<SUCCESS) HError(2128,"Initialise: MakeOneHMM failed"); if(LoadHMMSet( &hset,PathOf(hmmfn,path),ExtnOf(hmmfn,ext))<SUCCESS) HError(2128,"Initialise: LoadHMMSet failed"); SetParmHMMSet(&hset); if ((hset.hsKind==DISCRETEHS)||(hset.hsKind==TIEDHS)) uFlags = (UPDSet) (uFlags & (~(UPMEANS|UPVARS))); AttachAccs(&hset, &gstack, uFlags); /* Get a pointer to the physical HMM and set related globals */ hmmId = GetLabId(base,FALSE); macroLink = FindMacroName(&hset,'h',hmmId); hmmLink = (HLink)macroLink->structure; nStates = hmmLink->numStates; nStreams = hset.swidth[0]; for(s=1; s<=nStreams; s++) maxMixInS[s] = MaxMixInS(hmmLink, s); msdInfo = CreateMSDInfo(&msdinfoStack, hmmLink); SetVFloor( &hset, vFloor, minVar); if(segLab != NULL) segId = GetLabId(segLab,TRUE); if(trace>0) PrintInitialInfo(); thisP = CreateVector(&gstack,nStates); lastP = CreateVector(&gstack,nStates); }
/* Initialise: initialise global data structures */ void Initialise(void) { int i; char path[256]; CreateHeap(&langHeap,"LModel mem",MSTAK,1,0.5,1000,20000); if (wlistFN!=NULL) { tgtVoc = &wlist; CreateWordList(wlistFN,tgtVoc,10); } if (processText) { /* init empty buffer */ CreateWordMap(NULL,&wmap,newWords); wmap.hasCnts = TRUE; wmap.name = defMapName; wmap.htkEsc = htkEscape; ++wmap.seqno; mapUpdated = FALSE; if (tgtVoc!=NULL) { /* add words from word list to the map */ pruneWords = TRUE; for (i=0; i<tgtVoc->used; i++) { AddWordToMap(&wmap,tgtVoc->id[i]); } SortWordMap(&wmap); unkId = GetLabId(unkStr,FALSE); } /* init ngram buffer */ MakeFN(rootFN,dbsDir,NULL,path); stdBuf.used = 0; stdBuf.ng[nSize] = 1; /* count = 1 */ stdBuf.ngb = CreateNGBuffer(&langHeap,nSize,ngbSize,path,&wmap); } else { CreateWordMap(omapFN,&wmap,1); } CreateInputSet(&gstack,&wmap,&inSet); binfo.wmap = &wmap; binfo.inSet = &inSet; binfo.nSize = nSize; }