Esempio n. 1
0
void QepcadCls::ECLI(Word D, Word *c_, Word *t_)
{
  Word L,l,t,c,p;

Step1: /* Initialize if first time through (GVECPI = 0). */
       if (GVECPI == 0) {
	 GVECS = ISFECLI(D);
	 goto Step3; }

Step2: /* Look for previously returned eligible cell.  If it is still
in the CAD and has undetermined truth value, push the indices of its 
eligible children onto the stack. */
       p = CELLNA(GVECPI,D);
       if (SCREEN(p))
	 for(L = CINV(LELTI(p,CHILD)); L != NIL; L = RED(L)) {
	   l = FIRST(L);
	   if (SCREEN(l))
	     GVECS = COMP(LELTI(l,INDX),GVECS); }

Step3: /* Keep popping cell indices off the stack until one is found 
such that the corresponding cell still exists and does not already 
have a truth value.  If the cell returned by CELLNA is not the one
with index GVECPI, then it must have determined truth value.  Thus 
this single test below accounts for two cases:  The cell with index
GVECPI does exist but has determined truth value, or the cell with
index GVECPI does not exist any longer. */
       while(GVECS != NIL) {
	 ADV(GVECS,&GVECPI.W,&GVECS.W);
	 p = CELLNA(GVECPI,D);
	 if (SCREEN(p)) {
	   t = 1;
	   c = p;
	   goto Return; } }

Step4: /* No more cells left. */
       t = 0;
       c = NIL;
       GVECPI = 0;

Return: /* Prepare to return. */
       *c_ = c;
       *t_ = t;
       return;
}
Esempio n. 2
0
Word SSILRCRI(Word a_, Word b_)
{
       Word s,a,b,p,c,a1,a2,b1,b2,n,t,m,B,C,r;

Step0: /* Reflect interval if neccesary. */
       if (RNSIGN(a_) == -1) {
         s = 1; a = RNNEG(b_); b = RNNEG(a_); }
       else {
         s = 0; a = a_; b = b_; }

Step1: /* Initialize loop.  */
       RNFCL2(RNDIF(b,a),&p,&c);
       if (p == c) p--;
       FIRST2(b,&b1,&b2);
       if (a == 0)
         n = 0;
       else {
         FIRST2(a,&a1,&a2);
         n = IQ(ITRUNC(a1,p),a2); }

Step2: /* Loop until n is even, then increment p and divide n by 2. */
       do {
         if (ISATOM(n)) t = ODD(n);
         else t = ODD(FIRST(n));
         p++;
         n = IDP2(n,1);
       }while(t);
       m = ISUM(n,1);

Step3: /* If p is smallest possible, i.e. p = c, check (m+1)2^p > b. */
       if (p == c) {
         if (p >= 0) {
           B = b1;
           C = IMP2(IPROD(b2,m),p); }
         else {
           B = IMP2(b1,-p);
           C = IPROD(b2,m); }
         if (ICOMP(B,C) >= 1)
           goto Step2; }

Return: /* Return, reflecting the output interval if needed. */
       if (s) { r = n; n = -m; m = -r; }
       return (LIST2(LBRNFIE(n,p),LBRNFIE(m,p)));
}
Esempio n. 3
0
void IPLLDWR(Word V, Word A)
{
       Word A1,A11,i,P,L,H;
       /* hide i,j,n,r; */

Step1: /* Write. */
       i = 0;
       while (A != NIL)
         {
         ADV(A,&A1,&A);  i = i + 1;
         while (A1 != NIL)
           {
           ADV(A1,&A11,&A1);
           PLABELWR(A11);
           TAB(7);
           SWRITE("= "); 
           H = LELTI(A11,PO_PARENT);
           PARENTWR(H);
           if (LELTI(A11,PO_STATUS) == PO_REMOVE)
             SWRITE("  *** Removed ***  ");
           if (LELTI(A11,PO_TYPE) == PO_ECON)
             SWRITE("  *** Equational Constraint ***  ");
           P = LELTI(A11,PO_POLY);
           SWRITE("\n");
           TAB(7);
           SWRITE("= "); 
	 
	   if (LELTI(A11,PO_TYPE) == PO_POINT) {
	     SAMPLEWR(i,FIRST(P),4);
	   }
	   else {
	     IPDWRITE(i,P,V); SWRITE("\n");
	   }
           SWRITE("\n");
           }

         if (A != NIL)
           SWRITE("\n");
         }

Return: /* Prepare for return. */
       return;
}
Esempio n. 4
0
bool		List_remove(List *l, list_predicate fct, void *param)
{
	List_Iterator *it = FIRST(l);
	List_Iterator *tmp = NULL;

	if (!it)
		return false;
	while (it)
	{
		tmp = NEXT(it);
		if (fct(it->data, param))
		{
			List_remove_it(l, it);
			return true;
		}
		it = tmp;
    }
	return false;
}
Esempio n. 5
0
void QepcadCls::PROJMCECCLOSURE(Word P, Word J, Word Q)
{
      Word N,k,Q_k,PP,NP,pp,L,l,i,S,s;

Step1: /* Initialization. */
      N = LENGTH(Q);

Step2: /* Loop from */
      for(k = N; k > 1; k--) {

	Q_k = LELTI(Q,k);
	SEPPIVNONPIV(Q_k,k,&PP,&NP);

	while (PP != NIL) {
	  ADV(PP,&pp,&PP);

Step3: /* Add necessary coefficients of pp. */
	  L = PFSUFFCOEF(pp,P,J);
	  while (L != NIL ) { 
	    ADV(L,&l,&L); 
	    i = SECOND(LELTI(l,PO_LABEL));
	    SLELTI(Q,i,PFSUNION(LELTI(Q,i),LIST1(l))); }

Step4: /* Add factors of the discriminant of pp. */
	  if (PDEG(LELTI(pp,PO_POLY)) > 1) {
	    L = PFDISCRIM(pp,P,J);
	    while (L != NIL ) { 
	      ADV(L,&l,&L); 
	      i = SECOND(LELTI(l,PO_LABEL));
	      SLELTI(Q,i,PFSUNION(LELTI(Q,i),LIST1(l))); } }

Step5: /* Add resultants. */
	  for(S = CCONC(PP,NP); S != NIL; S = RED(S)) {
	    s = FIRST(S);
	    L = PFRES(pp,s,P,J);
	    while (L != NIL ) { 
	      ADV(L,&l,&L); 
	      i = SECOND(LELTI(l,PO_LABEL));
	      SLELTI(Q,i,PFSUNION(LELTI(Q,i),LIST1(l))); } } } }

Return:/* Return. */
      return;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
void *
s3b_hash_put(struct s3b_hash *hash, void *value)
{
    const s3b_block_t key = KEY(value);
    u_int i;

    for (i = FIRST(hash, key); 1; i = NEXT(hash, i)) {
        void *const value2 = VALUE(hash, i);

        if (EMPTY(value))
            break;
        if (KEY(value2) == key) {
            VALUE(hash, i) = value;         /* replace existing value having the same key with new value */
            return value2;
        }
    }
    assert(hash->numkeys < hash->maxkeys);
    VALUE(hash, i) = value;
    hash->numkeys++;
    return NULL;
}
Esempio n. 8
0
void MainTest::testDate()
{
    QDateTime d = QDateTime::currentDateTime();
    QTime t = QTime(d.time().hour(), d.time().minute(), d.time().second());
    d.setTime(t);

    Post *newPost = new Post;
    newPost->setTitle("post title");
    newPost->setSaveDate(d);

    db.posts()->append(newPost);

    db.saveChanges();

    auto q = FROM(db.posts())
            WHERE(Post::idField() == newPost->id())
            FIRST();

    qDebug() << d << q->saveDate();
    QTEST_ASSERT(q->saveDate() == d);
}
Esempio n. 9
0
service_t *
lookup_service_by_name(bootstrap_info_t *bootstrap, name_t name)
{
	service_t *servicep;

	if (bootstrap)
		do {
			for (  servicep = FIRST(services)
			     ; !IS_END(servicep, services)
			     ; servicep = NEXT(servicep))
			{
				if (!STREQ(name, servicep->name))
					continue;
				if (bootstrap && servicep->bootstrap != bootstrap)
					continue;
				return servicep;
			}
		} while (bootstrap != &bootstraps &&
			(bootstrap = bootstrap->parent));
	return NULL;
}
Esempio n. 10
0
static void		print_op(t_ps *ps, int op)
{
	if (OPT(OPT_EXEC))
	{
		if (OPT(OPT_VERBOSE))
		{
			if (!(OPT(OPT_INTERACTIVE)))
				ft_putendl(g_ops[op].name);
			print_stacks(ps);
		}
		else if (!OPT(OPT_INTERACTIVE) && !(OPT(OPT_GRAPHIC)))
			ft_printf("%s ", g_ops[op].name);
		if (OPT(OPT_GRAPHIC))
		{
			if ((G_MODE(0)
			|| (G_MODE(1) && !(ps->total_ops % (ps->total_elem / 30 + 1)))
			|| (G_MODE(2) && CURR_VAL(FIRST(ps->stack_a)) == ps->range_min)))
				mlx_redraw(ps, g_ops[op].name);
		}
	}
}
Esempio n. 11
0
Word NAIVEDOPFSUFF(Word P, Word D, Word i)
{
      Word t,L,tc,fc,tf,ff,c1,c2;

Step1: /* Set L to the list of all i-level cells. */
      L = CADCL(D,i);
      if (L == NIL) {
	t = -7;
	goto Return; }

Step2: /* Sort L by signiture. */
      L = GMSL(L,comp);

Step3: /* */
      tc = 0; fc = 0;
      while (L != NIL) {
	tf = 0; ff = 0;
	ADV(L,&c1,&L);
	if (LELTI(c1,TRUTH) == TRUE) tf++; else ff++;
	while(L != NIL && comp(c1,FIRST(L)) == 0) {
	  ADV(L,&c2,&L);
	  if (LELTI(c2,TRUTH) == TRUE) tf++; else ff++; }
	if (tf && ff) {
	  t = NIL;
	  goto Return; }
	if (tf) tc++;
	else    fc++; }

Step4: /* */      
      if (tc && fc)
	t = UNDET;
      else if (tc)
	t = TRUE;
      else
	t = FALSE;

Return: /* Prepare to return. */
      return (t);
}
Esempio n. 12
0
Word LPFZC(Word C, Word P)
{
      Word v,l,Q,L,i,s,p;

Step1: /* Get the sign vector for the projection factors of the cell's 
          level, and the list of projection factors of that level. */
      l = LELTI(C,LEVEL);
      v = FIRST(LELTI(C,SIGNPF));
      Q = LELTI(P,l);

Step2: /* Find proj fac's with sign zero in C. */
      L = NIL;
      for(i = 1; v != NIL; i++) {
	ADV(v,&s,&v);
	ADV(Q,&p,&Q);
	if (s == 0)
	  L = COMP(p,L); }

Return: /* Prepare to return. */
      return (L);

}
Esempio n. 13
0
void		List_insertion_sort(List *l, list_cmp_fct cmpf)
{
	List_Iterator	*it = FIRST(l);
	void *data = NULL;
	List_Iterator *current = NULL;
	List_Iterator *next = NULL;
	int len = COUNT(l);

	if (len <= 1 || !it)
		return ;
	INC_IT(it); //positioned on the second node
	while (it)
	{
		current = it;
		next = it->next;
		DEC_IT(it);
		while (it && cmpf(current->data, it->data) > 1)
			DEC_IT(it);
		if (!it) // prepend
		{
			data = List_remove_it(l, current); // Remove
			if (!List_prepend(l, data))
			{
				printf("Error prepending node to list [insertion sort]\n");
				return;
			}
		}
		else if (it != current && it != current->prev)
		{
			data = List_remove_it(l, current); // Remove
			if (!List_insert_after_it(l, it, data))
			{
				printf("Error inserting node into list [insertion sort]\n");
				return;
			}
		}
		it = next;
	}
}
Esempio n. 14
0
void MODCRDB(Word b, Word S1, Word Ms, Word Ns, Word *b1_)
{
       Word b1;

Step1: /* Process. */
       if (PCDBUSE == 'n')
         {
         MODCR(b,S1,Ms,Ns,&b1);
         goto Return;
         }
       if (DBSRCH(DBMODCR,LIST4(b,S1,Ms,Ns)) == 0)
         {
         MODCR(b,S1,Ms,Ns,&b1);
         DBADD(DBMODCR,LIST4(b,S1,Ms,Ns),LIST1(b1),&DBMODCR);
         }
       else
         b1 = FIRST(DBINFO);
       goto Return;

Return: /* Prepare for return. */
       *b1_ = b1;
       return;
}
Esempio n. 15
0
void PCADWRITE(Word Cs, Word Ps)
{
      Word C,l,i,L,k,I;

Step1: /* */
      I = PCADCINDEX(Cs);
      l = LENGTH(I);
      L = LELTI(Cs,SC_CDTV);

Step2: /* */
      SWRITE("\n");
      for(k = 0; k < l; k++)
	SWRITE("    ");
      OWRITE(I);

Step3: /* */
      SWRITE(":");
      SIGNLWR(PCADCSV(Cs,Ps));

Step4: /* */
      if (ISATOM(L)) {
	if (L == 0)
	  SWRITE(":F");
	else if (L == 1)
	  SWRITE(":T");
	else 
	  SWRITE(":?"); }
      else {
	SWRITE(":==>");
	while (L != NIL) {
	  PCADWRITE(FIRST(L),Ps);
	  L = RED(L); } }

Return: /* */
      if (I == NIL) SWRITE("\n");
      return;
}
Esempio n. 16
0
Word SIMPLIFYSYSLIST(BDigit r, Word L, Word A)
{
  Word Q, Lp, Qp;

Step1: /* Simplify each element individually */
  Q = NIL;
  for(Lp = L; Lp != NIL; Lp = RED(Lp))
  {
    Qp = SIMPLIFYSYS(r,FIRST(Lp),NIL,A);
    if (Qp != 1)
      Q = CCONC(Qp,Q);
  }

Step2: /* Check for inconsistency */
  if (Q == NIL)
    Q = 1;

Step3: /* Remove Sys A if Sys A contained in Sys B */
  if (Q != 1)
    Q = SOSRSUPS(Q);

Return: /* Prepare to return. */
  return Q;
}
Esempio n. 17
0
void IPLDWR(Word V, Word A)
{
       Word A1,P,r;

Step1: /* Write. */
       while (A != NIL)
       {
         ADV(A,&A1,&A);
         PLABELWR(A1);
         SWRITE(" = "); 
         r = SECOND(LELTI(A1,PO_LABEL));
         P = LELTI(A1,PO_POLY);
	 
	 if (LELTI(A1,PO_TYPE) == PO_POINT) {
	   SAMPLEWR(r,FIRST(P),4);
	 }
	 else {
	   IPDWRITE(r,P,V); SWRITE("\n");
	 }
       }

Return: /* Prepare for return. */
       return;
}
Esempio n. 18
0
Word RMCAFS(Word F)
{
    Word F1,F2,Fb,Fp,Fp1,Fp2,T,t,t1,t2;
    /* hide t,t1,t2; */

Step1: /* Classify the formula F. */
    T = FIRST(F);
    if (T == ANDOP) goto Step3;
    if (T == OROP) goto Step4;
    if (T == NOTOP) goto Step5;
    if (T == RIGHTOP) goto Step6;
    if (T == LEFTOP) goto Step7;
    if (T == EQUIOP) goto Step8;

Step2: /* Atomic Formula. */
    t = TYPEAF(F);
    if (t == TRUE) {
        Fp = LIST4(EQOP,0,0,NIL);
        goto Return;
    }
    if (t == FALSE) {
        Fp = LIST4(NEOP,0,0,NIL);
        goto Return;
    }
    Fp = F;
    goto Return;

Step3: /* Conjunction. */
    Fb = RED(F);
    Fp = LIST1(ANDOP);
    while (Fb != NIL)
    {
        ADV(Fb,&F1,&Fb);
        Fp1 = RMCAFS(F1);
        t = TYPEQFF(Fp1);
        if (t == FALSE) {
            Fp = LIST4(NEOP,0,0,NIL);
            goto Return;
        }
        if (t == UNDET) Fp = COMP(Fp1,Fp);
    }
    if (LENGTH(Fp) == 1) {
        Fp = LIST4(EQOP,0,0,NIL);
        goto Return;
    }
    if (LENGTH(Fp) == 2) {
        Fp = FIRST(Fp);
        goto Return;
    }
    Fp = INV(Fp);
    goto Return;

Step4: /* Disjunction. */
    Fb = RED(F);
    Fp = LIST1(OROP);
    while (Fb != NIL)
    {
        ADV(Fb,&F1,&Fb);
        Fp1 = RMCAFS(F1);
        t = TYPEQFF(Fp1);
        if (t == TRUE) {
            Fp = LIST4(EQOP,0,0,NIL);
            goto Return;
        }
        if (t == UNDET) Fp = COMP(Fp1,Fp);
    }
    if (LENGTH(Fp) == 1) {
        Fp = LIST4(NEOP,0,0,NIL);
        goto Return;
    }
    if (LENGTH(Fp) == 2) {
        Fp = FIRST(Fp);
        goto Return;
    }
    Fp = INV(Fp);
    goto Return;

Step5: /* Negation. */
    F1 = SECOND(F);
    Fp1 = RMCAFS(F1);
    t = TYPEQFF(Fp1);
    if (t == TRUE) Fp = LIST4(NEOP,0,0,NIL);
    else if (t == FALSE) Fp = LIST4(EQOP,0,0,NIL);
    else Fp = LIST2(NOTOP,Fp1);
    goto Return;

Step6: /* $\Rightarrow$. */
    F1 = SECOND(F);
    Fp1 = RMCAFS(F1);
    t1 = TYPEQFF(Fp1);
    F2 = THIRD(F);
    Fp2 = RMCAFS(F2);
    t2 = TYPEQFF(Fp2);
    if (t1 == TRUE) Fp = Fp2;
    else if (t1 == FALSE) Fp = LIST4(EQOP,0,0,NIL);
    else if (t2 == TRUE) Fp = LIST4(EQOP,0,0,NIL);
    else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1);
    else Fp = LIST3(RIGHTOP,Fp1,Fp2);
    goto Return;

Step7: /* $\Leftarrow$. */
    F1 = THIRD(F);
    Fp1 = RMCAFS(F1);
    t1 = TYPEQFF(Fp1);
    F2 = SECOND(F);
    Fp2 = RMCAFS(F2);
    t2 = TYPEQFF(Fp2);
    if (t1 == TRUE) Fp = Fp2;
    else if (t1 == FALSE) Fp = LIST4(EQOP,0,0,NIL);
    else if (t2 == TRUE) Fp = LIST4(EQOP,0,0,NIL);
    else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1);
    else Fp = LIST3(LEFTOP,Fp2,Fp1);
    goto Return;

Step8: /* $\Leftrightarrow$. */
    F1 = SECOND(F);
    Fp1 = RMCAFS(F1);
    t1 = TYPEQFF(Fp1);
    F2 = THIRD(F);
    Fp2 = RMCAFS(F2);
    t2 = TYPEQFF(Fp2);
    if (t1 == TRUE) Fp = Fp2;
    else if (t2 == TRUE) Fp = Fp1;
    else if (t1 == FALSE && t2 == FALSE) Fp = LIST4(EQOP,0,0,NIL);
    else if (t1 == FALSE) Fp = LIST2(NOTOP,Fp2);
    else if (t2 == FALSE) Fp = LIST2(NOTOP,Fp1);
    else Fp = LIST3(EQUIOP,Fp1,Fp2);
    goto Return;

Return: /* Prepare for return. */
    return(Fp);
}
DO
	wchar_t *expression = GET_STRING (L"Formula");
	LOOP {
		iam (Formant);
		Formant_formula (me, GET_REAL (L"left Time range"), GET_REAL (L"right Time range"),
			GET_INTEGER (L"left Formant range"), GET_INTEGER (L"right Formant range"), interpreter, expression);
	}
END

/******************** Formant & Spectrogram ********************************************/

FORM (Formant_and_Spectrogram_to_IntensityTier, L"Formant & Spectrogram: To IntensityTier", L"Formant & Spectrogram: To IntensityTier...")
	NATURAL (L"Formant number", L"1")
	OK
DO
	Formant me = FIRST (Formant);
	long iformant = GET_INTEGER (L"Formant number");
	Spectrogram thee = FIRST (Spectrogram);
	autoIntensityTier him = Formant_and_Spectrogram_to_IntensityTier (me, thee, iformant);
	praat_new (him.transfer(), my name, L"_", Melder_integer (GET_INTEGER (L"Formant number")));
END


/********************LFCC ********************************************/

DIRECT (LFCC_help)
	Melder_help (L"LFCC");
END

FORM (LFCC_to_LPC, L"LFCC: To LPC", L"LFCC: To LPC...")
	INTEGER (L"Number of coefficients", L"0")
Esempio n. 20
0
void
deactivate_bootstrap(bootstrap_info_t *bootstrap)
{
	bootstrap_info_t *deactivating_bootstraps;
	bootstrap_info_t *query_bootstrap;
	bootstrap_info_t *next_limit;
	bootstrap_info_t *limit;

	/*
	 * we need to recursively deactivate the whole subset tree below
	 * this point.  But we don't want to do real recursion because
	 * we don't have a limit on the depth.  So, build up a chain of
	 * active bootstraps anywhere underneath this one.
	 */
	deactivating_bootstraps = bootstrap;
	bootstrap->deactivate = NULL;
	for (next_limit = deactivating_bootstraps, limit = NULL
			 ; deactivating_bootstraps != limit
			 ; limit = next_limit, next_limit = deactivating_bootstraps)
	{
		for (bootstrap = deactivating_bootstraps
				 ; bootstrap != limit
				 ; bootstrap = bootstrap->deactivate)
		{
			for (  query_bootstrap = FIRST(bootstraps)
				   ; !IS_END(query_bootstrap, bootstraps)
				   ; query_bootstrap = NEXT(query_bootstrap))
			{
				if (query_bootstrap->parent == bootstrap &&
					query_bootstrap->requestor_port != MACH_PORT_NULL) {
					mach_port_deallocate(
										 mach_task_self(),
										 query_bootstrap->requestor_port);
					query_bootstrap->requestor_port = MACH_PORT_NULL;
					query_bootstrap->deactivate = deactivating_bootstraps;
					deactivating_bootstraps = query_bootstrap;
				}
			}
		}
	}

	/*
	 * The list is ordered with the furthest away progeny being
	 * at the front, and concluding with the one we started with.
	 * This allows us to safely deactivate and remove the reference
	 * each holds on their parent without fear of the chain getting
	 * corrupted (because each active parent holds a reference on
	 * itself and that doesn't get removed until we reach its spot
	 * in the list).
	 */
	do {
		bootstrap = deactivating_bootstraps;
		deactivating_bootstraps = bootstrap->deactivate;

		info("deactivating bootstrap %x", bootstrap->bootstrap_port);

		delete_bootstrap_services(bootstrap);
		
		mach_port_deallocate(mach_task_self(), bootstrap->bootstrap_port);

		{
			mach_port_t previous;
			mach_port_request_notification(
					mach_task_self(),
					bootstrap->bootstrap_port,
					MACH_NOTIFY_NO_SENDERS,
					1,
					bootstrap->bootstrap_port,
					MACH_MSG_TYPE_MAKE_SEND_ONCE,
					&previous);
		}
	} while (deactivating_bootstraps != NULL);
}
Esempio n. 21
0
static int
pdf_insert_bookmark(
    PDF *p,
    const char *hypertext,
    pdf_outline *outline,
    int jndex)
{
    static const char fn[] = "pdf_insert_bookmark";
    pdf_outline *root, *self;
    int parent;
    int self_idx;
    int pageno = pdf_current_page(p);

    /* allocation */
    if (p->outline_count == 0)
    {
        p->outline_capacity = OUTLINE_CHUNKSIZE;
        p->outlines = (pdf_outline *) pdc_calloc(p->pdc,
                          sizeof(pdf_outline) * p->outline_capacity, fn);

        /* populate the root outline object */
        root = &p->outlines[0];
        pdf_init_outline(p, root);
        root->obj_id = pdc_alloc_id(p->out);
        root->open = pdc_true;

        /* set the open mode show bookmarks if we have at least one,
         * and the client didn't already set his own open mode.
         */
        pdf_fix_openmode(p);
    }
    else if (p->outline_count + 1 >= p->outline_capacity)
    {
        p->outline_capacity *= 2;
        p->outlines = (pdf_outline *) pdc_realloc(p->pdc, p->outlines,
                          sizeof(pdf_outline) * p->outline_capacity, fn);
    }

    /* copy */
    self_idx = ++p->outline_count;
    self = &p->outlines[self_idx];
    memcpy(self, outline, sizeof(pdf_outline));

    self->obj_id = pdc_alloc_id(p->out);
    self->text = (char *) hypertext;
    self->page_id = pdf_get_page_id(p, 0);
    parent = self->parent;

    /* default destination */
    if (self->action == NULL && self->dest == NULL)
        self->dest = pdf_init_destination(p);

    /* no destination */
    if (self->dest != NULL &&
        self->dest->name != NULL && !strlen(self->dest->name))
    {
        pdf_cleanup_destination(p, self->dest);
        self->dest = NULL;
    }

    /* current page */
    if (self->dest)
    {
	/* this ugly code is for compatibility with the
	** obsolete "bookmarkdest" parameter.
	*/
        if (self->dest->pgnum == 0)
            self->dest->pgnum = pdf_current_page(p);

        if (self->dest->pgnum == 0)
	{
            self->dest->pgnum = 1;
	}
	else if (self->dest->page == PDC_BAD_ID)
	{
            self->dest->page = pdf_get_page_id(p, self->dest->pgnum);
	}
    }

    /* special case: empty list.
    */
    if (FIRST(parent) == 0)
    {
        if (jndex > 0)
	    pdc_error(p->pdc, PDC_E_OPT_ILLINTEGER, "index",
                pdc_errprintf(p->pdc, "%d", jndex), 0, 0);

        FIRST(parent) = LAST(parent) = self_idx;
	self->in_order = pdc_true;
    }
    else switch (jndex)
    {
	case -2:	/* insert "in order" */
	{
	    /* the "natural" case: append to the end if appropriate.
	    */
	    if (pageno >= search_backward(p, -1, LAST(parent)))
	    {
		self->prev = LAST(parent);
		NEXT(LAST(parent)) = self_idx;
		LAST(parent) = self_idx;
	    }
	    else
	    {
		int idx;
		int curr_pg = 1;
		int next_pg;

		for (idx = FIRST(parent); idx != 0; idx = NEXT(idx))
		{
		    if (!IN_ORDER(idx))
			continue;

		    next_pg = pdf_search_page_fwd(p, curr_pg, PAGE_ID(idx));

		    /* TODO: understand why this can happen.
		    */
		    if (next_pg < 1)
		    {
			idx = 0;
			break;
		    }

		    if (next_pg > pageno)
		    {
			self->next = idx;
			self->prev = PREV(idx);
			PREV(idx) = self_idx;

			if (self->prev == 0)
			    FIRST(parent) = self_idx;
			else
			    NEXT(self->prev) = self_idx;

			break;
		    }

		    curr_pg = next_pg;
		}

		/* if there are no "in order" bookmarks yet,
		** we simply append this one to the end.
		*/
		if (idx == 0)
		{
		    self->prev = LAST(parent);
		    NEXT(LAST(parent)) = self_idx;
		    LAST(parent) = self_idx;
		}
	    }

	    self->in_order = pdc_true;
	    break;
	}

	case -1:	/* append to the end */
	{
	    self->prev = LAST(parent);
	    NEXT(LAST(parent)) = self_idx;
	    LAST(parent) = self_idx;

	    self->in_order =
		(pageno >= search_backward(p, pageno, self->prev));
	    break;
	}

	case 0:		/* insert at the beginning */
	{
	    self->next = FIRST(parent);
	    PREV(FIRST(parent)) = self_idx;
	    FIRST(parent) = self_idx;

	    self->in_order =
		(pageno <= search_forward(p, pageno, self->next));
	    break;
	}

	default:	/* insert before [1..LAST] */
	{
	    int i;
	    int target = FIRST(parent);

            for (i = 0; i < jndex; ++i)
	    {
		if (target == LAST(parent))
		    pdc_error(p->pdc, PDC_E_OPT_ILLINTEGER, "index",
                        pdc_errprintf(p->pdc, "%d", jndex), 0, 0);

		target = NEXT(target);
	    }

	    self->next = target;
	    self->prev = PREV(target);
	    NEXT(self->prev) = PREV(self->next) = self_idx;

	    self->in_order =
		((pageno >= search_backward(p, pageno, self->prev)) &&
		(pageno <= search_forward(p, pageno, self->next)));
	    break;
	}
    } /* else switch */

    /* increase the number of open sub-entries for all relevant ancestors */
    do {
        COUNT(parent)++;
    } while (OPEN(parent) && (parent = PARENT(parent)) != 0);

    return (self_idx);          /* caller may use this as handle */
}
Esempio n. 22
0
void TVCLOSURE1D(Word D, Word P, Word J, Word k, Word t)
{
  Word S,cl,cm,cr,tl,tm,tr,I,fdflag ;
  
Step1: /* Initialize and check special cases. */
  S = LELTI(D,CHILD);
  if (S == NIL || LENGTH(S) == 1)
    goto Return;

Step2: /* */
  switch (t) {
  case 1: /* solution space closed */
    do {
      ADV2(S,&cl,&cm,&S); cr = FIRST(S);
      if (CCTV(cm) == UNDET) {
	if (CCTV(cl) == TRUE || CCTV(cr) == TRUE)
	  topinfset(cm,TRUE); }
      else 
	if (CCTV(cm) == FALSE) {
	  topinfset(cl,FALSE);
	  topinfset(cr,FALSE); }
    }while(RED(S) != NIL);
    break;

  case 2: /* non-solution space closed */
    do {
      ADV2(S,&cl,&cm,&S); cr = FIRST(S);
      if (CCTV(cm) == UNDET) {
	if (CCTV(cl) == FALSE || CCTV(cr) == FALSE)
	  topinfset(cm,FALSE); }
      else 
	if (CCTV(cm) == TRUE) {
	  topinfset(cl,TRUE);
	  topinfset(cr,TRUE); }
    }while(RED(S) != NIL);
    break;

  case 3: /* means solution space is the closure of an open set */
    /* The situation here is a little complicated.  If the stack
       is over a full dimensional cell, then you can say more than
       you can otherwise. fdflag is 1 if the stack is over a
       full-dimensional cell and 0 otherwise. */

    for(I = LELTI(D,INDX); I != NIL && EVEN(FIRST(I)); I = RED(I));
    fdflag = (I == NIL);

    /* This loop deduces: 
       1) if cm false then all neighbors false
       2) if cl true or cr true then cm true
       3) if cl false and cr false then cm flase
       The third conclusion is only valid for stacks over full dimensiona
       cells.
     */
    do {
      ADV2(S,&cl,&cm,&S); cr = FIRST(S);
      tm = CCTV(cm);
      if (tm == FALSE) {
	topinfset(cl,FALSE);
	topinfset(cr,FALSE); }
      else if (tm == UNDET) {
	tl = CCTV(cl);
	tr = CCTV(cr);
	if (tl == TRUE || tr == TRUE)
	  topinfset(cm,TRUE);
	else if (fdflag && tl == FALSE && tr == FALSE)
	  topinfset(cm,FALSE); }
    }while(RED(S) != NIL);

    /* This loop basically just applies the fact that, for a stack
       over a full dimensional cell, a true section implies one of
       the neighboring sectors is true. 
     */
    S = LELTI(D,CHILD);
    do {
      ADV2(S,&cl,&cm,&S); cr = FIRST(S);
      if (fdflag && CCTV(cm) == TRUE) {
	tl = CCTV(cl);
	tr = CCTV(cr);
	if (tl == FALSE)
	  topinfset(cr,TRUE);
	else if (tr == FALSE)
	  topinfset(cl,TRUE); }
    }while(RED(S) != NIL);

    break; }

Step3: /* Propogate truth values up. */
  CTVPROPUP(D,UNDET,k,TOPINF);

Return: /* Prepare to return. */
  return;
}
Esempio n. 23
0
DIRECT (CrossCorrelationTable_help)
	Melder_help (L"CrossCorrelationTable");
END

DIRECT (CrossCorrelationTable_to_PCA)
	LOOP {
		iam (CrossCorrelationTable);
		praat_new (SSCP_to_PCA (me), my name);
	}
END

FORM (Sound_and_PCA_projectChannels, L"Sound & PCA: To Sound (project channels)", 0)
	NATURAL (L"Number of components", L"10")
	OK
DO
	Sound me = FIRST (Sound);
	PCA thee = FIRST (PCA);
	praat_new (Sound_and_PCA_projectChannels (me, thee, GET_INTEGER (L"Number of components")), Thing_getName (me), L"_projected");
END

FORM (Sound_and_PCA_whitenChannels, L"Sound & PCA: To Sound (whiten channels)", 0)
	NATURAL (L"Number of components", L"10")
	OK
DO
	Sound me = FIRST (Sound);
	PCA thee = FIRST (PCA);
	praat_new (Sound_and_PCA_whitenChannels (me, thee, GET_INTEGER (L"Number of components")), Thing_getName (me), L"_white");
END

DIRECT (CrossCorrelationTable_to_CrossCorrelationTables)
	autoCrossCorrelationTables thee = CrossCorrelationTables_create ();
Esempio n. 24
0
DO
	LOOP {
		iam (FFNet);
		praat_new (FFNet_weightsToMatrix (me, GET_INTEGER (L"Layer number"), 0), my name);
	}
END

/******************* FFNet && Activation *************************************/

FORM (FFNet_Activation_to_Categories, L"FFNet & Activation: To Categories", 0)
	RADIO (L"Kind of labeling", 1)
	RADIOBUTTON (L"Winner-takes-all")
	RADIOBUTTON (L"Stochastic")
	OK
DO
	FFNet me = FIRST (FFNet);
	Activation thee = FIRST (Activation);
	praat_new (FFNet_Activation_to_Categories (me, thee, GET_INTEGER (L"Kind of labeling")), my name, L"_", thy name);
END

/******************* FFNet && Eigen ******************************************/

FORM (FFNet_Eigen_drawIntersection, L"FFnet & Eigen: Draw intersection", 0)
	INTEGER (L"X-component", L"1")
	INTEGER (L"Y-component", L"2")
	REAL (L"xmin", L"0.0")
	REAL (L"xmax", L"0.0")
	REAL (L"ymin", L"0.0")
	REAL (L"ymax", L"0.0")
	OK
DO
Esempio n. 25
0
Word NECCONDS(Word L_T, Word L_F, Word L_A, Word P)
{
     Word SF,Lp,N,a,t,Fp,SFp,A,n,S,f,S_f,T,I,i,Ap,L;

Word t1,t2,t3;
t1 = ACLOCK();

Step1: /* Construct N, the list of necessary conditions. */
     for(Lp = CINV(L_A), N = NIL; Lp != NIL; Lp = RED(Lp)) {
       a = FIRST(Lp);
       for(t = TRUE,T = L_T; t == TRUE && T != NIL; T = RED(T))
	 t = FMACELLEVAL(a,FIRST(T),P);
       if (t == TRUE)
	 N = COMP(a,N); }

Step2: /* Construct Fp, the list of false cells satisfying N. */
     for(Lp = CINV(L_F), Fp = NIL; Lp != NIL; Lp = RED(Lp))
       if (FMACELLEVAL(COMP(ANDOP,N),FIRST(Lp),P) != FALSE)
	 Fp = COMP(FIRST(Lp),Fp);

t1 = ACLOCK() - t1;
t2 = ACLOCK();

Step3: /* Construct formula for simplified problem. */
     SFp = NAIVESF(L_T,Fp,L_A,P);

t2 = ACLOCK() - t2;
t3 = ACLOCK();

Step4: /* Construct Fp, the list of false cells satisfying SFp. */
     for(Lp = CINV(L_F), Fp = NIL; Lp != NIL; Lp = RED(Lp))
       if (FMACELLEVAL(SFp,FIRST(Lp),P) != FALSE)
	 Fp = COMP(FIRST(Lp),Fp);
     if (Fp == NIL) {
       SF = SFp;
       goto Return; }

Step5: /* Construct the minimum hitting set problem. */
     A = CINV(N);
     n = LENGTH(A);
     for(S = NIL; Fp != NIL; Fp = RED(Fp)) {
       f = FIRST(Fp);
       S_f = NIL;
       for(i = n, Ap = A; Ap != NIL; i--,Ap = RED(Ap))
         if (FMACELLEVAL(FIRST(Ap),f,P) == FALSE)
           S_f = COMP(i,S_f);
       S = COMP(S_f,S); }

Step6: /* Get the hitting set. */
     T = MINHITSETSR(S,-1);

Step7: /* Convert hitting set to a formula. */
     T = LBIBMS(T);
     for(I = NIL, L = N, i = 1; T != NIL; i++, L = RED(L))
       if (i == FIRST(T)) {
         T = RED(T);
         I = COMP(FIRST(L),I); }
     if (LENGTH(I) == 1)
       I = FIRST(I);
     else
       I = COMP(ANDOP,INV(I));

Step8: /* Join I and SFp. */
     SF = LIST3(ANDOP,I,SFp);

Return: /* Prepare to return. */

t3 = ACLOCK() - t3;
if (PCVERBOSE) {
SWRITE("\nNECCONDS: t1 = ");IWRITE(t1);SWRITE(" t2 = ");
IWRITE(t2);SWRITE(" t3 = ");IWRITE(t3);SWRITE("\n\n"); }
     return SF;     
}
Esempio n. 26
0
Word CFLCELLLIST(Word L_D)
{
      Word C,r,C_r,L,Lp,T,F,U,c,t,f,u,Fp,Up,h,Cb,Cp,Q;
      /* Time */ Word tm;

Step1: /* Initialize. */
      C = NIL;

Step2: /* Get the children of L_D. */
      L = NIL;
      for(Q = L_D; Q != NIL; Q = RED(Q)) {
	L = CCONC(LELTI(FIRST(Q),CHILD),L); }

Step3: /* Sort by signiture. */
	L = GISL(L,comp);

Step4: /* Loop over each block of cells with same signiture. */
	while (L != NIL) {
	  Lp = NIL;
	  do {
	    Lp = COMP(FIRST(L),Lp);
	    L = RED(L);
	  } while (L != NIL && comp(FIRST(Lp),FIRST(L)) == 0);

Step5: /* Separate into lists of TRUE, FALSE, and UNDET cells. */
	  T = NIL; F = NIL; U = NIL; C_r = NIL;
	  while (Lp != NIL) {
	    ADV(Lp,&c,&Lp);
	    switch (LELTI(c,TRUTH)) {
	    case (TRUE) :  T = COMP(c,T); break;
	    case (FALSE) : F = COMP(c,F); break;
	    case (UNDET) : U = COMP(c,U); break; } }

Step6: /* TRUE/FALSE & TRUE/UNDET combinations. */
	    for(; T != NIL; T = RED(T)) {
	      t = FIRST(T);
	      
	      for(Fp = F; Fp != NIL; Fp = RED(Fp)) {
		f = FIRST(Fp); C_r = COMP(LIST2(t,f),C_r); }
	      
	      for(Up = U; Up != NIL; Up = RED(Up)) {
		u = FIRST(Up);
		h = CATV(u);
		if (h == FALSE || h == UNDET) 
		  C_r = COMP(LIST2(t,u),C_r); } }

Step7: /* FALSE/UNDET combinations. */
	    for(; F != NIL; F = RED(F)) {
	      f = FIRST(F);
	      
	      for(Up = U; Up != NIL; Up = RED(Up)) {
		u = FIRST(Up);
		h = CATV(u);
		if (h == TRUE || h == UNDET) 
		  C_r = COMP(LIST2(f,u),C_r); } }

Step8: /* Recurse on the UNDET cells. */
	  if ( U != NIL )
	    Cb = COMP(C_r,CFLCELLLIST(U));
	  else
	    Cb = LIST1(C_r);
	  

Step9: /* Update C to include the */
	  Cp = NIL;
	  while( C != NIL && Cb != NIL ) {
	    Cp = COMP(CCONC(FIRST(Cb),FIRST(C)),Cp);
	    C = RED(C); Cb = RED(Cb); }
	  Cp = CINV(Cp);
	  if ( C != NIL ) Cp = CCONC(Cp,C);
	  if ( Cb != NIL ) Cp = CCONC(Cp,Cb);
	  C = Cp; }
	  

Return: /* Prepare to return. */
      return (C);
}
Esempio n. 27
0
Word NORMAF(Word A)
{
    Word F,I,L,L_i,Lh,Lh_i,P,P_i,Ph_i,T,c,e_i,r,rh_i,s;
    /* hide rh_i,s; */

Step1: /* Get the components. */
    if (FIRST(A) == IROOT)
    {
        F = NORMAETF(A);
        goto Return;
    }
    FIRST4(A,&T,&P,&r,&I);

Step2: /* \v{P} = 0. */
    if (P != 0) goto Step3;
    switch (T)
    {
    case EQOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case GEOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case LEOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case GTOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    case LTOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    case NEOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    }
    goto Return;

Step3: /* Factor \v{P}. */
    IPFACDB(r,P,&s,&c,&L);

Step4: /* Adjust \v{T}. */
    if (s < 0) T = NEGRLOP(T);

Step5: /* \v{P} is an integer. */
    if (L != NIL) goto Step6;
    switch (T)
    {
    case NEOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case GTOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case GEOP:
        F = LIST4(EQOP,0,0,NIL);
        break;
    case EQOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    case LTOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    case LEOP:
        F = LIST4(NEOP,0,0,NIL);
        break;
    }
    goto Return;

Step6: /* Simplify the representation of the polys in \v{L}. */
    Lh = NIL;
    while (L != NIL)
    {
        ADV(L,&L_i,&L);
        FIRST2(L_i,&e_i,&P_i);
        PSIMREP(r,P_i,&rh_i,&Ph_i);
        Lh_i = LIST3(e_i,rh_i,Ph_i);
        Lh = COMP(Lh_i,Lh);
    }
    Lh = INV(Lh);

Step7: /* Expand. */
    switch (T)
    {
    case EQOP:
        F = EXPAFEQ(Lh);
        break;
    case GTOP:
        F = EXPAFGT(Lh);
        break;
    case LTOP:
        F = EXPAFLT(Lh);
        break;
    case NEOP:
        F = LIST2(NOTOP,EXPAFEQ(Lh));
        break;
    case LEOP:
        F = LIST2(NOTOP,EXPAFGT(Lh));
        break;
    case GEOP:
        F = LIST2(NOTOP,EXPAFLT(Lh));
        break;
    }
    goto Return;

Return: /* Prepare for return. */
    return(F);
}
Esempio n. 28
0
int main()
{
    tipofilalancamento inicio, fim;
    tipo_equipe_OK topo;
    struct equipe equipe;
    struct equipe_OK equipe_OK;
    int cont = 1, lancamento_bem_sucedido = 1;
    
    init(&inicio,&fim); 
    init_lista_sucesso(&topo);
    
    while (cont == 1) {
        printf("Entre com o nome da equipe:\n");
        gets(equipe.nome);
        equipe.tentativas = 0;
        
        ENQUEUE(&inicio, &fim, equipe);
        printf("\nDeseja cadastrar mais equipes?\n");
        printf("(\"1\" = SIM, quero cadastrar mais equipes / \"0\" = NAO, quero iniciar os lancamentos)\n");
        scanf("%d", &cont);
    }
    
    while (!IsEmpty(inicio, fim)) {
          if (FIRST(inicio, fim, &equipe) == 1) {
             printf("Lancamento da Equipe \"%s\"", equipe.nome);
             printf("\n");
             printf("Entre com os dados do lancamento:\n\n");
             printf("Lancamento bem sucedido? (\"1\" = SIM / \"0\" = NAO): ");
             scanf("%d",&lancamento_bem_sucedido);
             if (lancamento_bem_sucedido == 1) {
                printf("\n");

                printf("Entre com a distancia do alvo: ");
                scanf("%d", &equipe_OK.distancia_do_alvo);
                printf("\n");

                printf("Entre com o tempo de propulsao (em s): ");
                scanf("%f", &equipe_OK.tempo_de_propulsao);
                printf("\n");
                
                PUSH(&topo, equipe);
                
                printf("\nConfirmacao: Equipe \"%s\" | Tempo de propulsao: %d | Distancia do alvo: %f", &equipe_OK.nome, &equipe_OK.tempo_de_propulsao, &equipe_OK.distancia_do_alvo);
                
                DEQUEUE(&inicio, &fim, &equipe);
             } else {
                equipe.tentativas += 1;
                if (equipe.tentativas == 2) {
                    DEQUEUE(&inicio, &fim, &equipe);
                    printf("Equipe desclassificada após 2 tentativas sem sucesso\n");
                }
             }
             
             scanf("%d", &cont);
             printf("\n");
          }
    }
  
    cont = 1;
    while (cont != 0) {
        printf("Fim dos lançamentos! O que deseja fazer agora?\n");
        printf("1 = Ver o número de equipes que concluíram a competição\n");
        printf("2 = Ver equipe com melhor resultado\n");
        printf("0 = Finalizar o programa\n");
        scanf("%d", &cont);
        switch (cont) {
            case 1:
                break;
            case 2:
                break;
            case 0:
                while(!IsEmpty){
                    POP(&topo, );
                }
                break;
        }
    }
    
    system("PAUSE");
    return 1;
}
Esempio n. 29
0
static void
pdf_write_outline_dict(PDF *p, int entry)
{
    pdf_outline *outline = &p->outlines[entry];
    pdc_id act_idlist[PDF_MAX_EVENTS];

    /* write action objects */
    if (outline->action)
        pdf_parse_and_write_actionlist(p, event_bookmark, act_idlist,
                                       (const char *) outline->action);

    pdc_begin_obj(p->out, OBJ_ID(entry));   /* outline object */
    pdc_begin_dict(p->out);

    pdc_objref(p->out, "/Parent", OBJ_ID(PARENT(entry)));

    /* outline destination */
    if (outline->dest)
    {
        pdc_puts(p->out, "/Dest");
        pdf_write_destination(p, outline->dest);
    }

    /* write Action entries */
    else if (outline->action)
        pdf_write_action_entries(p, event_bookmark, act_idlist);

    pdc_puts(p->out, "/Title"); /* outline text */
    pdf_put_hypertext(p, outline->text);
    pdc_puts(p->out, "\n");

    if (PREV(entry))
        pdc_objref(p->out, "/Prev", OBJ_ID(PREV(entry)));
    if (NEXT(entry))
        pdc_objref(p->out, "/Next", OBJ_ID(NEXT(entry)));

    if (FIRST(entry)) {
        pdc_objref(p->out, "/First", OBJ_ID(FIRST(entry)));
        pdc_objref(p->out, "/Last", OBJ_ID(LAST(entry)));
    }
    if (COUNT(entry)) {
        if (OPEN(entry))
            pdc_printf(p->out, "/Count %d\n", COUNT(entry));    /* open */
        else
            pdc_printf(p->out, "/Count %d\n", -COUNT(entry));/* closed */
    }

    /* Color */
    if (outline->textcolor[0] != 0.0 ||
        outline->textcolor[1] != 0.0 ||
        outline->textcolor[2] != 0.0)
        pdc_printf(p->out, "/C[%f %f %f]\n", outline->textcolor[0],
                                              outline->textcolor[1],
                                              outline->textcolor[2]);

    /* FontStyle */
    if (outline->fontstyle != fnt_Normal)
    {
        int fontstyle = 0;
        if (outline->fontstyle == fnt_Bold)
            fontstyle = 2;
        if (outline->fontstyle == fnt_Italic)
            fontstyle = 1;
        if (outline->fontstyle == fnt_BoldItalic)
            fontstyle = 3;
        pdc_printf(p->out, "/F %d\n", fontstyle);
    }

    pdc_end_dict(p->out);
    pdc_end_obj(p->out);                        /* outline object */
}
Esempio n. 30
0
void AFMSBM(Word M, Word A, Word B, Word *C_, Word *E_, Word *F_)
{
       Word A1,Ap,As,B1,Bp,Bs,C,E,Ep,F,Fp,G,G11,h,i,j,m,n;
       /* hide h,i,j,m,n; */

Step1: /* Setup. */
       As = NIL; Ap = A;
       while (Ap != NIL) { ADV(Ap,&A1,&Ap); As = COMP(A1,As); } As = INV(As);
       Bs = NIL; Bp = B;
       while (Bp != NIL) { ADV(Bp,&B1,&Bp); Bs = COMP(B1,Bs); } Bs = INV(Bs);

Step2: /* gcd. */
       G = NIL; Ap = As;
       while (Ap != NIL)
         {
         A1 = FIRST(Ap);
         Bp = Bs;
         while (Bp != NIL)
           {
           B1 = FIRST(Bp);
           if (PDEG(A1) == 0 || PDEG(B1) == 0)
             { G11 = PMON(AFFINT(1),0); G = COMP(G11,G); }
           else
             {
             AFUPGC(M,A1,B1,&G11,&A1,&B1);
             SFIRST(Ap,A1); SFIRST(Bp,B1); G = COMP(G11,G);
             }
           Bp = RED(Bp);
           }
         Ap = RED(Ap);
         }
       G = INV(G);

Step3: /* Basis element from $A^*$. */
       n = LENGTH(As); m = LENGTH(Bs);
       E = NIL; for (i = 1; i <= n; i++) E = COMP(NIL,E);
       F = NIL; for (j = 1; j <= m; j++) F = COMP(NIL,F);
       C = NIL;
       for (i = 1; i <= n; i++)
         {
         ADV(As,&A1,&As);
         if (PDEG(A1) > 0)
           {
           C = COMP(A1,C);

           Ep = E;
           for (h = 1; h <= i - 1; h++) 
             { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); }
           SFIRST(Ep,COMP(1,FIRST(Ep))); Ep = RED(Ep);
           for (h = i + 1; h <= n; h++) 
             { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); }

           Fp = F;
           for (h = 1; h <= m; h++)     
             { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); }
           }
         }

Step4: /* Basis element from $B^*$. */
       for (j = 1; j <= m; j++)
         {
         ADV(Bs,&B1,&Bs);
         if (PDEG(B1) > 0)
           {
           C = COMP(B1,C);

           Ep = E;
           for (h = 1; h <= n; h++)     
             { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); }

           Fp = F;
           for (h = 1; h <= j - 1; h++) 
             { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); }
           SFIRST(Fp,COMP(1,FIRST(Fp))); Fp = RED(Fp);
           for (h = j + 1; h <= m; h++) 
             { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); }
           }
         }

Step5: /* Basis element from $G$. */
       for (i = 1; i <= n; i++) for (j = 1; j <= m; j++)
         {
         ADV(G,&G11,&G);
         if (PDEG(G11) > 0)
           {
           C = COMP(G11,C);

           Ep = E;
           for (h = 1; h <= i - 1; h++) 
             { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); }
           SFIRST(Ep,COMP(1,FIRST(Ep))); Ep = RED(Ep);
           for (h = i + 1; h <= n; h++) 
             { SFIRST(Ep,COMP(0,FIRST(Ep))); Ep = RED(Ep); }

           Fp = F;
           for (h = 1; h <= j - 1; h++) 
             { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); }
           SFIRST(Fp,COMP(1,FIRST(Fp))); Fp = RED(Fp);
           for (h = j + 1; h <= m; h++) 
             { SFIRST(Fp,COMP(0,FIRST(Fp))); Fp = RED(Fp); }
          }
        }

Return: /* Prepare for return. */
       *C_ = C;
       *E_ = E;
       *F_ = F;
       return;
}