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()); }
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))); } }
string Operand::buffer_etype(void) { stringstream ss; if (buffer_) { ss << buffer_->etype(); } else { ss << etype(); } return ss.str(); }
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()); }
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; }
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; }
//double operator=(double &a,etype &var) //{ return(a = var.d());} etype operator+(double a,const etype &var) { return(etype(a)+var);}
//int operator=(int &a,etype &var) //{ return(a = var.i());} etype operator+(int a,const etype &var) { return(etype(a)+var);}
etype operator+(const estrarray &a,const etype &var) { return(etype(a)+var); }
etype operator+(char *a,const etype &var) { return(etype(a)+var);}
//estr operator=(estr &a,etype &var) //{ return(a = var.s());} etype operator+(estr a,const etype &var) { return(etype(a)+var);}
etype operator/(double a,const etype &var) { return(etype(a)/var);}
etype operator*(double a,const etype &var) { return(etype(a)*var);}
etype operator*(int a,const etype &var) { return(etype(a)/var);}
etype operator/(float a,const etype &var) { return(etype(a)/var);}
etype operator*(float a,const etype &var) { return(etype(a)*var);}
etype operator-(float a,const etype &var) { return(etype(a)-var);}
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); }
etype operator-(double a,const etype &var) { return(etype(a)-var);}