Exemplo n.º 1
0
void ComponentIf::Evaluate(int timestamp)
{
  UPDATE_TIMESTAMP();

  if (m_inputs[1].comp == NULL || m_inputs[2].comp == NULL)
  {
    assignDefaultValue(m_outputs[0].value, m_outputs[0].type);
    return;
  }

  bool cond = true;
  GetInput(0, &cond);

  if (cond)
  {
    if (PASS_TIMESTAMP(m_inputs[1]))
      m_inputs[1].comp->Evaluate(timestamp);
    assignValue(m_outputs[0].value, m_inputs[1].value, m_outputs[0].type);
  }
  else
  {
    if (PASS_TIMESTAMP(m_inputs[2]))
      m_inputs[2].comp->Evaluate(timestamp);
    assignValue(m_outputs[0].value, m_inputs[2].value, m_outputs[0].type);
  }
}
Exemplo n.º 2
0
void ComponentOp2::Evaluate(int timestamp)
{
  UPDATE_TIMESTAMP();

  if (m_inputs[0].comp == NULL || m_inputs[1].comp == NULL)
  {
    assignDefaultValue(m_outputs[0].value, m_outputs[0].type);
    return;
  }

  // There are certainly better ways to do this, but I'm not using them yet

  double v0d, v1d;
  bool v0b, v1b;
  void *v0, *v1;

  if      (m_inputs[0].type == CT_DOUBLE) v0 = &v0d;
  else if (m_inputs[0].type == CT_BOOL)   v0 = &v0b;
  if      (m_inputs[1].type == CT_DOUBLE) v1 = &v1d;
  else if (m_inputs[1].type == CT_BOOL)   v1 = &v1b;

  if (PASS_TIMESTAMP(m_inputs[0]))
    m_inputs[0].comp->Evaluate(timestamp);
  if (PASS_TIMESTAMP(m_inputs[1]))
    m_inputs[1].comp->Evaluate(timestamp);
  assignValue(v0, m_inputs[0].value, m_inputs[0].type);
  assignValue(v1, m_inputs[1].value, m_inputs[1].type);

  if (m_operator == '+')
    *(double *)m_outputs[0].value = *(double *)v0 + *(double *)v1;
  else if (m_operator == '-')
    *(double *)m_outputs[0].value = *(double *)v0 - *(double *)v1;
  else if (m_operator == '*')
    *(double *)m_outputs[0].value = *(double *)v0 * *(double *)v1;
  else if (m_operator == '/')
    *(double *)m_outputs[0].value = *(double *)v0 / *(double *)v1;

  else if (m_operator == '<')
    *(bool *)m_outputs[0].value = *(double *)v0 < *(double *)v1;
  else if (m_operator == '>')
    *(bool *)m_outputs[0].value = *(double *)v0 > *(double *)v1;

  else if (m_operator == '|')
    *(bool *)m_outputs[0].value = *(bool *)v0 || *(bool *)v1;
  else if (m_operator == '&')
    *(bool *)m_outputs[0].value = *(bool *)v0 && *(bool *)v1;

  else if (m_operator == '=')
  {
    if (m_inputs[0].type == CT_DOUBLE)
      *(bool *)m_outputs[0].value = *(double *)v0 == *(double *)v1;
    else if (m_inputs[0].type == CT_BOOL)
      *(bool *)m_outputs[0].value = *(bool *)v0 == *(bool *)v1;
  }
}
Exemplo n.º 3
0
void probeMatcher(PipeMatcherRec* mrec, char write_flag, char req, char* ack, bit_vector* access_val)
{
	PipeMatcherState s = getState(mrec);
	if(s == _DONE)
	{
		if(req)
		{
			*ack = 1;	
			if(!write_flag)
				getValue(mrec, access_val);
#ifdef DEBUG
			fprintf(stderr,"probeMatcher: finished pipe-access %s %s %s\n", (write_flag ? "write" : "read"), mrec->_pipe_name, 
								(write_flag ? to_string(access_val) : to_string(mrec->_value)));
#endif

			setState(mrec, _IDLE);
		}
	}
	else if(s == _ACCESS)
	{
		*ack = 0;
	}
	else if(s == _IDLE)
	{
		if(req)
		{
			*ack = 0;
			if(write_flag)
				assignValue(mrec, access_val);
			setState(mrec, _ACCESS);	
		}
	}
}
Exemplo n.º 4
0
void fetchFromPipe(PipeMatcherRec* mrec)
{
	bit_vector tmp_val;
	init_bit_vector(&tmp_val, mrec->_value->width);
	
	read_bit_vector_from_pipe(mrec->_pipe_name, &tmp_val);
	assignValue(mrec, &tmp_val);
}
Exemplo n.º 5
0
int main()
{
///The metafunction @Metafunction.Iterator@ returns the iterator type for a given container type.
	seqan::String<char> str = "admn";
	seqan::Iterator<seqan::String<char> >::Type it = begin(str);
	seqan::Iterator<seqan::String<char> >::Type itEnd = end(str);
///We can use iterators to iterate over the elements of a container.
	while (it != itEnd) {
		::std::cout << *it;
		++it;
	}
	::std::cout << ::std::endl;
///Rooted iterators know their container (@Concept.RootedIteratorConcept|Rooted Iterator@).
///Hence, the functions @Function.goBegin@ and @Function.atEnd@ do
///not get $str$ as an argument.
///The following loop increments each character in $str$.
	seqan::Iterator<seqan::String<char>, seqan::Rooted >::Type it2 = begin(str);
	for (goBegin(it2); !atEnd(it2); goNext(it2)) 
	{
		++value(it2);
	}
///Some iterators support an iteration in reverse order.
///Note that @Function.goPrevious@ is called before the value of $it2$ is accessed.
///Remember that the end position of a container is always the position behind the last item in the container.
	goEnd(it2);
	while (!atBegin(it2))              
	{
		goPrevious(it2);
		::std::cout << getValue(it2);
	}
	::std::cout << ::std::endl;
///@Function.assignValue@ can be used to change the value of an iterator.
	assignValue(begin(str), 'X');
	::std::cout << str << ::std::endl;
	
	return 0;
}
Exemplo n.º 6
0
//initialize List of contingency tables (one for every kmer)
void initializeCont (seqan::StringSet<seqan::DnaString> kmers, Contingency & allContigs){
//     //Contingeny table for finding of one single kmer to store intermediate results
//     Contingency oneContig;
    unsigned l;
    l=length(kmers);
    //mock vector for mRNA IDs
    std::vector<int> mock;
    mock.push_back(-1);
    //reserve space
    allContigs.kmerDN.reserve(l);
    allContigs.kmerNoDN.reserve(l);
    allContigs.noKmerDN.reserve(l);
    allContigs.noKmerNoDN.reserve(l);
    allContigs.idNoDN.reserve(l);
    allContigs.idDN.reserve(l);
    
    //Initialize list of Contingency table for all the kmers
    for (unsigned i=0; i<l; i++){
        appendValue(allContigs.kmerSeq, "");
        allContigs.kmerDN.push_back(0);
        allContigs.kmerNoDN.push_back(0);
        allContigs.noKmerDN.push_back(0);
        allContigs.noKmerNoDN.push_back(0);
        //initialize ID Lists for the mRNAs, in which the kmer was found with -1, since there is no mRNA with rank -1
        allContigs.idNoDN.push_back(mock);
        allContigs.idDN.push_back(mock);
    }
    //assign the kmer to the position in the Contingencies Table
    for (unsigned j=0; j<l; j++){
        if (length(getValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j))))>0){
            std::cerr << "kmer already set" << '\n';
            std::cerr << getValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j)))<< '\n';
            return;
        }
        else {assignValue(allContigs.kmerSeq, kmerToID(getValue(kmers, j)), getValue(kmers, j));}
    }
}
Exemplo n.º 7
0
sExpression *evalAssignment(sExpression *exp, sEnvironment *env){
  if(setVariable(assignSynbol(exp), eval(assignValue(exp), env), env)){
    return &sTrue;
  }
  return &sFalse;
}