/** Update the previous state map.*/ void LexicalReorderingFeatureFunction::updateTarget() { m_prevStates.clear(); m_accumulator.ZeroAll(); const Hypothesis * currHypo = getSample().GetTargetTail(); LRStateHandle prevState(dynamic_cast<const LexicalReorderingState*>(m_mosesLexReorder->EmptyHypothesisState(currHypo->GetInput()))); while ((currHypo = (currHypo->GetNextHypo()))) { LRStateHandle currState(dynamic_cast<const LexicalReorderingState*>(m_mosesLexReorder->Evaluate(currHypo->GetTranslationOption(),prevState.get(),&m_accumulator))); for (size_t i = 0; i < currHypo->GetCurrTargetWordsRange().GetNumWordsCovered(); ++i) { m_prevStates.push_back(prevState); } prevState = currState; } }
void SingleStateFeatureFunction::updateTarget() { //Update the prevStates map, and the cached scores m_prevStates.clear(); m_accumulator.ZeroAll(); const Moses::Hypothesis* currHypo = getSample().GetTargetTail(); StateHandle prevState( m_mosesFeature->EmptyHypothesisState(currHypo->GetInput())); while ((currHypo = (currHypo->GetNextHypo()))) { StateHandle currState(m_mosesFeature->Evaluate( *currHypo, prevState.get(), &m_accumulator)); for (size_t i = 0; i < currHypo->GetCurrTargetWordsRange(). GetNumWordsCovered(); ++i) { m_prevStates.push_back(prevState); } prevState = currState; } }
/** * Checks for the number of neighbors that are in an active state */ int gameOfLife::getNumActiveNeighbors(int colIndex, int rowIndex) { int ret = 0; int prevCol = colIndex-1; int nextCol = colIndex+1; int prevRow = rowIndex-1; int nextRow = rowIndex+1; ret += currState(prevCol, prevRow); ret += currState(prevCol, rowIndex); ret += currState(prevCol, nextRow); ret += currState(colIndex, prevRow); ret += currState(colIndex, nextRow); ret += currState(nextCol, prevRow); ret += currState(nextCol, rowIndex); ret += currState(nextCol, nextRow); return ret; }
void hsplua_cmd::hl_gcinc() { // インクリメンタルGC lua_gc(currState(), LUA_GCINC, 0); return; }
void hsplua_cmd::hl_gcstop() { // GC停止 lua_gc(currState(), LUA_GCSTOP, 0); return; }
void hsplua_cmd::hl_gcgen() { // 世代別GC lua_gc(currState(), LUA_GCGEN, 0); return; }
int hsplua_func::hl_gcisrunning() { // GCが実行中かどうかを返す ref_val.ival = lua_gc(currState(), LUA_GCISRUNNING, 0); return HSPVAR_FLAG_INT; }
void hsplua_cmd::hl_gcsetstepmul() { // GCステップ係数設定 stat = lua_gc(currState(), LUA_GCSETSTEPMUL, exinfo->HspFunc_prm_geti()); return; }
void hsplua_cmd::hl_gcsetpause() { // GC停止期間設定 stat = lua_gc(currState(), LUA_GCSETPAUSE, exinfo->HspFunc_prm_geti()); return; }
void hsplua_cmd::hl_gcstep() { // GCステップ実行 stat = lua_gc(currState(), LUA_GCSTEP, exinfo->HspFunc_prm_geti()); return; }
int hsplua_func::hl_gccount() { // Luaが使用しているメモリの量 ref_val.dval = (double)lua_gc(currState(), LUA_GCCOUNTB, 0) + (double)(lua_gc(currState(), LUA_GCCOUNT, 0) * 1024); return HSPVAR_FLAG_DOUBLE; }
void hsplua_cmd::hl_gccollect() { // GC実行 lua_gc(currState(), LUA_GCCOLLECT, 0); return; }
void hsplua_cmd::hl_gcrestart() { // GC再開 lua_gc(currState(), LUA_GCRESTART, 0); return; }