示例#1
0
文件: p_tan.c 项目: hongyunnchen/pal
/*
 * 0 <= x <= pi/2
 * x = x' + pi/4
 * tan x = tan(x' + pi/4) = (tan x' + 1) / (1 - tan x')
 */
static inline PTYPE __p_tan_pi_2(const PTYPE x)
{
    PTYPE x_, tanx_;
    if (x <= pi_4)
        return __p_tan_pi_4(x);
    x_ = x - pi_4;
    tanx_ = __p_tan_pi_4(x_);
    return (tanx_ + PCONST(1.0)) / (PCONST(1.0) - tanx_);
}
示例#2
0
文件: p_tan.c 项目: hongyunnchen/pal
/*
 * 0 <= x <= pi
 * x = x' + pi/2
 * tan x = tan (x' + pi/2) = -1 / tan x'
 */
static inline PTYPE __p_tan_pi(const PTYPE x)
{
    PTYPE x_;
    if (x <= pi_2)
        return __p_tan_pi_2(x);
    x_ = x - pi_2;
    return PCONST(-1.0) / __p_tan_pi_2(x_);
}
示例#3
0
文件: p_sum.c 项目: hongyunnchen/pal
void PSYM(p_sum)(const PTYPE *a, PTYPE *c, int n)
{
    PTYPE tmp = PCONST(0.0);

    for (; n > 0; n--) {
        tmp += *(a++);
    }
    *c = tmp;
}
示例#4
0
文件: p_tan.c 项目: hongyunnchen/pal
/*
 * 0 <= x <= pi/4
 * tan x / x = 1 + a2 * x^2 + a4 * x^4 + ... + a12 * x^12 + e(x)
 * |e(x)| <= 2 * 10^-8
 */
static inline PTYPE __p_tan_pi_4(const PTYPE x)
{
    const PTYPE  a2 = PCONST(0.3333314036);
    const PTYPE  a4 = PCONST(0.1333923995);
    const PTYPE  a6 = PCONST(0.0533740603);
    const PTYPE  a8 = PCONST(0.0245650893);
    const PTYPE a10 = PCONST(0.0029005250);
    const PTYPE a12 = PCONST(0.0095168091);
    PTYPE x2, tanx_x;
    x2 = x * x;
    tanx_x = PCONST(1.0) + x2 * (a2 + x2 * (a4 + x2 * (a6 + x2 * (a8 + x2 * (a10 + x2 * a12)))));
    return tanx_x * x;
}
示例#5
0
Word RMCONS(Word r, Word J)
{
       Word J1,Jh,Jh1,Jp;

Step1: /* Remove. */
       Jp = NIL; Jh = J;
       while (Jh != NIL)
         {
         ADV(Jh,&J1,&Jh);
         Jh1 = LELTI(J1,PO_POLY);
         if (!PCONST(r,Jh1))
           Jp = COMP(J1,Jp);
         }
       Jp = INV(Jp); goto Return;

Return: /* Prepare for return. */
       return(Jp);
}
示例#6
0
文件: mkconst.c 项目: galaxyeye/bdb
int
main()
{
    int minor = 99999999;
    FILE *f = fopen("VERSION", "r");

    if (f) {
	if (fscanf(f, "%d", &minor) != 1) {
	    minor = 99999999;
	}
	fclose(f);
    }
    printf("/* DO NOT EDIT */\n\n");
    printf("package SQLite;\n\n");
    printf("/**\n");
    printf(" * Container for SQLite constants.\n");
    printf(" */\n\n");
    printf("public final class Constants {\n");
    PCONST(SQLITE_OK);
    PCONST(SQLITE_ERROR);
    PCONST(SQLITE_INTERNAL);
    PCONST(SQLITE_PERM);
    PCONST(SQLITE_ABORT);
    PCONST(SQLITE_BUSY);
    PCONST(SQLITE_LOCKED);
    PCONST(SQLITE_NOMEM);
    PCONST(SQLITE_READONLY);
    PCONST(SQLITE_INTERRUPT);
    PCONST(SQLITE_IOERR);
    PCONST(SQLITE_CORRUPT);
    PCONST(SQLITE_NOTFOUND);
    PCONST(SQLITE_FULL);
    PCONST(SQLITE_CANTOPEN);
    PCONST(SQLITE_PROTOCOL);
    PCONST(SQLITE_EMPTY);
    PCONST(SQLITE_SCHEMA);
    PCONST(SQLITE_TOOBIG);
    PCONST(SQLITE_CONSTRAINT);
    PCONST(SQLITE_MISMATCH);
    PCONST(SQLITE_MISUSE);

#ifndef SQLITE_NOLFS
#define SQLITE_NOLFS (SQLITE_MISUSE + 1)
#endif
    PCONST(SQLITE_NOLFS);

#ifndef SQLITE_AUTH
#define SQLITE_AUTH (SQLITE_NOLFS + 1)
#endif
    PCONST(SQLITE_AUTH);

#ifndef SQLITE_FORMAT
#define SQLITE_FORMAT (SQLITE_AUTH + 1)
#endif
    PCONST(SQLITE_FORMAT);

#ifndef SQLITE_RANGE
#define SQLITE_RANGE (SQLITE_FORMAT + 1)
#endif
    PCONST(SQLITE_RANGE);

#ifndef SQLITE_NOTADB
#define SQLITE_NOTADB (SQLITE_RANGE + 1)
#endif
    PCONST(SQLITE_NOTADB);

#ifndef SQLITE_ROW
#define SQLITE_ROW 100
#endif
    QCONST(SQLITE_ROW);

#ifndef SQLITE_DONE
#define SQLITE_DONE (SQLITE_ROW + 1)
#endif
    QCONST(SQLITE_DONE);

#ifndef SQLITE_INTEGER
#define SQLITE_INTEGER 1
#endif
    QCONST(SQLITE_INTEGER);

#ifndef SQLITE_FLOAT
#define SQLITE_FLOAT 2
#endif
    QCONST(SQLITE_FLOAT);

#ifndef SQLITE_BLOB
#define SQLITE_BLOB 4
#endif
    QCONST(SQLITE_BLOB);

#ifndef SQLITE_NULL
#define SQLITE_NULL 5
#endif
    QCONST(SQLITE_NULL);

#ifndef SQLITE3_TEXT
#define SQLITE3_TEXT 3
#endif
    QCONST(SQLITE3_TEXT);

#ifndef SQLITE_NUMERIC
#define SQLITE_NUMERIC (-1)
#endif
    QCONST(SQLITE_NUMERIC);

#ifndef SQLITE_TEXT
#ifdef HAVE_SQLITE3
#define SQLITE_TEXT 3
#else
#define SQLITE_TEXT (-2)
#endif
#endif
    QCONST(SQLITE_TEXT);

#ifndef SQLITE2_TEXT
#define SQLITE2_TEXT (-2)
#endif
    QCONST(SQLITE2_TEXT);

#ifndef SQLITE_ARGS
#define SQLITE_ARGS (-3)
#endif
    QCONST(SQLITE_ARGS);

#ifndef SQLITE_COPY
#define SQLITE_COPY 0
#endif
    QCONST(SQLITE_COPY);

#ifndef SQLITE_CREATE_INDEX
#define SQLITE_CREATE_INDEX 1
#endif
    QCONST(SQLITE_CREATE_INDEX);

#ifndef SQLITE_CREATE_TABLE
#define SQLITE_CREATE_TABLE 2
#endif
    QCONST(SQLITE_CREATE_TABLE);

#ifndef SQLITE_CREATE_TEMP_INDEX
#define SQLITE_CREATE_TEMP_INDEX 3
#endif
    QCONST(SQLITE_CREATE_TEMP_INDEX);

#ifndef SQLITE_CREATE_TEMP_TABLE
#define SQLITE_CREATE_TEMP_TABLE 4
#endif
    QCONST(SQLITE_CREATE_TEMP_TABLE);

#ifndef SQLITE_CREATE_TEMP_TRIGGER
#define SQLITE_CREATE_TEMP_TRIGGER 5
#endif
    QCONST(SQLITE_CREATE_TEMP_TRIGGER);

#ifndef SQLITE_CREATE_TEMP_VIEW
#define SQLITE_CREATE_TEMP_VIEW 6
#endif
    QCONST(SQLITE_CREATE_TEMP_VIEW);

#ifndef SQLITE_CREATE_TRIGGER
#define SQLITE_CREATE_TRIGGER 7
#endif
    QCONST(SQLITE_CREATE_TRIGGER);

#ifndef SQLITE_CREATE_VIEW
#define SQLITE_CREATE_VIEW 8
#endif
    QCONST(SQLITE_CREATE_VIEW);

#ifndef SQLITE_DELETE
#define SQLITE_DELETE 9
#endif
    QCONST(SQLITE_DELETE);

#ifndef SQLITE_DROP_INDEX
#define SQLITE_DROP_INDEX 10
#endif
    QCONST(SQLITE_DROP_INDEX);

#ifndef SQLITE_DROP_TABLE
#define SQLITE_DROP_TABLE 11
#endif
    QCONST(SQLITE_DROP_TABLE);

#ifndef SQLITE_DROP_TEMP_INDEX
#define SQLITE_DROP_TEMP_INDEX 12
#endif
    QCONST(SQLITE_DROP_TEMP_INDEX);

#ifndef SQLITE_DROP_TEMP_TABLE
#define SQLITE_DROP_TEMP_TABLE 13
#endif
    QCONST(SQLITE_DROP_TEMP_TABLE);

#ifndef SQLITE_DROP_TEMP_TRIGGER
#define SQLITE_DROP_TEMP_TRIGGER 14
#endif
    QCONST(SQLITE_DROP_TEMP_TRIGGER);

#ifndef SQLITE_DROP_TEMP_VIEW
#define SQLITE_DROP_TEMP_VIEW 15
#endif
    QCONST(SQLITE_DROP_TEMP_VIEW);

#ifndef SQLITE_DROP_TRIGGER
#define SQLITE_DROP_TRIGGER 16
#endif
    QCONST(SQLITE_DROP_TRIGGER);

#ifndef SQLITE_DROP_VIEW
#define SQLITE_DROP_VIEW 17
#endif
    QCONST(SQLITE_DROP_VIEW);

#ifndef SQLITE_INSERT
#define SQLITE_INSERT 18
#endif
    QCONST(SQLITE_INSERT);

#ifndef SQLITE_PRAGMA
#define SQLITE_PRAGMA 19
#endif
    QCONST(SQLITE_PRAGMA);

#ifndef SQLITE_READ
#define SQLITE_READ 20
#endif
    QCONST(SQLITE_READ);

#ifndef SQLITE_SELECT
#define SQLITE_SELECT 21
#endif
    QCONST(SQLITE_SELECT);

#ifndef SQLITE_TRANSACTION
#define SQLITE_TRANSACTION 22
#endif
    QCONST(SQLITE_TRANSACTION);

#ifndef SQLITE_UPDATE
#define SQLITE_UPDATE 23
#endif
    QCONST(SQLITE_UPDATE);

#ifndef SQLITE_ATTACH
#define SQLITE_ATTACH 24
#endif
    QCONST(SQLITE_ATTACH);

#ifndef SQLITE_DETACH
#define SQLITE_DETACH 25
#endif
    QCONST(SQLITE_DETACH);

#ifndef SQLITE_DENY
#define SQLITE_DENY 1
#endif
    QCONST(SQLITE_DENY);

#ifndef SQLITE_IGNORE
#define SQLITE_IGNORE 2
#endif
    QCONST(SQLITE_IGNORE);

#ifndef SQLITE_OPEN_NOMUTEX
#define SQLITE_OPEN_NOMUTEX 0
#endif
    QCONST(SQLITE_OPEN_NOMUTEX);

#ifndef SQLITE_OPEN_FULLMUTEX
#define SQLITE_OPEN_FULLMUTEX 0
#endif
    QCONST(SQLITE_OPEN_FULLMUTEX);

#ifndef SQLITE_OPEN_READONLY
#define SQLITE_OPEN_READONLY 0
#endif
    QCONST(SQLITE_OPEN_READONLY);

#ifndef SQLITE_OPEN_READWRITE
#define SQLITE_OPEN_READWRITE 0
#endif
    QCONST(SQLITE_OPEN_READWRITE);

#ifndef SQLITE_OPEN_CREATE
#define SQLITE_OPEN_CREATE 0
#endif
    QCONST(SQLITE_OPEN_CREATE);

#ifndef SQLITE_STATUS_MEMORY_USED
#define SQLITE_STATUS_MEMORY_USED 0
#endif
    QCONST(SQLITE_STATUS_MEMORY_USED);

#ifndef SQLITE_STATUS_MALLOC_SIZE
#define SQLITE_STATUS_MALLOC_SIZE 0
#endif
    QCONST(SQLITE_STATUS_MALLOC_SIZE);

#ifndef SQLITE_STATUS_PAGECACHE_USED
#define SQLITE_STATUS_PAGECACHE_USED 0
#endif
    QCONST(SQLITE_STATUS_PAGECACHE_USED);

#ifndef SQLITE_STATUS_PAGECACHE_OVERFLOW
#define SQLITE_STATUS_PAGECACHE_OVERFLOW 0
#endif
    QCONST(SQLITE_STATUS_PAGECACHE_OVERFLOW);

#ifndef SQLITE_STATUS_PAGECACHE_SIZE
#define SQLITE_STATUS_PAGECACHE_SIZE 0
#endif
    QCONST(SQLITE_STATUS_PAGECACHE_SIZE);

#ifndef SQLITE_STATUS_SCRATCH_USED
#define SQLITE_STATUS_SCRATCH_USED 0
#endif
    QCONST(SQLITE_STATUS_SCRATCH_USED);

#ifndef SQLITE_STATUS_SCRATCH_OVERFLOW
#define SQLITE_STATUS_SCRATCH_OVERFLOW 0
#endif
    QCONST(SQLITE_STATUS_SCRATCH_OVERFLOW);

#ifndef SQLITE_STATUS_SCRATCH_SIZE
#define SQLITE_STATUS_SCRATCH_SIZE 0
#endif
    QCONST(SQLITE_STATUS_SCRATCH_SIZE);

#ifndef SQLITE_STATUS_PARSER_STACK
#define SQLITE_STATUS_PARSER_STACK 0
#endif
    QCONST(SQLITE_STATUS_PARSER_STACK);

#ifndef SQLITE_DBSTATUS_LOOKASIDE_USED
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
#endif
    QCONST(SQLITE_DBSTATUS_LOOKASIDE_USED);

#ifndef SQLITE_DBSTATUS_CACHE_USED
#define SQLITE_DBSTATUS_CACHE_USED 0
#endif
    QCONST(SQLITE_DBSTATUS_CACHE_USED);

#ifndef SQLITE_STMTSTATUS_FULLSCAN_STEP
#define SQLITE_STMTSTATUS_FULLSCAN_STEP 0
#endif
    QCONST(SQLITE_STMTSTATUS_FULLSCAN_STEP);

#ifndef SQLITE_STMTSTATUS_SORT
#define SQLITE_STMTSTATUS_SORT 0
#endif
    QCONST(SQLITE_STMTSTATUS_SORT);

#ifndef SQLITE_STMTSTATUS_AUTOINDEX
#define SQLITE_STMTSTATUS_AUTOINDEX 0
#endif
    QCONST(SQLITE_STMTSTATUS_AUTOINDEX);

    printf("    public static final int drv_minor = %d;\n",
	   minor);

    printf("}\n");
    return 0;
}
示例#7
0
Word QepcadCls::ACCCVBC(Word k, Word c, Word M, Word B1, Word b, Word* B1h)
{
  Word d, nnf, dV, IV, cp, i, I_i, d_i, c_i, L, Q, Qb, Qbs, F, Fp, a;

Step1: /* Initialization **********************************************/
  a = NIL; /* this is the pseudo-sample point we're building up *******/
  F = NIL; /* Useless now, could be usefull later. ********************/
  d = 0;   /* dimension of cell c_i. **********************************/
  nnf = 0; /* number of variables not fixed. **************************/
  dV = CINV(RED(PDEGV(k+1,B1))); /* vector of degrees of first k ******
				    variables of B1. ******************/
  IV = LELTI(c,INDX);            /* vector of indices of cell c. ******/
  c_i = GVPC;


Step2: /* Loop over each level from 1 to k ****************************/
  for(i = 1; i <= k; i++) {
    I_i = LELTI(IV,i);
    d_i = LELTI(dV,i);
    c_i = LELTI(LELTI(c_i,CHILD),I_i);
    
Step3: /* c_i is a section over a 0-dimensional cell ******************/
    if ((I_i % 2 == 0) && d == 0) {
      a = SUFFIX(a,LELTI(b,i));
      continue; }
    
Step4: /* c_i is a section over a cell of dimension greater than zero */

    if ((I_i % 2 == 0) && d > 0) {
      for(L=SECTIONPOLS(i,c_i,GVPF),Qbs=1,Fp=NIL; L != NIL; L=RED(L)) {
	Q = AFPFIP(i,LELTI(FIRST(L),PO_POLY));
	Qb = SPECIALSUBS(i,M,a,Q); /* Qb can't be zero, by definition of
				      SECTIONPOLS */
	Qbs = AFPEMV(nnf + 1,M,Qb,LELTI(b,i));
	if (Qbs == 0) {
	  a = SUFFIX(a,LELTI(b,i));
	  break; }
	else
	  Fp = COMP(Qb,Fp); }
      if (L == NIL) {
	F = CCONC(F,Fp);
	nnf++;
	a = SUFFIX(a,NIL);
      } }
    
Step5: /* c_i is a sector *********************************************/
    if (I_i % 2 == 1) {
      d++;
      nnf++;
      a = SUFFIX(a,NIL); }
  }


/*Step6: a is the psuedo-sample point, check that B1 is univariate at a. */
  bool uniq = true;
  /*
    Changed to below 8/13/08
    Word B1b = SPECIALSUBS(k+1,M,a,B1);
  */
  Word B1b = SPECIALSUBS(k+1,M,a,AFPFIP(k+1,B1));
  for(Word B1s = B1b; uniq && B1s != 0; B1s = PRED(B1s))
    uniq = PCONST(nnf,PLDCF(B1s));
  if (B1h != 0) *B1h = B1b;

  return uniq ? TRUE : UNDET;
}
示例#8
0
Word QepcadCls::PROJMC(Word r, Word A)
{
       Word A1,A2,Ap,Ap1,Ap2,App,D,L,Lh,P,R,W,i,t;

Step1: /* Obtain coefficients. */
       P = NIL;
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue;
	 Ap1 = LELTI(A1,PO_POLY); 
	 L = PLDCF(Ap1); 
	 Lh = NIL;
	 t = 0;
	 if (!PCONST(r - 1,L)) {
	   W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,0,A1)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); 
	   Lh = COMP(L,Lh); 
	   t = 1; }
	 i = 0;
	 while (t) {
	   Ap1 = PRED(Ap1); i++;  L = PLDCF(Ap1);
	   t = 0;
	   if (Ap1 != 0) 
	     if (!PCONST(r - 1,L)) 
	       if (!IPFZT(r - 1,Lh)) {
		 W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,i,A1)),PO_OTHER,PO_KEEP); 
		 P = COMP(W,P); 
		 Lh = COMP(L,Lh); 
		 t = 1; } } }

Step2: /* Obtain discriminants. */
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue;        
	 Ap1 = LELTI(A1,PO_POLY);
	 if (PDEG(Ap1) >= 2) {
	   D = IPDSCRQE(r,Ap1);
	   W = MPOLY(D,NIL,LIST1(LIST4(PO_DIS,0,0,A1)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }

Step3: /* Obtain resultants. */
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 Ap1 = LELTI(A1,PO_POLY);
	 App = Ap;
	 while (App != NIL) {
	   ADV(App,&A2,&App);
	   if (PCEQC && 
	       LELTI(A1,PO_TYPE) != PO_ECON && 
	       LELTI(A2,PO_TYPE) != PO_ECON) continue;
	   Ap2 = LELTI(A2,PO_POLY);
	   R = IPRESQE(r,Ap1,Ap2);
	   W = MPOLY(R,NIL,LIST1(LIST6(PO_RES,0,0,A1,0,A2)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }

Step4: /* Finish. */
       P = INV(P);
       goto Return;

Return: /* Prepare for return. */
       return(P);
}
示例#9
0
Word QepcadCls::PROJHO(Word r, Word A)
{
       Word A1,A2,Ap,Ap1,Ap2,App,D,L,L1,P,Ps,R,R1,R11,R2,Rp,Rp11,Rpp,Rs,Rs1,
            S1,T,W,ap1,b,d,i,k,w;

Step1: /* $r = 2$. */
       if (r > 2) goto Step2;
       P = NIL; Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue;
	 Ap1 = LELTI(A1,PO_POLY);
	 W = MPOLY(PLDCF(Ap1),NIL,LIST1(LIST3(PO_LCO,0,A1)),PO_OTHER,PO_KEEP);
	 P = COMP(W,P);
	 if (PDEG(Ap1) >= 2) {
	   D = IPDSCRQE(2,Ap1);
	   W = MPOLY(D,NIL,LIST1(LIST4(PO_DIS,0,0,A1)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 Ap1 = LELTI(A1,PO_POLY);
	 App = Ap;
	 while (App != NIL) {
	   ADV(App,&A2,&App);
	   if (PCEQC && 
	       LELTI(A1,PO_TYPE) != PO_ECON && 
	       LELTI(A2,PO_TYPE) != PO_ECON) continue;
	   Ap2 = LELTI(A2,PO_POLY);
	   T = IPRESQE(2,Ap1,Ap2);
	   W = MPOLY(T,NIL,LIST1(LIST6(PO_RES,0,0,A1,0,A2)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }
       P = INV(P);
       goto Return;

Step2: /* Determine number of reducta needed for each $A_i$. */
       Ap = A; R = NIL;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 Ap1 = LELTI(A1,PO_POLY);
	 R1 = LIST1(Ap1);
	 ap1 = PLDCF(Ap1);
	 S1 = LIST1(ap1);
	 b = PCONST(r - 1,ap1);
	 d = 0;
	 Ap1 = PRED(Ap1);
	 while (!b && !d && Ap1 != 0) {
	   R1 = COMP(Ap1,R1);
	   ap1 = PLDCF(Ap1);
	   b = PCONST(r - 1,ap1);
	   if (!b) {
	     S1 = COMP(ap1,S1);
	     d = IPFZT(r - 1,S1); }
	   Ap1 = PRED(Ap1); }
	 R1 = INV(R1);
	 R = COMP(R1,R); }
       R = INV(R);

Step3: /* Process each $R_i$. */
       P = NIL; Rp = R;  Ap = A;
       while (Rp != NIL) {
	 ADV(Rp,&R1,&Rp); ADV(Ap,&A1,&Ap);
	 if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue;
	 S1 = NIL;
	 i = 0;
	 do {
	   ADV(R1,&R11,&R1);
	   W = MPOLY(PLDCF(R11),NIL,LIST1(LIST3(PO_LCO,i,A1)),
		     PO_OTHER,PO_KEEP);
	   P = COMP(W,P);
	   if (PDEG(R11) >= 2) {
	     Rp11 = IPDMV(r,R11);
	     L = IPPSCT(r,R11,Rp11,S1);
	     k = 0;
	     while (L != NIL) {
	       ADV(L,&L1,&L);
	       W = MPOLY(L1,NIL,LIST1(LIST4(PO_DIS,k,i,A1)),PO_OTHER,PO_KEEP);
	       P = COMP(W,P);
	       k = k + 1; }
	     S1 = COMP(PLDCF(R11),S1); }
	   i++; }
	 while (R1 != NIL); }

Step4: /* Process pairs $R_i$, $R_j$. */
       Rp = R; Ap = A;
       while (Rp != NIL) {
	 ADV(Rp,&R1,&Rp); ADV(Ap,&A1,&Ap);
	 Rpp = Rp; App = Ap;
	 while (Rpp != NIL) {
	   ADV(Rpp,&R2,&Rpp); ADV(App,&A2,&App);
	   if (PCEQC && 
	       LELTI(A1,PO_TYPE) != PO_ECON && 
	       LELTI(A2,PO_TYPE) != PO_ECON) continue;
	   if (LENGTH(R1) > LENGTH(R2)) {
	     Ps = FIRST(R1);
	     Rs = R2;
	     w = 1; }
	   else {
	     Ps = FIRST(R2);
	     Rs = R1;
	     w = 0; }
	   S1 = NIL;
	   i = 0;
	   while (Rs != NIL) {
	     ADV(Rs,&Rs1,&Rs);
	     if (PDEG(Rs1) >= 1) {
	       if (w == 1) L = IPPSCT(r,Ps,Rs1,S1);
	       else        L = IPPSCT(r,Rs1,Ps,S1);
	       k = 0;
	       while (L != NIL) {
		 ADV(L,&L1,&L);
		 if (w == 1)
		   W = MPOLY(L1,NIL,LIST1(LIST6(PO_RES,k,0,A1,i,A2)),
			     PO_OTHER,PO_KEEP);
		 else 
		   W = MPOLY(L1,NIL,LIST1(LIST6(PO_RES,k,i,A1,0,A2)),
			     PO_OTHER,PO_KEEP); 
		 P = COMP(W,P);
		 k++; }                    
	       S1 = COMP(PLDCF(Rs1),S1); }
	     i++; } } }

Step5: /* Finish. */
       P = INV(P);

Return: /* Prepare for return. */
       return(P);
}
示例#10
0
Word QepcadCls::PROJMCmod(Word r, Word A)
{
       Word A1,A2,Ap,Ap1,Ap2,App,D,L,Lh,P,R,W,i,t,Q,j,S,Sp;

Step1: /* Obtain coefficients. */
       P = NIL;
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 Ap1 = LELTI(A1,PO_POLY); 

	 /* Deal with projection points! */
	 if (LELTI(A1,PO_TYPE) == PO_POINT) {
	   W = MPOLY(RED(Ap1),NIL,LIST1(LIST2(PT_PRJ,A1)),PO_POINT,PO_KEEP);
	   P = COMP(W,P);
	   continue;
	 }

	 /* Handle the leading coefficient! */
	 L = PLDCF(Ap1); 
	 Lh = NIL;
	 t = 0;
	 /* if (!PCONST(r - 1,L)) {*/
	 if (!VERIFYCONSTSIGN(r-1,IPIP(r-1,ISIGNF(PLBCF(r-1,L)),L),1,GVNA.W)) {
	   W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,0,A1)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); 
	   Lh = COMP(L,Lh); 
	   t = 1; }

	 /* If r = 2 then we know the leading coefficient is always enough! */
	 if (r == 2)
	   t = 0;

	 /* If x_{r-1} is a bound variable, and the quantifier is
	    either F or G, then we know we'll only be lifting over
	    full dimensional cells so we don't have to add more 
	    coefficients! */
	 if (t) {
	   j = r - GVNFV - 1;
	   if (j > 0) {
	     Q = LELTI(GVQ,j); /* Quantifier for x_{r-1} */
	     if (Q == FULLDE || Q == FULLDA)
	       t = 0; } }


	 /* If PCMZERROR is set to true, then we only need leading coefficients
            when projecting polynomials of level k+1 or lower. */
	 if (t && PCMZERROR && r <= GVNFV + 1)
	   t = 0;

	 /* If it can be determined that the system of coefficients is
	    inconsistent ... we can stop with just the leading coeff! */
	 if (t) {
	   j = CLOCK();
	   S = COEFSYS(r,Ap1);
  	   if (S == 1 || (Sp = SIMPLIFYSYSLIST(r-1,S,GVNA == NIL ? TRUE : GVNA.W)) == 1)
  	     t = 0; 
 	   else {
 	     QepcadCls Q; Word G;
 	     for(t = 0; t == 0 && Sp != NIL; Sp = RED(Sp))
 	       if ((G = SYSSOLVECAD(r-1,FIRST(Sp),GVNA == NIL ? TRUE : GVNA.W,GVVL,Q)) != NIL) 
	       {
		 /* If there are finitely many solutions, add those points as projection
		    points. */
		 if (ISLIST(G)) {
		   for(Word Lp = G; Lp != NIL; Lp = RED(Lp)) {
		     /* ADD POINTS to PROJECTION POLS! */
		     Word X = NIL; /* List of all sample points up to and inluding FIRST(G) */
		     Word c = Q.GVPC;
		     for(Word I = LELTI(FIRST(Lp),INDX); I != NIL; I = RED(I))
		     {
		       c = LELTI(LELTI(c,CHILD),FIRST(I));
		       Word s = LELTI(c,SAMPLE);
		       X = COMP(ISPRIMIT(s) ? (LENGTH(s) > 3 ? FOURTH(s) : s) : s,X);
		     }
		     W = MPOLY(X,NIL,LIST1(LIST2(PT_NUL,A1)),PO_POINT,PO_KEEP);
		     P = COMP(W,P);
		   }
		 }
		 else
		   t = 1; /* Instead of adding all the other coeffs, better to add system! */
	       }
 	   }	   

	   j = CLOCK() - j;
	   if (PCVERBOSE) {
	     SWRITE("Coef consistency check took "); IWRITE(j); SWRITE("ms\n");
	     if (!t)
	       SWRITE("Found system inconsistent for ");
	     else
	       SWRITE("Unable to determine consistency for ");
	     IPDWRITE(r,Ap1,GVVL);
	     SWRITE("\n");
	   }
	 }


	 /* Handle the rest of the coefficients as needed. */
	 i = 0;
	 while (t) {
	   Ap1 = PRED(Ap1); i++;  L = PLDCF(Ap1);
	   t = 0;
	   if (Ap1 != 0) 
	     if (!PCONST(r - 1,L)) 
	       if (!IPFZT(r - 1,Lh)) {
		 W = MPOLY(L,NIL,LIST1(LIST3(PO_LCO,i,A1)),PO_OTHER,PO_KEEP); 
		 P = COMP(W,P); 
		 Lh = COMP(L,Lh); 
		 t = 1; } } 
	 }

Step2: /* Obtain discriminants. */
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 if (LELTI(A1,PO_TYPE) == PO_POINT) continue;
	 if (PCEQC && LELTI(A1,PO_TYPE) != PO_ECON) continue;        
	 Ap1 = LELTI(A1,PO_POLY);
	 if (PDEG(Ap1) >= 2) {
	   D = IPDSCRQE(r,Ap1);
	   W = MPOLY(D,NIL,LIST1(LIST4(PO_DIS,0,0,A1)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }

Step3: /* Obtain resultants. */
       Ap = A;
       while (Ap != NIL) {
	 ADV(Ap,&A1,&Ap);
	 if (LELTI(A1,PO_TYPE) == PO_POINT) continue;
	 Ap1 = LELTI(A1,PO_POLY);
	 App = Ap;
	 while (App != NIL) {
	   ADV(App,&A2,&App);
	   if (LELTI(A2,PO_TYPE) == PO_POINT) continue;
	   if (PCEQC && 
	       LELTI(A1,PO_TYPE) != PO_ECON && 
	       LELTI(A2,PO_TYPE) != PO_ECON) continue;
	   Ap2 = LELTI(A2,PO_POLY);
	   R = IPRESQE(r,Ap1,Ap2);
	   W = MPOLY(R,NIL,LIST1(LIST6(PO_RES,0,0,A1,0,A2)),PO_OTHER,PO_KEEP);
	   P = COMP(W,P); } }

Step4: /* Finish. */
       P = INV(P);
       goto Return;

Return: /* Prepare for return. */
       return(P);
}
示例#11
0
文件: p_tan.c 项目: hongyunnchen/pal
#include <pal.h>

static const PTYPE pi_4 = PCONST(M_PI) / PCONST(4.0);
static const PTYPE pi_2 = PCONST(M_PI) / PCONST(2.0);
static const PTYPE pi =   PCONST(M_PI);

/*
 * 0 <= x <= pi/4
 * tan x / x = 1 + a2 * x^2 + a4 * x^4 + ... + a12 * x^12 + e(x)
 * |e(x)| <= 2 * 10^-8
 */
static inline PTYPE __p_tan_pi_4(const PTYPE x)
{
    const PTYPE  a2 = PCONST(0.3333314036);
    const PTYPE  a4 = PCONST(0.1333923995);
    const PTYPE  a6 = PCONST(0.0533740603);
    const PTYPE  a8 = PCONST(0.0245650893);
    const PTYPE a10 = PCONST(0.0029005250);
    const PTYPE a12 = PCONST(0.0095168091);
    PTYPE x2, tanx_x;
    x2 = x * x;
    tanx_x = PCONST(1.0) + x2 * (a2 + x2 * (a4 + x2 * (a6 + x2 * (a8 + x2 * (a10 + x2 * a12)))));
    return tanx_x * x;
}

/*
 * 0 <= x <= pi/2
 * x = x' + pi/4
 * tan x = tan(x' + pi/4) = (tan x' + 1) / (1 - tan x')
 */
static inline PTYPE __p_tan_pi_2(const PTYPE x)