Exemplo n.º 1
0
Arquivo: brute.c Projeto: rcls/brute
static uint32_t EXTRACT4 (value4_t v, int index)
{
    switch (index) {
    case 0:
        return FIRST4 (v);
    case 1:
        return FIRST4 (__builtin_ia32_pshufd (v, 0x55));
    case 2:
        return FIRST4 (__builtin_ia32_pshufd (v, 0xAA));
    case 3:
        return FIRST4 (__builtin_ia32_pshufd (v, 0xFF));
    default:
        abort();
    }
}
Exemplo n.º 2
0
void GETRP(Word S1, Word t, Word U, Word *Ms_, Word *Ns_)
{
    Word C0,C1,D,Ms,Ns,R,Sp1,T,a,e0,e1,q,r;

Step1: /* Reduce coefficients mod S1. */
    FIRST4(U,&e1,&C1,&e0,&C0);
    C1 = RPFIP(1,C1);
    C0 = RPFIP(1,C0);
    Sp1 = RPMAIP(1,S1);
    RPQR(1,C1,Sp1,&q,&C1);
    RPQR(1,C0,Sp1,&q,&C0);

Step2: /* Find similar integral polynomial for leading coefficient. */
    IPSRP(1,C1,&a,&C1);
    C0 = RPRNP(1,a,C0);

Step3: /* Multiply C_0 by negated inverse of C_1. */
    IUPRC(S1,C1,&T,&r);
    R = RNRED(1,r);
    R = RNNEG(R);
    R = AFFRN(R);
    T = RPFIP(1,T);
    T = AFCR(T);
    C0 = AFCR(C0);
    D = AFPROD(S1,T,C0);
    Ns = AFPROD(S1,R,D);
    Ms = AFPROD(S1,AFFINT(t),Ns);
    Ms = AFDIF(AFGEN(),Ms);
    goto Return;

Return: /* Prepare for return. */
    *Ms_ = Ms;
    *Ns_ = Ns;
    return;
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
void SPFRPSFT(Word P, Word c, Word k, Word *R_, Word *F_)
{
       Word R,F,Pk1,l,R1,i,j,S,Si,Pi,Sij,Pij,G,g;
       Word H,h,f1,f2,f3,f4,f5,f6,n,n1,n2,L,L1,L2;

Step1: /* Initialize. */
       Pk1 = LELTI(P,k+1);
       l = LENGTH(Pk1);

       R = NIL;
       for (i=1; i<=l; i++) {
	  R1 = NIL;
	  for (j=1; j<=l; j++)
	     R1 = COMP(1,R1);
	  R = COMP(R1,R); }

       F = NIL;
       for (i=1; i<=l; i++)
	  F = COMP(1,F);

       if (l == 0) goto Return;

Step2: /* Update. */
       S = LELTI(c,SIGNPF);
       S = CINV(S);
       for (i=1; i<=k; i++) {
	  ADV(S,&Si,&S);
	  ADV(P,&Pi,&P);
	  while (Si != NIL) {
	     ADV(Si,&Sij,&Si);
	     ADV(Pi,&Pij,&Pi);
	     if (Sij != 0) continue;
	     G = LELTI(Pij,PO_PARENT);
	     while (G != NIL) {
		ADV(G,&g,&G);
		if (FIRST(g) != PO_FAC) continue;
		H = LELTI(THIRD(g),PO_PARENT);
		while (H != NIL) {
		   ADV(H,&h,&H);
		   switch(FIRST(h)) {
                   case PO_LCO:
		      FIRST3(h,&f1,&f2,&f3);
		      if (f2 != 0) break;
		      L = LELTI(f3,PO_LABEL);
		      if (SECOND(L) != k+1) break;
		      n = PLPOS(Pk1,THIRD(L));
		      if (n == 0) FAIL("SPFRPSFT","PO_LCO");
		      SLELTI(F,n,0);               
		      break;
	           case PO_DIS:
		      FIRST4(h,&f1,&f2,&f3,&f4);
		      if (f2 != 0 || f3 != 0) break;
		      L = LELTI(f4,PO_LABEL);
		      if (SECOND(L) != k+1) break;
		      n = PLPOS(Pk1,THIRD(L));
		      if (n == 0) FAIL("SPFRPSFT","PO_DIS");
		      SLELTI(F,n,0);                   
		      break;
                   case PO_RES:
		      FIRST6(h,&f1,&f2,&f3,&f4,&f5,&f6);
		      if (f2 != 0 || f3 != 0 || f5 != 0) break;
		      L1 = LELTI(f4,PO_LABEL);
		      if (SECOND(L1) != k+1) break;
		      L2 = LELTI(f6,PO_LABEL);
		      if (SECOND(L2) != k+1)
			 FAIL("SPFRPSFT","resultant of diff level");
		      n1 = PLPOS(Pk1,THIRD(L1));
		      if (n1 == 0) FAIL("SPFRPSFT","PO_RES: n1");
		      n2 = PLPOS(Pk1,THIRD(L2));
		      if (n2 == 0) FAIL("SPFRPSFT","PO_RES: n2");
		      if (n2 > n1)
			 SLELTI(LELTI(R,n1),n2,0);
		      else
			 FAIL("SPFRPSFT","n2 <= n1");
		      break; } } } } }

Return: /* Prepare for return. */
       *R_ = R;
       *F_ = F;
       return;
}