Word C1DTOEDGELIST(Word cl, Word cm, Word cr) { Word E,L,i,Ll,Lr,l,a,b,t; Step1: /* Initialize. */ E = NIL; Step2: /* Get adjacencies for (cl,cm) and (cr,cm). */ L = FIRST(ADJ_2D_PART(cm,cl,cr,P,J)); i = LAST(LELTI(cm,INDX)); Ll = NIL; Lr = NIL; while(L != NIL) { ADV(L,&l,&L); FIRST2(l,&a,&b); if (FIRST(a) == i) { t = a; a = b; b = t; } if (FIRST(a) < i) Ll = COMP(LIST2(a,b),Ll); else Lr = COMP(LIST2(a,b),Lr); } Step3: /* Get edges from adjacency info. */ E = CONC(ADJ2DITOEL(Ll,cl,cm),E); E = CONC(ADJ2DITOEL(Lr,cr,cm),E); Return: /* Prepare to return. */ return E; }
/* ESPCAD cell triple and polynomial index list of strong necessary conditions. */ Word ESPCADCTPILSNC(Word c1,Word c2, Word c3, Word i, Word j,Word k, Word P) { Word Lt,Lf,C,c,A,tt,tf,L,Lp,Ls; Step1: /* Classify cells as true or false. */ C = LIST3(c1,c2,c3); for(Lt = NIL, Lf = NIL; C != NIL; C = RED(C)) { c = FIRST(C); switch(LELTI(c,SC_TMPM)) { case TRUE: Lt = COMP(c,Lt); break; case FALSE: Lf = COMP(c,Lf); break; default: break; } } Step2: /* Need a true cell and a false cell to continue. */ if (Lt == NIL || Lf == NIL) { L = NIL; goto Return; } Step3: /* Weed out conditions that are not strong & necessary. */ Ls = FMAAFPIRN(i,j,k); for(L = NIL; Ls != NIL; Ls = RED(Ls)) { A = FIRST(Ls); for(tt = 1, Lp = Lt; tt && Lp != NIL; Lp = RED(Lp)) tt = FMACELLEVAL(A,FIRST(Lp),P); for(tf = 1, Lp = Lf; tf && Lp != NIL; Lp = RED(Lp)) tf = FMACELLEVAL(A,FIRST(Lp),P); if (tt && !tf) L = COMP(A,L); } Return: /* */ return L; }
void Socket::connect(const std::string& h, const std::string& s) { host = h; serv = s; int status; addrinfo hint, *info; memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_INET; hint.ai_socktype = SOCK_STREAM; LOG(COMP("Connecting to %1", hostserv()), LOG_MSG) ERR(status = getaddrinfo(host.c_str(), serv.c_str(), &hint, &info), COMP("getaddrinfo():%1", gai_strerror(status))) ERR((fd = socket(info->ai_family, info->ai_socktype, info->ai_protocol)) == -1, COMP("socket():%1", strerror(errno))) ERR(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(status=1), sizeof(status)) == -1, COMP("setsockopt():%1", strerror(errno))) ERR(::connect(fd, info->ai_addr, info->ai_addrlen) == -1, COMP("connect():%1", strerror(errno))) freeaddrinfo(info); disconnected = false; }
Word MINHITSET(Word A, Word B) { Word L,As,C,Cp,p,Ap,T,s; Step1: /* Quick decisions. */ if (A == NIL) return (NIL); if ((B == 0) || (FIRST(A) == NIL)) return (MC_FAIL); Step2: /* Initialize loop. */ L = FIRST(A); As = RED(A); C = MC_FAIL; Step3: /* Loop over the elements of L, looking for a min. hit set of A. */ while ( (L != NIL) && (B != 0) ) { ADV(L,&p,&L); Step4: /* Eliminate from A all sets hit by p, call this Ap. */ Ap = NIL; T = As; while ( T != NIL) { ADV(T,&s,&T); if (! MEMBER(p,s)) { Ap = COMP(s,Ap); } } Ap = INV(Ap); Step5: /* Recurse: Look for a cover of Ap of at most B-1 columns. */ Cp = MINHITSET(Ap,B-1); if ( Cp != MC_FAIL ) { C = COMP(p,Cp); B = LENGTH(Cp); } } Return: /* Loop complete. Return. */ return (C); }
Word ADJ_2D1(Word c, Word c_l, Word P, Word J) { Word U,V,v_l,Sol,S,A,Ap,a,b; /* init(); sa_send("["); */ Step1: /* Initialization. */ v_l = LDCOEFMASK(c,P,J); U = AD2DS_CONS(c_l,P); V = AD2DS_CONS(c,P); Step2: /* Get Adjacencies. */ /* Sol = ADJ_2D1_SIMPLE(U,V,v_l,FIRST(LELTI(c,INDX))); */ Sol = ADJ_2D1P1(U,V,v_l,FIRST(LELTI(c,INDX))); Step3: /* If c_l is to the right of c, reverse order of pairs. */ if (FIRST(LELTI(c,INDX)) < FIRST(LELTI(c_l,INDX))) { for(S = NIL; Sol != NIL; Sol = RED(Sol)) { for(A = NIL, Ap = FIRST(Sol); Ap != NIL; Ap = RED(Ap)) { FIRST2(FIRST(Ap),&a,&b); A = COMP(LIST2(b,a),A); } S = COMP(A,S); } Sol = S; } Return: /* Prepare to return. */ /* sa_send("]\n"); uninit(); */ return Sol; }
struct Interval* insert(struct Interval* intervals, int intervalsSize, struct Interval newInterval, int* returnSize) { struct Interval* ns = malloc(sizeof(struct Interval) * (intervalsSize + 1)); (* returnSize) = 0; int i; if (intervalsSize == 0 || intervals[0].start > newInterval.start) { i = 0; ns[(* returnSize)].start = newInterval.start; ns[(* returnSize)].end = newInterval.end; newInterval.start = newInterval.end = INT_MAX; } else if (intervalsSize > 0) { i = 1; ns[(* returnSize)].start = intervals[0].start; ns[(* returnSize)].end = intervals[0].end; } if (intervalsSize == 0) { (* returnSize)++; return ns; } for ( ; i < intervalsSize ; i++) { if (newInterval.start < intervals[i].start) { COMP(newInterval); newInterval.start = newInterval.end = INT_MAX; i--; } else { COMP(intervals[i]); } } if (newInterval.start != INT_MAX) { COMP(newInterval); } (* returnSize)++; return ns; }
Word MBPROD(Word A, Word B) { Word A1,A11,Ap,Ap1,B1,B11,Bp,Bs,C,C1,C11,i,j,k,p,q,qp,r; /* hide C11,i,j,k,p,q,qp,r; */ Step1: /* Get the sizes of $A$ and $B$. */ p = LENGTH(A); if (p == 0) q = 0; else q = LENGTH(FIRST(A)); qp = LENGTH(B); if (qp == 0) r = 0; else r = LENGTH(FIRST(B)); Step2: /* Multiply. */ C = NIL; Ap = A; for (i = 1; i <= p; i++) { C1 = NIL; ADV(Ap,&A1,&Ap); Bp = B; for (j = 1; j <= r; j++) { C11 = 0; Bs = NIL; Ap1 = A1; for (k = 1; k <= q; k++) { ADV(Ap1,&A11,&Ap1); ADV(Bp,&B1,&Bp); ADV(B1,&B11,&B1); C11 = C11 + A11 * B11; Bs = COMP(B1,Bs); } Bp = INV(Bs); C1 = COMP(C11,C1); } C1 = INV(C1); C = COMP(C1,C); } C = INV(C); goto Return; Return: /* Prepare for return. */ return(C); }
Word QepcadCls::IPFZT(Word r, Word A) { Word A1,Ap,As,P,Ths,i,s,t; /* hide Ap,Ths,i,s,t; */ Step1: /* Initialize. */ /*Int*/ if (PCIPFZT == 'n') return(0); /*Int*/ Ths = ACLOCK(); t = 1; P = NIL; for (i = r; i >= 1; i--) P = COMP(i,P); i = 1; Step2: /* Test for finitely many distinct x sub i - coordinates among the common zeros. */ Ap = A; As = NIL; do { ADV(Ap,&A1,&Ap); if (i > 1) A1 = PPERMV(r,A1,P); s = PUNT(r,A1); if (s == 2) goto Step4; else if (s == 1) goto Step3; As = COMP(A1,As); } while (!(Ap == NIL)); As = INV(As); if (!IPFZT1(r,As)) { t = 0; goto Step4; } Step3: /* Check for completion. */ i = i + 1; if (i > r) goto Step4; P = PERMCY(P); goto Step2; Step4: /* Return. */ /*Int*/ Ths = ACLOCK() - Ths; /*Int*/ TMIPFZT[r] = TMIPFZT[r] + Ths; goto Return; Return: /* Prepare for return. */ return(t); }
Word PCADCSV(Word cs, Word Ps) { Word c,l,S,s,I,V,Vs; Step1: /* */ c = LELTI(cs,SC_REP); l = LELTI(c,LEVEL); if (l == 0) { Vs = NIL; goto Return; } S = LELTI(Ps,l); for(I = NIL; S != NIL; S = RED(S)) { s = FIRST(S); I = COMP(THIRD(LELTI(s,PO_LABEL)),I); } LBIBMS(I); I = CINV(I); V = FIRST(LELTI(c,SIGNPF)); for(Vs = NIL;I != NIL; I = RED(I)) Vs = COMP(LELTI(V,FIRST(I)),Vs); Return: /* Prepare to return. */ return (Vs); }
void testSIimplOI(BDigit r, Word P, Word ZL, Word NZ, Word A) { /* Compute generators A and all its 1st order partials */ Word L = LIST1(A); for(int i = 1; i <= r; ++i) { Word D = IPDER(r,A,i); if (D != 0) L = COMP(D,L); } L = CCONC(L,ZL); /* Compute a variable list for output purposes. */ Word V = NIL; for(int i = r; i > 0; i--) { char s[2]; s[0] = 'a' - 1 + i; s[1] = '\0'; V = COMP(LFS(s),V); } /* Go through assumptions and find non-vanishing conditions. */ Word M = NZ; SWRITE("Test si ==> oi: "); IPDWRITE(r,A,V); SWRITE("\n"); GBTest(r,L,V); }
static ret_t process_request_line (cherokee_handler_admin_t *hdl, cherokee_buffer_t *line) { #define COMP(str,sub) (strncmp(str, sub, sizeof(sub)-1) == 0) if (COMP (line->buf, "get server.ports")) { return cherokee_admin_server_reply_get_ports (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "get server.traffic")) { return cherokee_admin_server_reply_get_traffic (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "get server.thread_num")) { return cherokee_admin_server_reply_get_thread_num (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "get server.trace")) { return cherokee_admin_server_reply_get_trace (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "set server.trace")) { return cherokee_admin_server_reply_set_trace (HANDLER(hdl), &hdl->dwriter, line); } else if (COMP (line->buf, "get server.sources")) { return cherokee_admin_server_reply_get_sources (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "kill server.source")) { return cherokee_admin_server_reply_kill_source (HANDLER(hdl), &hdl->dwriter, line); } else if (COMP (line->buf, "set server.backup_mode")) { return cherokee_admin_server_reply_set_backup_mode (HANDLER(hdl), &hdl->dwriter, line); } else if (COMP (line->buf, "get server.connections")) { return cherokee_admin_server_reply_get_conns (HANDLER(hdl), &hdl->dwriter); } else if (COMP (line->buf, "close server.connection")) { return cherokee_admin_server_reply_close_conn (HANDLER(hdl), &hdl->dwriter, line); } SHOULDNT_HAPPEN; return ret_error; }
Word CADFPCAD(Word D, Word P, Word S, Word I, Word Pb) { Word Db,Is,N,Sb,Pb_N,Ts,L,p,i,is,Q,Ms,C,Cs,Ds,Ss; Word Mb,mb; Step1: /* Is D the root cell? */ Db = LELTI(D,SC_REP); if (LELTI(D,SC_PAR) == NIL) { Is = NIL; Ss = NIL; Ms = NIL; } else { Step2: /* D is not the root cell. */ Is = CINV(COMP(LELTI(D,SC_INX),CINV(I))); N = LENGTH(Is); Step3: /* Signiture & multiplicity information. */ Sb = FIRST(LELTI(Db,SIGNPF)); Pb_N = LELTI(Pb,N); Ts = NIL; Ms = NIL; is = 0; /* Loop over each level N polynomial in P. */ for(L = CINV(LELTI(P,N)); L != NIL; L = RED(L)) { p = FIRST(L); i = 1; is++; /* Set i so that p is the ith level N pol in Pb. */ i = PFPIPFL(p,Pb_N); if (i == 0) { SWRITE("CAPFPCAD: Can't find the polynomial!\n"); } Ts = COMP(LELTI(Sb,i),Ts); /* Set the multiplicity list if necessary */ for (Mb = LELTI(Db,MULSUB); Mb != NIL; Mb = RED(Mb)) { mb = FIRST(Mb); if (FIRST(mb) == THIRD(LELTI(p,PO_LABEL))) { Ms = COMP(mb,Ms); } } } /* Ms = CINV(Ms); */ Ss = COMP(Ts,S); } Step4: /* Children. */ C = LELTI(D,SC_CDTV); if ( ISATOM(C) ) { Cs = NIL; } else { for(Cs = NIL; C != NIL; C = RED(C)) { Cs = COMP(CADFPCAD(FIRST(C),P,Ss,Is,Pb),Cs); } Cs = CINV(Cs); } Step5: /* */ Ds = LCOPY(Db); SLELTI(Ds,CHILD,Cs); SLELTI(Ds,INDX,Is); SLELTI(Ds,SIGNPF,Ss); SLELTI(Ds,HOWTV,NOTDET); /* Might want to change. */ SLELTI(Ds,MULSUB,Ms); Return: /* Prepare to return. */ return (Ds); }
bool TrailID::operator<( const TrailID &rhs ) const { #define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false; COMP(st); COMP(cd); #undef COMP return false; }
static void bstree_copy_sort( bstree bst, unsigned int node, bstree_node *array, unsigned int *index){ static int bstree_shrink( bstree bst); static int bstree_node_find( const bstree bst, const unsigned int *node, KEYTYPE key, VALUETYPE *value){ if( key == bst->array[*node].key ){ *value = bst->array[*node].value; return BSTREE_SUCCESS; } if( COMP(key, bst->array[*node].key) < 0 ){ if( bst->array[*node].left != NODE_NULL ){ return bstree_node_find( bst, &(bst->array[node].left), key, value); } }else{ if( bst->array[node].right != NODE_NULL ){ return bstree_node_find( bst, &(bst->array[node].right), key, value); } } return BSTREE_FAILURE; } static int bstree_node_insert( bstree bst, unsigned int *node, KEYTYPE key, VALUETYPE value){ int status; if( *node == NODE_NULL){ if( bst->max_pos == bst->array_size ){ if( bstree_grow( bst) == BSTREE_MEM_ERROR ){ return BSTREE_MEM_ERROR; } } *node = bstree->max_pos; bst->array[*node].left = NODE_NULL; bst->array[*node].right = NODE_NULL; bst->array[*node].key = key; bst->array[*node].value = value; bst->array[*node].level = 1; (bst->max_pos)++; (bst->size)++; return BSTREE_SUCCESS; } if( key == bst->array[*node].key ){ bst->array[*node].value += value; return BSTREE_SUCCESS; } if( COMP( key, bst->array[*node].key) < 0 ){ status = bstree_node_insert( bst, &(bst->array[node].left), key, value); }else{ status = bstree_node_insert( bst, &(bst->array[node].right), key, value); } skew( bst, node); split( bst, node); return status; }
void Socket::send(const std::string& msg) { int sent = 0; for (int i = 0; i < msg.size(); i += sent) { ERR((sent = ::send(fd, &msg[i], msg.size()-i, 0)) == -1, COMP("send():%1", strerror(errno))) } LOG(COMP("Sent %1B to %2:\n'%3'", msg.size(), hostserv(), Glib::strescape(msg)), LOG_DEBUG) }
Word FMAAFPIRN(Word i, Word j, Word k) { Word L,op; L = NIL; for(op = 1; op <= 6; op++) { L = COMP(LIST2(LIST2(i,j),op),L); L = COMP(LIST2(LIST2(i,j),LIST2(op,k)),L); } return L; }
Word CYLIMPFORM(Word C, Word P, Word k, Word A) { Word SF,L,Lp,c,S,t,Q,As,Ap,Fp,F,Lt,Lf,s,Si,Fi,Qp,SF2; Step1: /* Set L to a list of all (k-1)-level cells over which there are k-level cells with SC_TMPM of TRUE. */ if (k == 0) { if (LELTI(C,SC_TMPM) == TRUE) SF = LIST1(TRUE); else SF = LIST1(FALSE); goto Return; } SF = NIL; L = NIL; for(Lp = PCADCL(C,k-1); Lp != NIL; Lp = RED(Lp)) { c = FIRST(Lp); S = LELTI(c,SC_CDTV); if (!ISLIST(S)) continue; for(t = 0; S != NIL && !t; S = RED(S)) t = (LELTI(FIRST(S),SC_TMPM) == TRUE); if (t) L = COMP(c,L); } Step2: /* Construct formula for the k-level cells. */ Lt = NIL; Lf = NIL; S = NIL; for(Lp = L; Lp != NIL; Lp = RED(Lp)) S = CCONC(LELTI(FIRST(Lp),SC_CDTV),S); for(S = PCADCL(C,k); S != NIL; S = RED(S)) { s = FIRST(S); if (LELTI(s,SC_TMPM) == TRUE) Lt = COMP(s,Lt); else Lf = COMP(s,Lf); } F = NAIVESF(SPCADCBDD(Lt,k),Lf,A,P); Step3: /* */ S = GEOPARTII(FMASORT(FMA2DNF(F)),L,P,NIL); /* Construct definiting formula from each (Si,Fi) in S. */ for(; S != NIL; S = RED(S)) { FIRST2(FIRST(S),&Si,&Fi); ESCSLKMF(C,k-1); for(Qp = Si; Qp != NIL; Qp = RED(Qp)) SLELTI(FIRST(Qp),SC_TMPM,TRUE); SF2 = CYLIMPFORM(C,P,k-1,A); SF = COMP(LIST3(ANDOP,SF2,CLEANUPFORM(Si,Fi,P)),SF); } Step4: /* Convert SF from a list of formulas to a formula. */ if (LENGTH(SF) > 1) SF = COMP(OROP,SF); else SF = FIRST(SF); Return: /* Prepare to return. */ return SF; }
SSL_CTX *initCTX() { SSL_CTX *m_ctx; ERR((m_ctx = SSL_CTX_new(SSLv23_method())) == NULL, COMP("SSL_CTX_new():%1", SSLErrors())) SSL_CTX_set_options(m_ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2); ERR(SSL_CTX_set_default_verify_paths(m_ctx) == 0, COMP("SSL_CTX_set_default_verify_paths():%1", SSLErrors())) return m_ctx; }
bool StepsID::operator<( const StepsID &rhs ) const { #define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false; COMP(st); COMP(dc); COMP(sDescription); COMP(uHash); #undef COMP return false; }
inline DWORD BlendColor(DWORD c1, DWORD c2, int alpha) { int r = (COMP(c1,16)*256 + (COMP(c2,16)-COMP(c1,16))*alpha) >> 8; int g = (COMP(c1,8)*256 + (COMP(c2,8)-COMP(c1,8))*alpha) >> 8; int b = (COMP(c1,0)*256 + (COMP(c2,0)-COMP(c1,0))*alpha) >> 8; return MAKECOLOR(r,g,b); }
Word LDCOEFMASK(Word c, Word P, Word J) { Word *A,P_2,n,i,M,P_1,L,m,j,p,Lp,h,q,v,l; Step1: /* Set up A to be a characteristic vector for the set of level 2 proj fac's whose leading coefficients vanish in c. */ P_2 = LELTI(P,2); n = THIRD(LELTI(LAST(P_2),PO_LABEL)); A = GETARRAY(n + 1); for(i = 1; i <= n; i++) A[i] = 0; Step2: /* Set L to be the list of projection factors which vanish in c. */ M = LELTI(c,MULSUB); P_1 = LELTI(P,1); L = NIL; while(M != NIL) { ADV(M,&m,&M); j = FIRST(m); do ADV(P_1,&p,&P_1); while(j != THIRD(LELTI(p,PO_LABEL))); L = COMP(p,L); } Step3: /* Set Lp to the list of projection polynomials with factors in L. */ Lp = NIL; while(L != NIL) { ADV(L,&p,&L); for(h = LELTI(p,PO_PARENT); h != NIL; h = RED(h)) Lp = COMP(THIRD(FIRST(h)),Lp); } Step4: /* Run through the histories of each polynomial in Lp. If the polynomial is the leading coefficient of some bivariate projection factor, set A at the index for that projection factor to 1. */ while(Lp != NIL) { ADV(Lp,&p,&Lp); for(h = LELTI(p,PO_PARENT); h != NIL; h = RED(h)) { q = FIRST(h); if (FIRST(q) == PO_LCO) { l = LELTI(THIRD(q),PO_LABEL); if (SECOND(l) == 2) A[ THIRD(l) ] = 1; } } } Step5: /* Create the vector itself! */ v = NIL; while(P_2 != NIL) { ADV(P_2,&p,&P_2); j = THIRD(LELTI(p,PO_LABEL)); v = COMP(A[j],v); } v = INV(v); Return: /* Prepare to return. */ FREEARRAY(A); return v; }
Ptr(Socket) tcp_s(const std::string& h, const std::string& s, bool ssl, int tries) { for (int i = 0; i < tries; ++i) { LOG(COMP("Trying connection (%1/%2)", i+1, tries), LOG_MSG) try { Ptr(Socket) socket(ssl ? new SSLSocket() : new Socket()); socket->connect(h, s); return socket; } catch (...) {} } ERR(true, COMP("Could not connect after %1 tries.", tries)) return Ptr(Socket)((Socket*)NULL); }
Word FMAOPCOMBINE(Word F) { Word L,M,Fp,f,a,b,Lp,Mp,Lb; switch(FIRST(F)) { case OROP: /* Set L to a list of all top level atomic formulas. */ L = NIL; M = NIL; for(Fp = RED(F); Fp != NIL; Fp = RED(Fp)) { f = FIRST(Fp); if (ISLIST(FIRST(f))) L = COMP(f,L); else M = COMP(f,M); } /* Create Lp from L */ Lp = NIL; while(L != NIL) { a = FIRST(L); if (FMAQEXTAF(a)) { Lp = COMP(a,Lp); L = RED(L); continue; } Lb = RED(L); for(L = NIL; Lb != NIL; Lb = RED(Lb)) { b = FIRST(Lb); if (FMAQEXTAF(b) || ! EQUAL(FIRST(b),FIRST(a))) L = COMP(b,L); else a = LIST2(FIRST(a),SECOND(a) | SECOND(b)); } if (SECOND(a) > 6) Lp = COMP(LIST1(TRUE),Lp); else Lp = COMP(a,Lp); } /* Create Mp from M. */ for(Mp = NIL; M != NIL; M = RED(M)) Mp = COMP(FMAOPCOMBINE(FIRST(M)),Mp); Fp = COMP(OROP,CCONC(Lp,Mp)); break; case ANDOP: Fp = NIL; for(L = CINV(RED(F)); L != NIL; L = RED(L)) Fp = COMP(FMAOPCOMBINE(FIRST(L)),Fp); Fp = COMP(ANDOP,Fp); break; default: Fp = F; } return Fp; }
Word CELLSCPCELL(Word C, Word P, Word Ps) { Word c,A,i,L,N,Ps_N,Lp,l,S,s,k,Z,r; Step1: /* Initialize. */ FIRST3(C,&c,&A,&i); if (A == NIL) { Lp = LIST1(c); goto Return; } L = CELLSCPCELL(A,P,Ps); N = LELTI(c,LEVEL); Ps_N = LELTI(Ps,N); Step2: /* Loop over all the cells that form the projection of C. */ Lp = NIL; while (L != NIL) { ADV(L,&l,&L); S = LELTI(l,CHILD); if (S == NIL) { Lp = COMP(l,Lp); } else { Step3: /* Set s to the first child of l which lies in C. */ ADV(S,&s,&S); for(k = 1; k < i; S = RED(S)) { s = FIRST(S); if ( EVEN(k) ) k++; else { Z = LPFZC(s,P); if ( LPFSETINTERSECT(Z,Ps_N) != NIL ) k++; } } Step4: /* Continue adding cells from S until they no longer lie in C. */ if ( EVEN(i) ) Lp = COMP(s,Lp); else { Lp = COMP(s,Lp); while ( S != NIL ) { ADV2(S,&s,&r,&S); Z = LPFZC(s,P); if ( LPFSETINTERSECT(Z,Ps_N) == NIL ) { Lp = COMP(s,Lp); Lp = COMP(r,Lp); } else break; } } } } Return: /* Return. */ return (Lp); }
Word QepcadCls::SFCFULLDf(Word D, Word P, Word J, Word n) { Word t,SF,Dp,Pp,Lt,Lf,LA,Q,D1,P1,D0,P0,J0,i,Lp,pflag, L; char e,s,m,c; Step1: /* Space is either empty or R^n. */ t = DOPFSUFF_FULLD(P,LIST1(D)); if (t == TRUE) { SF = LIST1(TRUE); /* CAD is identically TRUE. */ goto Return; } else if (t == FALSE) { SF = LIST1(FALSE); /* CAD is identically FALSE. */ goto Return; } Step2: /* Extended language. */ /* Dp,Pp are a simplified CAD for D,P (based only on full-dimensional cells!) */ CCADCONmod(n,P,D,&Pp,&Dp); Dp = PCAD2ESPCAD(P,Pp,Dp,NIL); /* Get list of all the true and false cells. */ LTFOCALWTV(Dp,n,&Lt,&Lf); /* Filter out all but the full-dimensional true/false cells. */ for(L = NIL; Lt != NIL; Lt = RED(Lt)) if (LELTI(LELTI(FIRST(Lt),SC_REP),LEVEL) == CELLDIM(LELTI(FIRST(Lt),SC_REP))) L = COMP(FIRST(Lt),L); Lt = L; for(L = NIL; Lf != NIL; Lf = RED(Lf)) if (LELTI(LELTI(FIRST(Lf),SC_REP),LEVEL) == CELLDIM(LELTI(FIRST(Lf),SC_REP))) L = COMP(FIRST(Lf),L); Lf = L; if (Lt == NIL && Lf == NIL) { SWRITE("No cells have truth values!\n"); goto Return; } t = ESPCADDOPFSUFF(Pp,LIST1(Dp)); LA = LISTOETAmod(Pp,n,t==NIL); /* Construct formula */ SF = NECCONDS(Lt,Lf,LA,Pp); SF = FMASORT(SF); SF = FMA_REMCONST(SF); SF = FMASMOOTH(SF); SF = FMAOPCOMBINE(SF); Return: /* Prepare to return. */ return SF; }
Word CF(Word L,Word F,Word P) { Word Fp,A,Ap,f; switch(FIRST(F)) { case (TRUE) : Fp = F; break; case (FALSE) : Fp = F; break; case (ANDOP) : A = RED(F); for(Ap = NIL; A != NIL; A = RED(A)) { f = CF(L,FIRST(A),P); if (FIRST(f) == FALSE) { Fp = f; goto Return; } if (FIRST(f) != TRUE) Ap = COMP(f,Ap); } if (Ap == NIL) Fp = LIST1(TRUE); else if (LENGTH(Ap) == 1) Fp = FIRST(Ap); else Fp = COMP(ANDOP,Ap); break; case (OROP) : A = RED(F); for(Ap = NIL; A != NIL; A = RED(A)) { f = CF(L,FIRST(A),P); if (FIRST(f) == TRUE) { Fp = f; goto Return; } if (FIRST(f) != FALSE) Ap = COMP(f,Ap); } if (Ap == NIL) Fp = LIST1(FALSE); else if (LENGTH(Ap) == 1) Fp = FIRST(Ap); else Fp = COMP(OROP,Ap); break; default: f = UNIFORMTV(L,F,P); if (f == UNDET) Fp = F; else Fp = LIST1(f); break; } Return: return Fp; }
static int featureset_comp(const void *x, const void *y, size_t n, void *udata) { int ret = 0; const crf1df_feature_t* f1 = (const crf1df_feature_t*)x; const crf1df_feature_t* f2 = (const crf1df_feature_t*)y; ret = COMP(f1->type, f2->type); if (ret == 0) { ret = COMP(f1->src, f2->src); if (ret == 0) { ret = COMP(f1->dst, f2->dst); } } return ret; }
Word CYLFORM(Word C, Word P, Word k, Word A) { Word SF,L,Lp,c,S,t,Q,As,Ap,Fp,F,Lt,Lf,s; Step1: /* Set L to a list of all (k-1)-level cells over which there are k-level cells with SC_TMPM of TRUE. */ if (k == 0) { SF = LIST1(TRUE); goto Return; } SF = NIL; L = NIL; for(Lp = PCADCL(C,k-1); Lp != NIL; Lp = RED(Lp)) { c = FIRST(Lp); S = LELTI(c,SC_CDTV); if (!ISLIST(S)) continue; for(t = 0; S != NIL && !t; S = RED(S)) t = (LELTI(FIRST(S),SC_TMPM) == TRUE); if (t) L = COMP(c,L); } Step3: /* Construct formula for the k-level cells. */ Lt = NIL; Lf = NIL; S = NIL; for(Lp = L; Lp != NIL; Lp = RED(Lp)) S = CCONC(LELTI(FIRST(Lp),SC_CDTV),S); for(S = PCADCL(C,k); S != NIL; S = RED(S)) { s = FIRST(S); if (LELTI(s,SC_TMPM) == TRUE) Lt = COMP(s,Lt); else Lf = COMP(s,Lf); } F = NAIVESF(SPCADCBDD(Lt,k),Lf,A,P); Step2: /* Formula for the projection. */ for(Q = L; Q != NIL; Q = RED(Q)) SLELTI(FIRST(Q),SC_TMPM,TRUE); As = NIL; for(Ap = CINV(A); Ap != NIL; Ap = RED(Ap)) if (FMALEVEL(FIRST(Ap)) < k) As = COMP(FIRST(Ap),As); Fp = CYLFORM(C,P,k-1,As); SF = LIST3(ANDOP,Fp,F); Return: /* Prepare to return. */ return SF; }
Word STACKMULT(Word c) { Word d,i,m,p,M,S; Step1: /* Get the stack over c. */ S = LELTI(c,CHILD); Step2: /* Construct the stack multiplicity list. */ M = NIL; if (S == NIL) goto Return; S = RED(S); if (S == NIL) goto Return; i = 2; while (S != NIL) { d = FIRST(S); m = LELTI(d,MULSUB); p = LIST2(i,m); M = COMP(p,M); i = i + 2; S = RED2(S); } M = INV(M); Return: /* Return M. */ return (M); }
void VLREADR(Word *V_, Word *t_) { Word C,V,t,v; /* hide C,t; */ Step1: /* Read variables. */ t = 1; V = NIL; C = CREADB(); if (C != '(') { SWRITE("Error VLREADR: '(' was expected.\n"); goto Step2; } C = CREADB(); if (C == ')') goto Return; else BKSP(); do { VREADR(&v,&t); if (t == 0) goto Return; V = COMP(v,V); C = CREADB(); if (C == ')') { V = INV(V); goto Return; } if (C != ',') { SWRITE("Error VLREADR: ',' was expected.\n"); goto Step2; } } while (1); Step2: /* Error. */ DIELOC(); t = 0; goto Return; Return: /* Prepare for return. */ *V_ = V; *t_ = t; return; }