Exemplo n.º 1
0
String DFA::debInfo() const {
	String s("DFA");
	s << " # states=" << numStates();
	s << " startState=" << startState() << "\n";
	for (int i = 0; i < numStates(); i++) {
		DFAState &state = getState(i);
#if !AUGMENT
		String work;
		if (state.flag(DFAState::F_FINAL)) {
			work << "F";
			if (state.finalCode() >= 0)
				work << state.finalCode();
		} 
		work.pad(3);
		s << work;
#else
		s << (char)(state.flag(DFAState::F_FINAL) ? '*' : ' ');
#endif
		s << (char)(state.flag(DFAState::F_DELETE) ? 'D' : ' ');
		s << (char)(state.flag(DFAState::F_VISITED) ? 'V' : ' ');
		s << fmt(i,3) << " ";
		s << state.transitionInfo();
		s << '\n';
	}
	return s;
}
Exemplo n.º 2
0
// construct a list of all possible symbols
void DFA::min_getSymbolSet(OrdSet &symbols) const {
	Array<int> symList;
	for (int i = 0; i < numStates(); i++) {
		DFAState &s = getState(i);
		s.getSymbols(symList);
		for (int j = 0; j < symList.length(); j++)
			symbols.add(symList.itemAt(j));
	}
}
Exemplo n.º 3
0
void DFA::addState(int s) {
	if (s < 0 || s >= MAX_STATES)
		throw Exception("Invalid state");
	// add new states if necessary between end of state
	// array and this state
	while (s >= numStates()) {
		states_.add(DFAState());
	}
}
Exemplo n.º 4
0
void ChanceNode::evaluate()
{
   pCPT = cpt;             // init ptr into the cpt      
   if ( parents.size() )   // is this node dependent?
      for ( int s=0; s<numStates(); s++ )
         if (!state[s]->flags.test(State::READ_ONLY) )
            setState( s, recursParent(0) );
         else
            recursParent(0);
}   
Exemplo n.º 5
0
void Faders::next(Cell* current, int index) {
	int alive, state, nextIndex;
	
	nextIndex = wrapi(index + 1, 0, 2);
	
	alive = current->countAliveNeighbors(index);
	state = current->states[index];
	if (state > 1) {
		if (state < numStates()) {
			current->states[nextIndex] = state + 1;
		}
		else
		{
			current->states[nextIndex] = 0;
		}
	}
	else
	{
		if (state == 0)
		{
			current->states[nextIndex] = _births[alive];
		}
		else
		{
			if (_survivals[alive] == 0) {
				if (state < numStates()) {
					current->states[nextIndex] = state + 1;
				}
				else
				{
					current->states[nextIndex] = 0;
				}
			}
			else
			{
				current->states[nextIndex] = 1;
			}
		}
	}
		
}
Exemplo n.º 6
0
int DFA::getTransitionState(int stateI, int symbol)
{
	if (stateI < 0 || stateI >= MAX_STATES)
		throw Exception("Invalid state");
	int stateD = -1;
	do {

    if (stateI >= numStates())
			break;

		stateD = getState(stateI).getTransitionState(symbol);
	} while (false);

	return stateD;
}
Exemplo n.º 7
0
double Continuous::mapState(double state) {
	return unmapf(state, 0.0, numStates() - 1);
}
Exemplo n.º 8
0
double Life::mapState(double state) {
	return (float)((int)mapf(state, 0.0, numStates() - 1));
}
Exemplo n.º 9
0
void HLL::initBuffers() {
	Super::initBuffers();

	eigenvaluesBuffer = cl.alloc(sizeof(real) * numStates() * getVolume() * app->dim);
}