Exemplo n.º 1
0
etype etype::operator/(const etype &var)
{
  switch(type){
    case ET_INT: return(etype( *(int*)value / var.i() ));
    case ET_FLOAT: return(etype( *(float*)value / var.f() ));
    case ET_DOUBLE: return(etype( *(double*)value / var.d() ));
    case ET_CHAR: return(etype( *(char*)value / var.c() ));
    case ET_ESTR: lwarn("division not defined for string type"); return(estr());
    case ET_EARRAY: lwarn("division not defined for array type"); return(estrarray());
  }
  lwarn("undefined value");
  return(estr());
}
Exemplo n.º 2
0
inline
void assign(array_nd<array<T> >& a, const mxArray* mx)
{
	if(mx::type_class<T>() == mxUNKNOWN_CLASS)
		throw etype();
	if(mxGetClassID(mx) != mx::type_class<T>())
		throw etype();

	size_array sz(mxGetNumberOfDimensions(mx),
		reinterpret_cast<const size_t*>(mxGetDimensions(mx)));
	a.resize(sz);

	size_t len = a.length();

	for(size_t i = 0; i < len; i++) {
		assign(a[i], mxGetCell(mx, mwIndex(i)));
	}
}
Exemplo n.º 3
0
string Operand::buffer_etype(void)
{
    stringstream ss;
    if (buffer_) {
        ss << buffer_->etype();
    } else {
        ss << etype();
    }
    return ss.str();
}
Exemplo n.º 4
0
etype etype::operator+(const etype &var)
{
  switch(type){
    case ET_INT: return(etype( *(int*)value + var.i() ));
    case ET_FLOAT: return(etype( *(float*)value + var.f() ));
    case ET_DOUBLE: return(etype( *(double*)value + var.d() ));
    case ET_CHAR: return(etype( *(char*)value + var.c() ));
    case ET_ESTR: return(etype( *(estr*)value + var.s() ));
    case ET_EARRAY: return(etype( *(estrarray*)value + var ));
  }
  lwarn("undefined value");
  return(estr());
}
Exemplo n.º 5
0
int
nextWalk(WalkPtr *w, uchar score[VtScoreSize], uchar *type, u32int *tag, Entry **e)
{
    if(w->n >= w->m)
        return 0;

    if(w->isEntry) {
        *e = &w->e;
        entryUnpack(&w->e, w->data, w->n);
        memmove(score, w->e.score, VtScoreSize);
        *type = etype(&w->e);
        *tag = w->e.tag;
    } else {
        *e = nil;
        memmove(score, w->data+w->n*VtScoreSize, VtScoreSize);
        *type = w->type-1;
        *tag = w->tag;
    }
    w->n++;
    return 1;
}
Exemplo n.º 6
0
Tnode*
initxsource(Entry e, int dowrap)
{
    Block *b;
    Tnode *t, *tt;

    b = dataBlock(e.score, etype(e.flags, e.depth), e.tag);
    if(b == nil)
        return stringnode("dataBlock: %r");

    if((e.flags & VtEntryActive) == 0)
        return stringnode("inactive Entry");

    if(e.depth == 0) {
        if(e.flags & _VtEntryDir)
            tt = initxentryblock(b, copyEntry(e));
        else
            tt = initxdatablock(b, e.dsize);
    } else {
        tt = initxblock(b, smprint("%s+%d pointer", (e.flags & _VtEntryDir) ? "BtDir" : "BtData", e.depth),
                        ptrgen, copyEntry(e));
    }

    /*
     * wrap the contents of the Source in a Source node,
     * just so it's closer to what you see in the code.
     */
    if(dowrap) {
        t = stringnode("Source");
        t->nkid = 1;
        t->kid = mallocz(sizeof(Tnode*)*1, 1);
        t->kid[0] = tt;
        tt = t;
    }
    return tt;
}
Exemplo n.º 7
0
//double operator=(double &a,etype &var)
//{ return(a = var.d());}
etype operator+(double a,const etype &var)
{ return(etype(a)+var);}
Exemplo n.º 8
0
//int operator=(int &a,etype &var)
//{ return(a = var.i());}
etype operator+(int a,const etype &var)
{ return(etype(a)+var);}
Exemplo n.º 9
0
etype operator+(const estrarray &a,const etype &var)
{ return(etype(a)+var); }
Exemplo n.º 10
0
etype operator+(char *a,const etype &var)
{ return(etype(a)+var);}
Exemplo n.º 11
0
//estr operator=(estr &a,etype &var)
//{ return(a = var.s());}
etype operator+(estr a,const etype &var)
{ return(etype(a)+var);}
Exemplo n.º 12
0
etype operator/(double a,const etype &var)
{ return(etype(a)/var);}
Exemplo n.º 13
0
etype operator*(double a,const etype &var)
{ return(etype(a)*var);}
Exemplo n.º 14
0
etype operator*(int a,const etype &var)
{ return(etype(a)/var);}
Exemplo n.º 15
0
etype operator/(float a,const etype &var)
{ return(etype(a)/var);}
Exemplo n.º 16
0
etype operator*(float a,const etype &var)
{ return(etype(a)*var);}
Exemplo n.º 17
0
etype operator-(float a,const etype &var)
{ return(etype(a)-var);}
Exemplo n.º 18
0
void 
CSUmbrella::runEvent() const
{
  double locdt = dt;
  
#ifdef DYNAMO_DEBUG 
  if (boost::math::isnan(locdt))
    M_throw() << "A NAN system event time has been found";
#endif
  
  Sim->dSysTime += locdt;
  
  Sim->ptrScheduler->stream(locdt);
  
  //dynamics must be updated first
  Sim->dynamics.stream(locdt);

  ++Sim->eventCount;

  BOOST_FOREACH(const size_t& id, *range1)
    Sim->dynamics.getLiouvillean().updateParticle(Sim->particleList[id]);
  
  BOOST_FOREACH(const size_t& id, *range2)
    Sim->dynamics.getLiouvillean().updateParticle(Sim->particleList[id]);
  
  bool kedown(false); //Will kinetic energy go down?

  int newulevel ;

  if (ulevel == 0)
    {
      kedown = true;
      
      if (type == WELL_OUT)
	newulevel = 1;
      else
	newulevel = -1;
    }
  else if (type == WELL_OUT)
    {
      if (ulevel > 0) kedown = true;
      newulevel = ulevel + 1; 
    }
  else //if (type == WELL_IN)
    {
      if (ulevel < 0) kedown = true;
      newulevel = ulevel - 1;
    }
    
  EEventType etype(NONE);

  NEventData SDat(Sim->dynamics.getLiouvillean().multibdyWellEvent
		      (*range1, *range2, 0.0, (kedown) ? -delU : delU, etype));

  if (etype != BOUNCE)
    ulevel = newulevel;

  Sim->signalParticleUpdate(SDat);
  
  //Only 1ParticleEvents occur
  BOOST_FOREACH(const ParticleEventData& PDat, SDat.L1partChanges)
    Sim->ptrScheduler->fullUpdate(PDat.getParticle());
  
  locdt += Sim->freestreamAcc;

  Sim->freestreamAcc = 0;

  BOOST_FOREACH(magnet::ClonePtr<OutputPlugin>& Ptr, Sim->outputPlugins)
    Ptr->eventUpdate(*this, SDat, locdt); 
}
Exemplo n.º 19
0
etype operator-(double a,const etype &var)
{ return(etype(a)-var);}