void estiva_std_R5(void *x, void *y) { int i; if ( y == NULL ) { i = where(x); set(i,NULL,NULL); if ( i == top ) top--; } else{ R5(x,NULL); i = where(NULL); set(i,x,y); if ( i == top ) { top++; if ( top >= limit ) { static void **tx, **ty; ary1(tx,limit); ary1(ty,limit); forall(0,i,top) tx[i] = x_array[i]; forall(0,i,top) ty[i] = y_array[i]; limit++; ary1(x_array,limit); ary1(y_array,limit); forall(0,i,top) x_array[i] = tx[i]; forall(0,i,top) y_array[i] = ty[i]; } } } }
Conducta::~Conducta() { forall(it,_comportamientos) delete it->second; forall(it,_contadores) delete it->second; forall(it,_timers) delete it->second; forall(it,_sensores) delete it->second; }
int Setcount(int _size) { int a[_size],count=0; forall(i,0,_size-1)a[i]=0; forall(i,0,_size-1)a[findSet(i)]++; forall(i,0,_size-1)if(a[i]!=0)count++; return count; }
void QMultiScope::setGuideSpacing(int spc) { forall(&QScope::setGuideSpacing,spc); dynamic_cast<QScope*>(allgraphs)->setGuideSpacing(spc); update(); dumpNext(); }
/* * Write a new lint library. */ void outlib(const char *name) { /* Open of output file and initialisation of the output buffer */ outopen(name); /* write name of lint library */ outsrc(name); /* name of lint lib has index 0 */ outclr(); outint(0); outchar('s'); outstrg(name); /* * print the names of all files references by unnamed * struct/union/enum declarations. */ outfiles(); /* write all definitions with external linkage */ forall(dumpname); /* close the output */ outclose(); }
void destroy() { auto self = this->self; forall(this->base, this->capacity, [](Cell& c){ c.~Cell(); }); global_free(this->base); call_on_all_cores([self]{ self->~GlobalHashSet(); }); global_free(self); }
static inline int64_t verify(TupleGraph tg, GlobalAddress<G> g, int64_t root) { VerificatorBase<G>::verify(tg,g,root); // SSSP distances verification forall(tg.edges, tg.nedge, [=](TupleGraph::Edge& e){ auto i = e.v0, j = e.v1; /* Eliminate self loops from verification */ if ( i == j) return; /* SSSP specific checks */ auto ti = VerificatorBase<G>::get_parent(g,i), tj = VerificatorBase<G>::get_parent(g,j); auto di = get_dist(g,i), dj = get_dist(g,j); auto wij = get_edge_weight(g,i,j), wji = get_edge_weight(g,j,i); CHECK(!((di < dj) && ((di + wij) < dj))) << "Error, distance of the nearest neighbor is too great :" << "(" << i << "," << di << ")" << "--" << wij << "-->" << "(" << j << "," << dj << ")" ; CHECK(!((dj < di) && ((dj + wji) < di))) << "Error, distance of the nearest neighbor is too great : " << "(" << j << "," << dj << ")" << "--" << wji << "-->" << "(" << i << "," << di << ")" ; CHECK(!((i == tj) && ((di + wij) != dj))) << "Error, distance of the child vertex is not equil to " << "sum of its parent distance and edge weight :" << "(" << i << "," << di << ")" << "--" << wij << "-->" << "(" << j << "," << dj << ")" ; CHECK(!((j == ti) && ((dj + wji) != di))) << "Error, distance of the child vertex is not equil to " << "sum of its parent distance and edge weight :" << "(" << j << "," << dj << ")" << "--" << wji << "-->" << "(" << i << "," << di << ")" ; }); // everything checked out! VLOG(1) << "SSSP verified!\n"; return nedge_traversed; }
// inline __attribute__((always_inline)) void forall(Index_type begin, Index_type end, //SgTemplateFunctionDeclaration LOOP_BODY loop_body) { forall( EXEC_POLICY_T(), begin, end, loop_body ); }
void QMultiScope::setSpeedy(int s) { sdbx("Set speedy %i",s); forall(&QScope::setSpeedy,s); dynamic_cast<QScope*>(allgraphs)->setSpeedy(s); update(); dumpNext(); }
void QScope::setExtent(int ext) { // fprintf(stderr,"QScope:setextent "); // sdbx("QScope(%p)::setExtent %i",this,ext); extent = raw_t(ext/uvpd()); forall(&QScope::setExtent,ext); update(); // sdbx("(%p)-> extent=%i",this,extent); }
void QMultiScope::setLength(int length) { dbx("Set length"); qss.length = length*FREQKHZ; forall(&QScope::setLength,qss.length); dynamic_cast<QScope*>(allgraphs)->setLength(qss.length); update(); dumpNext(); }
int main(){ int i,j; for(i=0; i < 100; ++i){ g(a,i); g(b,i); foo(i); } ASSERT(forall(idx, implies(0<=idx && idx <100, a[idx] == 0 && b[idx] == 0))); for(j=100;j < 200; ++j){ g(b,j); foo(j); } ASSERT(forall(idx_0, implies(100<=idx_0 && idx_0 < 200, b[idx_0] == 0))); return 1; }
void QMultiScope::setPreTrig(int pretrig) { dbx("Set pre trig"); qss.pretrig = pretrig*FREQKHZ; forall(&QScope::setPreTrig,qss.pretrig); dynamic_cast<QScope*>(allgraphs)->setPreTrig(qss.pretrig); update(); dumpNext(); }
static GlobalAddress<GlobalHashSet> create(size_t total_capacity) { auto base = global_alloc<Cell>(total_capacity); auto self = symmetric_global_alloc<GlobalHashSet>(); call_on_all_cores([self,base,total_capacity]{ new (self.localize()) GlobalHashSet(self, base, total_capacity); }); forall(base, total_capacity, [](int64_t i, Cell& c) { new (&c) Cell(); }); return self; }
void show_op(trit (*f)(trit, trit), const char *name) { trit a, b; printf("\n[%s]\n F ? T\n -------", name); forall(a) { printf("\n%c |", t_s(a)); forall(b) printf(" %c", t_s(f(a, b))); } puts(""); }
//void QMultiScope::setCenter(bool box) { void QMultiScope::setCenter() { dbx("Set center"); //if(isbox) forall(&QScope::setCenter); //else for(int hw=0;hw<TOTALCHANS;hw++) dynamic_cast<QScope*>(allgraphs)->setCenter_hw(hw); update(); dumpNext(); }
void Conducta::Actualizar(const EstadoDeSensores& estado_sensores) { if (!comportamiento_actual) Error("Conducta - Actualizar - Error: No existe un comportamiento actual!!!"); ActualizarSensores(estado_sensores); Elementos elementos; elementos.timers = &_timers; elementos.contadores = &_contadores; elementos.sensores = &_sensores; elementos.actuadores = &_actuadores; Transicion* transicion_activa = comportamiento_actual->TransicionActiva(elementos); if ( transicion_activa ) { transicion_activa->EjecutarActualizaciones(); CambiarAComportamiento( transicion_activa->IdComportamientoDestino() ); } forall(it,_timers) (it->second)->Ejecutar(); /* * @tfischer: lo siguiente esta por completitud, * por si en algun momento se usa, * pero esta comentado por performance * * forall(it,_contadores) (it->second)->Ejecutar(); forall(it,_sensores) (it->second)->Ejecutar(); */ comportamiento_actual->EjecutarElementos(); forall(it,_actuadores) (it->second)->Ejecutar(); }
int main() { var x = var("x"); std::cout << x << std::endl; var y = var("y"); std::cout << y << std::endl; expr expr1 = x || y; std::cout << expr1 << std::endl; expr expr2 = x && y; std::cout << expr2 << std::endl; expr expr3 = !x; std::cout << expr3 << std::endl; expr expr4 = !(x && y); std::cout << expr4 << std::endl; expr expr5 = !(x || y) && (x || y); std::cout << expr5 << std::endl; var z = var("z"); expr expr6 = expr5 && z; std::cout << expr6 << std::endl; var w = var("w"); expr expr7 = w || expr6; std::cout << expr7 << std::endl; expr equality = x == x; std::cout << equality << std::endl; expr nonequality = x != x; std::cout << nonequality << std::endl; expr demorgan = !(x && y) == (!x || !y); std::cout << demorgan << std::endl; func f = func("f"); expr fx = f(x); std::cout << fx << std::endl; expr fxy = f(x && y); std::cout << fxy << std::endl; expr expr8 = forall(x)(fx); std::cout << expr8 << std::endl; func g = func("g"); expr expr9 = exists(x)(f(x) == g(x)); std::cout << expr9 << std::endl; }
void QScope::refresh(timeref_t t) { if (t) { qss.endtime = t; nspikes = 0; } QPainter qp(this); erase(contentsRect()); drawContents(&qp); //drawContents_box(&qp); forall(&QScope::refresh,t); // for satellites i think }
void QScope::refresh_together(timeref_t t) {// DB modification, extracted from refresh if (t) { qss.endtime = t; nspikes = 0; } QPainter qp(this); //drawContents_all(&qp); erase(contentsRect()); drawContents_together(&qp); forall(&QScope::refresh_together,t); // for satellites i think }
void QScope::addSpike(Spikeinfo const &si) { // int x = time2x(si.time+qss.sf->first()); int x = time2x(si.time); QPainter qpai(this); qpai.setPen(aux_pen); qpai.setBrush(aux_pen.color()); qpai.drawEllipse(x-2, coffset+(si.height>0?-1:1)*halfhei*7/8-2,4,4); if (nspikes>=spikes.size()) spikes.push_back(si); else spikes[nspikes] = si; nspikes++; forall(&QScope::addSpike,si); }
int main(void) { trit a; puts("[Not]"); forall(a) printf("%c | %c\n", t_s(a), t_s(t_not(a))); show_op(t_and, "And"); show_op(t_or, "Or"); show_op(t_eq, "Equiv"); show_op(t_imply, "Imply"); return 0; }
int Actuador::Ejecutar() { int acumulador; acumulador = 0; forall(it,_entradas) acumulador += (*it)->GetValor(); _valor = acumulador; // cout << "nuevo valor de " << GetDescripcion() << " con " << _entradas.size() << " entradas: " << GetValor() << endl; return _valor; }
void QMultiScope::refresh(timeref_t t) { qss.endtime = t; if(isbox){ forall(&QScope::refresh,t); //for(int hw=0;hw<TOTALCHANS;hw++) // dynamic_cast<QScope*>(graphptrs[hw])->refresh(t); addSpikes(); dynamic_cast<QScope*>(allgraphs)->refresh_together(t); } else{ dynamic_cast<QScope*>(allgraphs)->erasetrace(); dynamic_cast<QScope*>(allgraphs)->refresh_all(t); } dumpme(); }
void QScope::setCenter() { if (qss.sf && qss.endtime>0) { double sum = 0; timeref_t starttime = (qss.endtime<qss.length) ? 0 : (qss.endtime-qss.length); for (timeref_t t=starttime; t<qss.endtime; t++) sum += (*qss.sf)[t][qss.channel]; center = raw_t(sum/(qss.endtime-starttime)); } else { center = 0; } centers[qss.channel]=center; forall(&QScope::setCenter,center); //update(); }
int * main (int x, int y){ int * a; int i; if ( x< 0 || y < 0 || y > x ) return (int *) 0; a = (int *) malloc( x * sizeof(int)); if (a == 0 ) exit(1); for (i=0; i < y ; ++i) { ASSERT(valid(&a[i])); a[i] = 0; } ASSERT(forall(idx, implies(idx >=0 && idx < y, valid(&a[idx]) && a[idx] == 0))); return a; }
int estiva_gmressolver(void *A, double *x, double *b) { static double *work, *h; long n, ldw, iter, info, i,ldh, restrt; double resid = 1.0e-7; setAmx(A); restrt = 50; ldw = iter = n = dim1(b); ldh = restrt+1; ary1(work,ldw*(restrt+4)); ary1(h, ldh*(restrt+2)); forall (0, i, n ) x[i] = b[i]; ILUdecomp(A); gmres_(&n,b+1,x+1,&restrt, work,&ldw,h,&ldh,&iter,&resid,estiva_matvec, estiva_psolve,&info); printf("gmres iter = %ld\n",iter); return 0; }
int Caja::Ejecutar() { int acumulador, resultado; acumulador = 0; forall(it,_entradas) acumulador += (*it)->GetValor(); // ESTO ESTÁ MAL!!! // están al revés los indices 0 y 1 // además cuando hace la cuenta de "a" termina haciendo un "-" en lugar de un "/"!!! // acá calculo la función formada por los puntos // la ecuación de la recta es Y = a*(X - x0) + y0 // donde a = (y1 - y0)/(x1 - x0) // ESTO ESTÁ BIEN... // acá calculo la función formada por los puntos // la ecuación de la recta es Y = a*(X - x0) + y0 // donde a = (y0 - y1)/(x0 - x1) if ( acumulador <= _punto_min.x ) resultado = _punto_min.y; else if ( _punto_max.x <= acumulador ) resultado = _punto_max.y; else { //float a = ( (float)_punto_max.y - (float)_punto_min.y ) - ( (float)_punto_max.x - (float)_punto_min.x ); //resultado = (int)( a*( (float)acumulador - (float)_punto_min.x ) + (float)_punto_min.y ); float a = ( (float)_punto_min.y - (float)_punto_max.y ) / ( (float)_punto_min.x - (float)_punto_max.x ); resultado = (int)( a*( (float)acumulador - (float)_punto_min.x ) + (float)_punto_min.y ); } _valor = resultado; // cout << "nuevo valor de " << GetDescripcion() << ": " << GetValor() << endl; return _valor; }
int estiva_qmrsolver(void *A, double *x, double *b) { static MX *AT; static double *work; long n, ldw, iter, info, i; double resid = 1.0e-7; transmx(AT,A); setAmx(A); setATmx(AT); ldw = iter =n = dim1(b); ary1(work,n*11); setveclength(n); forall (0, i, n ) x[i] = b[i]; ILUdecomp(A); qmr_(&n,b+1,x+1,work,&ldw,&iter,&resid,estiva_matvec, estiva_matvectrans, estiva_psolveq, estiva_psolvetransq,&info); if (defop("-v")) fprintf(stderr, "qmr iter = %ld\n",iter); return 0; }
/* * Write a new lint library. */ void outlib(const char *name) { /* Open of output file and initialisation of the output buffer */ outopen(name); /* write name of lint library */ outsrc(name); /* name of lint lib has index 0 */ outclr(); outint(0); outchar('s'); outstrg(name); /* write all definitions with external linkage */ forall(dumpname); /* close the output */ outclose(); }