void HMM::smoother(int iseq, double* c, double* beta, double* Z) { int si = o->sind[iseq]; // start index of the current sequence int sl = o->slen[iseq]; // length of the current sequence uint32_t* y_ = o->y + si; // pointer to the current sequence double one = 1; // initialize: fill last frame of beta with ones vfill(&one, beta + (sl-1)*hs, 1, hs); for(int t = sl - 2; t > -1; t--) { double* out = beta + t*hs; vmul(beta + (t+1)*hs, 1, g + y_[t+1], os, Z, 1, hs); // using out as a temp vector because in cblas_dgemv, x cannot be y cblas_dgemv(CblasRowMajor, CblasNoTrans, hs, hs, 1, Q, hs, Z, 1, 0, out, 1); vsdiv(out, 1, c + t+1, out, 1, hs); } }
void vIn_next_a(IOUnit *unit, int inNumSamples) { World *world = unit->mWorld; int bufLength = world->mBufLength; int numChannels = unit->mNumOutputs; float fbusChannel = ZIN0(0); if (fbusChannel != unit->m_fbusChannel) { unit->m_fbusChannel = fbusChannel; int busChannel = (uint32)fbusChannel; int lastChannel = busChannel + numChannels; if (!(busChannel < 0 || lastChannel > (int)world->mNumAudioBusChannels)) { unit->m_bus = world->mAudioBus + (busChannel * bufLength); unit->m_busTouched = world->mAudioBusTouched + busChannel; } } float *in = unit->m_bus; int32 *touched = unit->m_busTouched; int32 bufCounter = unit->mWorld->mBufCounter; for (int i=0; i<numChannels; ++i, in += bufLength) { ACQUIRE_BUS_AUDIO_SHARED((int32)fbusChannel + i); float *out = OUT(i); if (touched[i] == bufCounter) { vcopy(out, in, inNumSamples); } else { vfill(out, 0.f, inNumSamples); } RELEASE_BUS_AUDIO_SHARED((int32)fbusChannel + i); } }
/* Routine to process a transitive verb */ trverb() { switch(verb){ case CALM: case WALK: case QUIT: case SCORE: case FOO: case BRIEF: case SUSPEND: case HOURS: case LOG: actspk(verb); break; case TAKE: vtake(); break; case DROP: vdrop(); break; case OPEN: case LOCK: vopen(); break; case SAY: vsay(); break; case NOTHING: rspeak(54); break; case ON: von(); break; case OFF: voff(); break; case WAVE: vwave(); break; case KILL: vkill(); break; case POUR: vpour(); break; case EAT: veat(); break; case DRINK: vdrink(); break; case RUB: if (object != LAMP) rspeak(76); else actspk(RUB); break; case THROW: vthrow(); break; case FEED: vfeed(); break; case FIND: case INVENTORY: vfind(); break; case FILL: vfill(); break; case READ: vread(); break; case BLAST: vblast(); break; case BREAK: vbreak(); break; case WAKE: vwake(); break; default: printf("This verb is not implemented yet.\n"); } }
/* CARRY TAKE etc. */ vtake() { int msg; int i; if (toting(object)) { actspk(verb); return; } /* special case objects and fixed objects */ msg = 25; if (object == PLANT && prop[PLANT] <= 0) msg = 115; if (object == BEAR && prop[BEAR] == 1) msg = 169; if (object == CHAIN && prop[BEAR] != 0) msg = 170; if (fixed[object]) { rspeak(msg); return; } /* special case for liquids */ if (object == WATER || object == OIL) { if (!here(BOTTLE) || liq() != object) { object = BOTTLE; if (toting(BOTTLE)&&prop[BOTTLE] == 1){ vfill(); return; } if (prop[BOTTLE] != 1) msg = 105; if (!toting(BOTTLE)) msg = 104; rspeak(msg); return; } object = BOTTLE; } if (holding >= 7) { rspeak(92); return; } /* special case for bird. */ if (object == BIRD && prop[BIRD] == 0) { if (toting(ROD)) { rspeak(26); return; } if (!toting(CAGE)) { rspeak(27); return; } prop[BIRD] = 1; } if ( (object == BIRD || object == CAGE) && prop[BIRD] != 0) carry((BIRD+CAGE)-object,loc); carry(object,loc); /* handle liquid in bottle */ i = liq(); if (object == BOTTLE && i != 0) place[i] = -1; rspeak(54); }