rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
if ( cause & 0x02 ) CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_1 );
void mips_vector_isr_handlers( void ){ unsigned int sr; unsigned int cause; int bit; unsigned int pf_icr; mips_get_sr( sr ); mips_get_cause( cause ); cause &= (sr & SR_IMASK); cause >>= CAUSE_IPSHIFT; if ( cause & 0x04 ) /* IP[0] ==> INT0 == TIMER1 */ CALL_ISR( MONGOOSEV_IRQ_TIMER1 ); if ( cause & 0x08 ) /* IP[1] ==> INT1 == TIMER2*/ CALL_ISR( MONGOOSEV_IRQ_TIMER2 ); if ( cause & 0x10 ) /* IP[2] ==> INT2 */ CALL_ISR( MONGOOSEV_IRQ_INT2 ); if ( cause & 0x20 ) /* IP[3] ==> INT4 */ CALL_ISR( MONGOOSEV_IRQ_INT4 ); if ( cause & 0x40 ) { /* IP[4] ==> INT5 */ pf_icr = MONGOOSEV_READ( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_CAUSE_REGISTER ); /* XXX if !pf_icr */ for ( bit=0 ; bit <= 31 ; bit++, pf_icr >>= 1 ) { if ( pf_icr & 1 ) CALL_ISR( MONGOOSEV_IRQ_PERIPHERAL_BASE + bit ); } } if ( cause & 0x02 ) /* SW[0] */ CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_1 ); if ( cause & 0x01 ) /* IP[1] */ CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_2 );}
if ( cause & 0x01 ) CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_2 );
mips_get_sr( sr ); if( cshifted & 0x3 ) { sr |= (SR_IBIT1 | SR_IBIT1); cause &= ~(SR_IBIT1 | SR_IBIT1); mips_set_cause(cause); mips_set_sr(sr); if ( cshifted & 0x01 ) { CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_1, frame ); } if ( cshifted & 0x02 ) { CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_2, frame ); } } sr |= cause; mips_set_sr( sr );
void mips_vector_isr_handlers( void ){ unsigned int sr; unsigned int cause; int bit; unsigned int pf_icr; mips_get_sr( sr ); mips_get_cause( cause ); cause &= (sr & SR_IMASK); cause >>= CAUSE_IPSHIFT; if ( cause & 0x04 ) /* IP[0] ==> INT0 == TIMER1 */ CALL_ISR( MONGOOSEV_IRQ_TIMER1 ); if ( cause & 0x08 ) /* IP[1] ==> INT1 == TIMER2*/ CALL_ISR( MONGOOSEV_IRQ_TIMER2 ); if ( cause & 0x10 ) /* IP[2] ==> INT2 */ CALL_ISR( MONGOOSEV_IRQ_INT2 ); if ( cause & 0x20 ) /* IP[3] ==> INT4 */ CALL_ISR( MONGOOSEV_IRQ_INT4 ); if ( cause & 0x40 ) { /* IP[4] ==> INT5 */ pf_icr = MONGOOSEV_READ( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_CAUSE_REGISTER ); /* XXX if !pf_icr */ for ( bit=0 ; bit <= 31 ; bit++, pf_icr >>= 1 ) { if ( pf_icr & 1 ) CALL_ISR( MONGOOSEV_IRQ_PERIPHERAL_BASE + bit ); } } if ( cause & 0x02 ) /* SW[0] */ CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_1 ); if ( cause & 0x01 ) /* IP[1] */ CALL_ISR( MONGOOSEV_IRQ_SOFTWARE_2 );}
unsigned32 file_size = 0; unsigned32 buf_size = 0;
uint32_t file_size = 0; uint32_t buf_size = 0;
void fileio_write_file(void){ char fname[1024]; char tmp_str[32]; unsigned32 file_size = 0; unsigned32 buf_size = 0; size_t curr_pos,bytes_to_copy; int fd = -1; ssize_t n; rtems_interval start_tick,curr_tick,ticks_per_sec; char *bufptr = NULL; boolean failed = FALSE; static const char write_test_string[] = "The quick brown fox jumps over the lazy dog\n"; static const char write_block_string[] = "\n----- end of write buffer ------\n"; printf(" =========================\n"); printf(" WRITE FILE ... \n"); printf(" =========================\n"); fileio_print_free_heap(); /* * get number of ticks per second */ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec); /* * get path to file to write */ if (!failed) { printf("Enter path/filename ==>"); fgets(fname,sizeof(fname)-1,stdin); while (fname[strlen(fname)-1] == '\n') { fname[strlen(fname)-1] = '\0'; } if (0 == strlen(fname)) { printf("*** no filename entered, aborted\n"); failed = TRUE; } } /* * get total file size to write */ if (!failed) { printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" "Enter filesize to write ==>"); fgets(tmp_str,sizeof(tmp_str)-1,stdin); failed = fileio_str2size(tmp_str,&file_size); if (failed) { printf("*** illegal file size, aborted\n"); } } /* * get block size to write */ if (!failed) { printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n" "Enter block size to use for write calls ==>"); fgets(tmp_str,sizeof(tmp_str)-1,stdin); failed = fileio_str2size(tmp_str,&buf_size); if (failed) { printf("*** illegal block size, aborted\n"); } } /* * allocate buffer */ if (!failed) { printf("... allocating %lu bytes of buffer for write data\n", (unsigned long)buf_size); bufptr = malloc(buf_size+1); /* extra space for terminating NUL char */ if (bufptr == NULL) { printf("*** malloc failed, aborted\n"); failed = TRUE; } } /* * fill buffer with test pattern */ if (!failed) { printf("... filling buffer with write data\n"); curr_pos = 0; /* * fill buffer with test string */ while (curr_pos < buf_size) { bytes_to_copy = MIN(buf_size-curr_pos, sizeof(write_test_string)-1); memcpy(bufptr+curr_pos,write_test_string,bytes_to_copy); curr_pos += bytes_to_copy; } /* * put "end" mark at end of buffer */ bytes_to_copy = sizeof(write_block_string)-1; if (buf_size >= bytes_to_copy) { memcpy(bufptr+buf_size-bytes_to_copy, write_block_string, bytes_to_copy); } } /* * create file */ if (!failed) { printf("... creating file \"%s\"\n",fname); fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE); if (fd < 0) { printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno)); failed = TRUE; } } /* * write file */ if (!failed) { printf("... writing to file\n"); rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick); curr_pos = 0; do { bytes_to_copy = buf_size; do { n = write(fd, bufptr + (buf_size-bytes_to_copy), MIN(bytes_to_copy,file_size-curr_pos)); if (n > 0) { bytes_to_copy -= n; curr_pos += n; } } while ((bytes_to_copy > 0) && (n > 0)); } while ((file_size > curr_pos) && (n > 0)); rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick); if (n < 0) { failed = TRUE; printf("*** file write failed, " "%lu bytes written, " "errno = %d(%s)\n", (unsigned long)curr_pos,errno,strerror(errno)); } else { printf("time elapsed for write: %g seconds\n", ((double)curr_tick-start_tick)/ticks_per_sec); printf("write data rate: %g KBytes/second\n", (((double)file_size) / 1024.0 / (((double)curr_tick-start_tick)/ticks_per_sec))); } } if (fd >= 0) { printf("... closing file\n"); close(fd); } if (bufptr != NULL) { printf("... deallocating buffer\n"); free(bufptr); bufptr = NULL; } printf("\n ******** End of file write\n"); fileio_print_free_heap();}
long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2;
gpmem_t av = avma; GEN theta, nf, rel, aux, H, Y, M, A, suni, sunitrel, futu, fu, tu, w, k, T; GEN prod, S1, S2; GEN res = cgetg(3,t_VEC), relpol = (GEN)ext[1], rnfeq = (GEN)ext[2]; long L, i, drel;
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1)))
if (typ(ext)!=t_VEC || lg(ext)!=4 || typ(relpol)!=t_POL) err(typeer,"rnfisnorm"); if (typ(rnfeq) == t_VEC)
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res;
if (lg(rnfeq) != 4) err(typeer, "rnfisnorm"); k = (GEN)rnfeq[3]; } else { if (typ(rnfeq) != t_INT) err(typeer, "rnfisnorm"); k = rnfeq;
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
bnf = checkbnf(bnf); nf = checknf(bnf); T = (GEN)nf[1]; if (typ(x) != t_POL) x = basistoalg(nf,x); if (gvar(x) != varn(T)) err(consister, "rnfisnorm"); drel = degpol(relpol); if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && odd(drel))) { res[1] = (long)x; res[2] = un; return gerepilecopy(av, res); }
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1)))
rel = checkbnf((GEN)ext[3]); fu = check_units(rel,"rnfisnorm"); prod = gun; S1 = S2 = cgetg(1,t_VEC); if (!gcmp1(gmael3(rel,8,1,1)))
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2);
GEN gen = gmael3(rel,8,1,3); GEN cyc = gmael3(rel,8,1,2), dext = stoi(drel); for(i=1;i<lg(gen);i++) { if (gcmp1(ggcd((GEN)cyc[i], dext))) break; fa_pr_append(nf,rel,gmael3(gen,i,1,1),&prod,&S1,&S2); }
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++)
byteptr d = diffptr; long p = 0; if (maxprime() < flag) err(primer1); for(;;)
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p));
NEXT_PRIME_VIADIFF(p, d); if (p > flag) break; pr_append(nf,rel,stoi(p),&prod,&S1,&S2);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
{ listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); }
fa_pr_append(nf,rel,stoi(-flag),&prod,&S1,&S2);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2);
GEN Ndiscrel=divii((GEN)checknf(rel)[3], gpowgs((GEN)nf[3], drel)); fa_pr_append(nf,rel,absi(Ndiscrel), &prod,&S1,&S2);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); }
fa_pr_append(nf,rel,idealnorm(nf,x), &prod,&S1,&S2);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2);
w = gmael3(rel,8,4,1); tu = gmael3(rel,8,4,2); futu = concatsp(fu, tu); suni = bnfsunit(bnf,S1,PREC); sunitrel = (GEN)bnfsunit(rel,S2,PREC)[1]; if (lg(sunitrel)>1) sunitrel = lift(basistoalg(rel,sunitrel)); sunitrel = concatsp(futu, sunitrel);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1)
A = lift(bnfissunit(bnf,suni,x)); L = lg(sunitrel); M = cgetg(L+1,t_MAT); theta = get_theta_abstorel(T, relpol, k); for (i=1; i<L; i++)
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf);
GEN u = (GEN)sunitrel[i]; u = poleval(u, theta); M[i] = llift( bnfissunit(bnf,suni, gnorm(u)) ); if (lg(M[i]) == 1) err(bugparier,"rnfisnorm"); sunitrel[i] = (long)u;
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3))
aux = zerocol(lg(A)-1); aux[lg(futu)-1] = (long)w; M[L] = (long)aux; H = hnfall0(M, 0); Y = gmul((GEN)H[2], inverseimage((GEN)H[1],A)); setlg(Y, L); aux = factorback(sunitrel, gfloor(Y)); x = gdiv(x, gnorm(gmodulcp(lift(aux),relpol))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || !degpol(x[2])))
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);
res[1] = (long)aux; res[2] = (long)x; return gerepilecopy(av, res);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i; gpmem_t ltop = avma; GEN listp,relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (gpmem_t)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag > 1) { i = cgcd(flag, smodis(prod,flag)); if (i > 1) flag /= i; /* don't include same primes twice */ listp = (GEN)factor(stoi(flag))[1]; for (i=1; i<lg(listp); i++) { GEN p = (GEN)listp[i]; prod = mulii(prod,p); S1 = concatsp(S1,primedec(bnf,p)); S2 = concatsp(S2,primedec(relnf,p)); } } else if (flag < 0) { listp = (GEN)factor(stoi(-flag))[1]; vecconcat(bnf,relnf,listp,&prod,&S1,&S2); } if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN)idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; return gerepilecopy(ltop,res);}
long av=avma,tetpil,m,n,r1,r2,vnf,i,j,k,vpol,v1,r1j,r2j,lfac,degabs;
ulong av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,v1,r1j,r2j,lfac,degabs;
rnfinitalg(GEN nf,GEN pol,long prec){ long av=avma,tetpil,m,n,r1,r2,vnf,i,j,k,vpol,v1,r1j,r2j,lfac,degabs; GEN RES,sig,rac,p1,p2,liftpol,delta,RAC,ro,p3,bas; GEN f,f2,fac,fac1,fac2,id,p4,p5; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); vnf=0; for (i=0; i<=n; i++) { long tp1; p1=(GEN)pol[i+2]; tp1=typ(p1); if (! is_const_t(tp1)) { if (tp1!=t_POLMOD) err(typeer,"rnfinitalg"); p1 = checknfelt_mod(nf, p1, "rnfinitalg"); if (! is_const_t(typ(p1))) { v1=varn(p1); if (vnf && vnf!=v1) err(talker,"different variables in rnfinitalg"); if (!vnf) vnf=v1; } } } if (!vnf) vnf=varn(nf[1]); if (vpol>=vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES=cgetg(12,t_VEC); RES[1]=(long)pol; m=degpol(nf[1]); degabs=n*m; r1 = nf_get_r1(nf); r2 = (m-r1) >> 1; sig=cgetg(r1+r2+1,t_VEC); RES[2]=(long)sig; rac=(GEN)nf[6]; liftpol=lift(pol); RAC=cgetg(r1+r2+1,t_VEC); RES[6]=(long)RAC; for (j=1; j<=r1; j++) { p1=gsubst(liftpol,vnf,(GEN)rac[j]); ro=roots(p1,prec); r1j=0; while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p2=cgetg(3,t_VEC); p2[1]=lstoi(r1j); p2[2]=lstoi(r2j=((n-r1j)>>1)); sig[j]=(long)p2; p3=cgetg(r1j+r2j+1,t_VEC); for (i=1; i<=r1j; i++) p3[i]=lreal((GEN)ro[i]); for (; i<=r1j+r2j; i++) p3[i]=(long)ro[(i<<1)-r1j]; RAC[j]=(long)p3; } for (; j<=r1+r2; j++) { p2=cgetg(3,t_VEC); p2[1]=zero; p2[2]=lstoi(n); sig[j]=(long)p2; p1=gsubst(liftpol,vnf,(GEN)rac[j]); RAC[j]=(long)roots(p1,prec); } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1]=p1[3]; delta[2]=p1[4]; RES[3]=(long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1]=(long)mat_to_vecpol(p2,vpol); bas[2]=(long)p1[2]; RES[7]=(long)bas; RES[8]=linvmat(p2); f2=idealdiv(nf,discsr(pol),(GEN)p1[3]); fac=idealfactor(nf,f2); fac1=(GEN)fac[1]; fac2=(GEN)fac[2]; lfac=lg(fac1)-1; f=idmat(m); for (i=1; i<=lfac; i++) { if (mpodd((GEN)fac2[i])) err(bugparier,"rnfinitalg (odd exponent)"); f=idealmul(nf,f,idealpow(nf,(GEN)fac1[i],gmul2n((GEN)fac2[i],-1))); } RES[4]=(long)f; RES[10]=(long)nf; RES[5]=(long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); RES[9]=lgetg(1,t_VEC); /* table de multiplication */ p2=cgetg(6,t_VEC); RES[11]=(long)p2; p1=rnfequation2(nf,pol); for (i=1; i<=3; i++) p2[i]=p1[i]; p4=cgetg(degabs+1,t_MAT); for (i=1; i<=n; i++) { /* removing denominators speeds up multiplication */ GEN cop3,com, om = rnfelementreltoabs(RES,gmael(bas,1,i)); if (DEBUGLEVEL>1) msgtimer("i = %ld",i); com = content(om); om = gdiv(om,com); id=gmael(bas,2,i); for (j=1; j<=m; j++) { p5=cgetg(degabs+1,t_COL); p4[(i-1)*m+j]=(long)p5; p1=gmul((GEN)nf[7],(GEN)id[j]); p3 = gsubst(p1,varn(nf[1]), (GEN)p2[2]); cop3 = content(p3); p3 = gdiv(p3,cop3); p3 = gmul(gmul(com,cop3), lift_intern(gmul(om,p3))); for (k=1; k<lgef(p3)-1; k++) p5[k]=p3[k+1]; for ( ; k<=degabs; k++) p5[k]=zero; } } if (DEBUGLEVEL>1) msgtimer("p4"); p3 = denom(p4); p4 = hnfmodid(gmul(p3,p4), p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(p4,j,j),2) > 0) { p1=shifti(gcoeff(p4,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(p4,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(p4,i,k)=lsubii(gcoeff(p4,i,k),gcoeff(p4,i,j)); } p4 = gdiv(p4,p3); p2[4]=(long)mat_to_vecpol(p4,vpol); p2[5]=linvmat(p4); tetpil=avma; return gerepile(av,tetpil,gcopy(RES));}
tetpil=avma; return gerepile(av,tetpil,gcopy(RES));
return gerepilecopy(av,RES);
rnfinitalg(GEN nf,GEN pol,long prec){ long av=avma,tetpil,m,n,r1,r2,vnf,i,j,k,vpol,v1,r1j,r2j,lfac,degabs; GEN RES,sig,rac,p1,p2,liftpol,delta,RAC,ro,p3,bas; GEN f,f2,fac,fac1,fac2,id,p4,p5; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); vnf=0; for (i=0; i<=n; i++) { long tp1; p1=(GEN)pol[i+2]; tp1=typ(p1); if (! is_const_t(tp1)) { if (tp1!=t_POLMOD) err(typeer,"rnfinitalg"); p1 = checknfelt_mod(nf, p1, "rnfinitalg"); if (! is_const_t(typ(p1))) { v1=varn(p1); if (vnf && vnf!=v1) err(talker,"different variables in rnfinitalg"); if (!vnf) vnf=v1; } } } if (!vnf) vnf=varn(nf[1]); if (vpol>=vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES=cgetg(12,t_VEC); RES[1]=(long)pol; m=degpol(nf[1]); degabs=n*m; r1 = nf_get_r1(nf); r2 = (m-r1) >> 1; sig=cgetg(r1+r2+1,t_VEC); RES[2]=(long)sig; rac=(GEN)nf[6]; liftpol=lift(pol); RAC=cgetg(r1+r2+1,t_VEC); RES[6]=(long)RAC; for (j=1; j<=r1; j++) { p1=gsubst(liftpol,vnf,(GEN)rac[j]); ro=roots(p1,prec); r1j=0; while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p2=cgetg(3,t_VEC); p2[1]=lstoi(r1j); p2[2]=lstoi(r2j=((n-r1j)>>1)); sig[j]=(long)p2; p3=cgetg(r1j+r2j+1,t_VEC); for (i=1; i<=r1j; i++) p3[i]=lreal((GEN)ro[i]); for (; i<=r1j+r2j; i++) p3[i]=(long)ro[(i<<1)-r1j]; RAC[j]=(long)p3; } for (; j<=r1+r2; j++) { p2=cgetg(3,t_VEC); p2[1]=zero; p2[2]=lstoi(n); sig[j]=(long)p2; p1=gsubst(liftpol,vnf,(GEN)rac[j]); RAC[j]=(long)roots(p1,prec); } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1]=p1[3]; delta[2]=p1[4]; RES[3]=(long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1]=(long)mat_to_vecpol(p2,vpol); bas[2]=(long)p1[2]; RES[7]=(long)bas; RES[8]=linvmat(p2); f2=idealdiv(nf,discsr(pol),(GEN)p1[3]); fac=idealfactor(nf,f2); fac1=(GEN)fac[1]; fac2=(GEN)fac[2]; lfac=lg(fac1)-1; f=idmat(m); for (i=1; i<=lfac; i++) { if (mpodd((GEN)fac2[i])) err(bugparier,"rnfinitalg (odd exponent)"); f=idealmul(nf,f,idealpow(nf,(GEN)fac1[i],gmul2n((GEN)fac2[i],-1))); } RES[4]=(long)f; RES[10]=(long)nf; RES[5]=(long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); RES[9]=lgetg(1,t_VEC); /* table de multiplication */ p2=cgetg(6,t_VEC); RES[11]=(long)p2; p1=rnfequation2(nf,pol); for (i=1; i<=3; i++) p2[i]=p1[i]; p4=cgetg(degabs+1,t_MAT); for (i=1; i<=n; i++) { /* removing denominators speeds up multiplication */ GEN cop3,com, om = rnfelementreltoabs(RES,gmael(bas,1,i)); if (DEBUGLEVEL>1) msgtimer("i = %ld",i); com = content(om); om = gdiv(om,com); id=gmael(bas,2,i); for (j=1; j<=m; j++) { p5=cgetg(degabs+1,t_COL); p4[(i-1)*m+j]=(long)p5; p1=gmul((GEN)nf[7],(GEN)id[j]); p3 = gsubst(p1,varn(nf[1]), (GEN)p2[2]); cop3 = content(p3); p3 = gdiv(p3,cop3); p3 = gmul(gmul(com,cop3), lift_intern(gmul(om,p3))); for (k=1; k<lgef(p3)-1; k++) p5[k]=p3[k+1]; for ( ; k<=degabs; k++) p5[k]=zero; } } if (DEBUGLEVEL>1) msgtimer("p4"); p3 = denom(p4); p4 = hnfmodid(gmul(p3,p4), p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(p4,j,j),2) > 0) { p1=shifti(gcoeff(p4,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(p4,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(p4,i,k)=lsubii(gcoeff(p4,i,k),gcoeff(p4,i,j)); } p4 = gdiv(p4,p3); p2[4]=(long)mat_to_vecpol(p4,vpol); p2[5]=linvmat(p4); tetpil=avma; return gerepile(av,tetpil,gcopy(RES));}
unsigned32 rtems_time; unsigned32 rtc_time;
uint32_t rtems_time; uint32_t rtc_time;
int checkRealTime(){ rtems_time_of_day rtems_tod; rtems_time_of_day rtc_tod; unsigned32 rtems_time; unsigned32 rtc_time; if (!RTC_Present) return -1; rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod ); RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod); rtems_time = _TOD_To_seconds( &rtems_tod ); rtc_time = _TOD_To_seconds( &rtc_tod ); return rtems_time - rtc_time;}
GEN I0 = dummycopy(I), Wa;
GEN I0 = dummycopy(I), W0 = dummycopy(W), Wa;
rnfordmax(GEN nf, GEN pol, GEN pr, long vdisc){ pari_sp av = avma, av1, lim; long i, j, k, n, vpol, cmpt, sep; GEN q, q1, p, T, modpr, W, I, MW, C, p1; GEN Tauinv, Tau, prhinv, pip, nfT, id, rnfId; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); modpr = nf_to_ff_init(nf,&pr,&T,&p); p1 = rnfdedekind_i(nf, pol, modpr, vdisc); if (!p1) { avma = av; return NULL; } if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); sep = itos((GEN)p1[3]); W = gmael(p1,2,1); I = gmael(p1,2,2); pip = basistoalg(nf, (GEN)pr[2]); nfT = (GEN)nf[1]; n = degpol(pol); vpol = varn(pol); q = T? gpowgs(p,degpol(T)): p; q1 = q; while (cmpis(q1,n) < 0) q1 = mulii(q1,q); rnfId = idmat(n); id = idmat(degpol(nfT)); prhinv = idealinv(nf, pr); C = cgetg(n+1, t_MAT); for (j=1; j<=n; j++) C[j] = lgetg(n*n+1, t_COL); MW = cgetg(n*n+1, t_MAT); for (j=1; j<=n*n; j++) MW[j] = lgetg(n+1, t_COL); Tauinv = cgetg(n+1, t_VEC); Tau = cgetg(n+1, t_VEC); av1 = avma; lim = stack_lim(av1,1); for(cmpt=1; ; cmpt++) { GEN I0 = dummycopy(I), Wa; GEN Wainv, Waa; GEN Ip, A, Ainv, MWmod, F; GEN pseudo, G; if (DEBUGLEVEL>1) fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); for (j=1; j<=n; j++) { GEN tau, tauinv; long v1, v2; if (gegal((GEN)I[j],id)) { Tau[j] = Tauinv[j] = un; continue; } p1 = ideal_two_elt(nf,(GEN)I[j]); v1 = element_val(nf,(GEN)p1[1],pr); v2 = element_val(nf,(GEN)p1[2],pr); tau = (v1 > v2)? (GEN)p1[2]: (GEN)p1[1]; tauinv = element_inv(nf, tau); Tau[j] = (long)tau; Tauinv[j] = (long)tauinv; W[j] = (long)element_mulvec(nf, tau, (GEN)W[j]); I[j] = (long)idealmul(nf, tauinv, (GEN)I[j]); } /* W = (Z_K/pr)-basis of O/pr. O = (W0,I0) ~ (W, I) */ Wa = basistoalg(nf,W); /* compute MW: W_i*W_j = sum MW_k,(i,j) W_k */ Waa = lift_intern(mat_to_vecpol(Wa,vpol)); Wainv = lift_intern(ginv(Wa)); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { GEN z = RXQX_rem(gmul((GEN)Waa[i],(GEN)Waa[j]), pol, nfT); long tz = typ(z); if (is_scalar_t(tz) || (tz == t_POL && varn(z) > vpol)) z = gmul(z, (GEN)Wainv[1]); else z = mulmat_pol(Wainv, z); for (k=1; k<=n; k++) { GEN c = gres((GEN)z[k], nfT); coeff(MW, k, (i-1)*n+j) = (long)c; coeff(MW, k, (j-1)*n+i) = (long)c; } } /* compute Ip = pr-radical [ could use Ker(trace) if q large ] */ MWmod = modprM(MW,nf,modpr); F = cgetg(n+1, t_MAT); F[1] = rnfId[1]; for (j=2; j<=n; j++) F[j] = (long)rnfelementid_powmod(MWmod, j, q1, T,p); Ip = FqM_ker(F,T,p); /* Fill C: W_k A_j = sum_i C_(i,j),k A_i */ if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr); for (j=1; j<lg(Ip); j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = (long)to_polmod((GEN)p1[i], nfT); } for ( ; j<=n; j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = lmul(pip, (GEN)p1[i]); } Ainv = lift_intern(ginv(A)); A = lift_intern(A); for (k=1; k<=n; k++) for (j=1; j<=n; j++) { GEN z = gmul(Ainv, gmod(element_mulid(MW, (GEN)A[j],k), nfT)); for (i=1; i<=n; i++) { GEN c = gres((GEN)z[i], nfT); coeff(C, (j-1)*n+i, k) = (long)nf_to_ff(nf,c,modpr); } } G = modprM_lift(FqM_ker(C,T,p), modpr); pseudo = rnfjoinmodules_i(nf, G,prhinv, rnfId,I); /* express W in terms of the power basis */ W = algtobasis(nf, gmul(Wa, basistoalg(nf,(GEN)pseudo[1]))); I = (GEN)pseudo[2]; /* restore the HNF property W[i,i] = 1. NB: Wa upper triangular, with * Wa[i,i] = Tau[i] */ for (j=1; j<=n; j++) if (Tau[j] != un) { W[j] = (long)element_mulvec(nf, (GEN)Tauinv[j], (GEN)W[j]); I[j] = (long)idealmul(nf, (GEN)Tau[j], (GEN)I[j] ); } if (DEBUGLEVEL>3) fprintferr(" new order:\n%Z\n%Z\n", W, I); if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); } if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepileall(av1,2, &W,&I); } }}
if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr);
A = modprM_lift(FqM_suppl(Ip,T,p), modpr);
rnfordmax(GEN nf, GEN pol, GEN pr, long vdisc){ pari_sp av = avma, av1, lim; long i, j, k, n, vpol, cmpt, sep; GEN q, q1, p, T, modpr, W, I, MW, C, p1; GEN Tauinv, Tau, prhinv, pip, nfT, id, rnfId; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); modpr = nf_to_ff_init(nf,&pr,&T,&p); p1 = rnfdedekind_i(nf, pol, modpr, vdisc); if (!p1) { avma = av; return NULL; } if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); sep = itos((GEN)p1[3]); W = gmael(p1,2,1); I = gmael(p1,2,2); pip = basistoalg(nf, (GEN)pr[2]); nfT = (GEN)nf[1]; n = degpol(pol); vpol = varn(pol); q = T? gpowgs(p,degpol(T)): p; q1 = q; while (cmpis(q1,n) < 0) q1 = mulii(q1,q); rnfId = idmat(n); id = idmat(degpol(nfT)); prhinv = idealinv(nf, pr); C = cgetg(n+1, t_MAT); for (j=1; j<=n; j++) C[j] = lgetg(n*n+1, t_COL); MW = cgetg(n*n+1, t_MAT); for (j=1; j<=n*n; j++) MW[j] = lgetg(n+1, t_COL); Tauinv = cgetg(n+1, t_VEC); Tau = cgetg(n+1, t_VEC); av1 = avma; lim = stack_lim(av1,1); for(cmpt=1; ; cmpt++) { GEN I0 = dummycopy(I), Wa; GEN Wainv, Waa; GEN Ip, A, Ainv, MWmod, F; GEN pseudo, G; if (DEBUGLEVEL>1) fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); for (j=1; j<=n; j++) { GEN tau, tauinv; long v1, v2; if (gegal((GEN)I[j],id)) { Tau[j] = Tauinv[j] = un; continue; } p1 = ideal_two_elt(nf,(GEN)I[j]); v1 = element_val(nf,(GEN)p1[1],pr); v2 = element_val(nf,(GEN)p1[2],pr); tau = (v1 > v2)? (GEN)p1[2]: (GEN)p1[1]; tauinv = element_inv(nf, tau); Tau[j] = (long)tau; Tauinv[j] = (long)tauinv; W[j] = (long)element_mulvec(nf, tau, (GEN)W[j]); I[j] = (long)idealmul(nf, tauinv, (GEN)I[j]); } /* W = (Z_K/pr)-basis of O/pr. O = (W0,I0) ~ (W, I) */ Wa = basistoalg(nf,W); /* compute MW: W_i*W_j = sum MW_k,(i,j) W_k */ Waa = lift_intern(mat_to_vecpol(Wa,vpol)); Wainv = lift_intern(ginv(Wa)); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { GEN z = RXQX_rem(gmul((GEN)Waa[i],(GEN)Waa[j]), pol, nfT); long tz = typ(z); if (is_scalar_t(tz) || (tz == t_POL && varn(z) > vpol)) z = gmul(z, (GEN)Wainv[1]); else z = mulmat_pol(Wainv, z); for (k=1; k<=n; k++) { GEN c = gres((GEN)z[k], nfT); coeff(MW, k, (i-1)*n+j) = (long)c; coeff(MW, k, (j-1)*n+i) = (long)c; } } /* compute Ip = pr-radical [ could use Ker(trace) if q large ] */ MWmod = modprM(MW,nf,modpr); F = cgetg(n+1, t_MAT); F[1] = rnfId[1]; for (j=2; j<=n; j++) F[j] = (long)rnfelementid_powmod(MWmod, j, q1, T,p); Ip = FqM_ker(F,T,p); /* Fill C: W_k A_j = sum_i C_(i,j),k A_i */ if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr); for (j=1; j<lg(Ip); j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = (long)to_polmod((GEN)p1[i], nfT); } for ( ; j<=n; j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = lmul(pip, (GEN)p1[i]); } Ainv = lift_intern(ginv(A)); A = lift_intern(A); for (k=1; k<=n; k++) for (j=1; j<=n; j++) { GEN z = gmul(Ainv, gmod(element_mulid(MW, (GEN)A[j],k), nfT)); for (i=1; i<=n; i++) { GEN c = gres((GEN)z[i], nfT); coeff(C, (j-1)*n+i, k) = (long)nf_to_ff(nf,c,modpr); } } G = modprM_lift(FqM_ker(C,T,p), modpr); pseudo = rnfjoinmodules_i(nf, G,prhinv, rnfId,I); /* express W in terms of the power basis */ W = algtobasis(nf, gmul(Wa, basistoalg(nf,(GEN)pseudo[1]))); I = (GEN)pseudo[2]; /* restore the HNF property W[i,i] = 1. NB: Wa upper triangular, with * Wa[i,i] = Tau[i] */ for (j=1; j<=n; j++) if (Tau[j] != un) { W[j] = (long)element_mulvec(nf, (GEN)Tauinv[j], (GEN)W[j]); I[j] = (long)idealmul(nf, (GEN)Tau[j], (GEN)I[j] ); } if (DEBUGLEVEL>3) fprintferr(" new order:\n%Z\n%Z\n", W, I); if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); } if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepileall(av1,2, &W,&I); } }}
G = modprM_lift(FqM_ker(C,T,p), modpr);
rnfordmax(GEN nf, GEN pol, GEN pr, long vdisc){ pari_sp av = avma, av1, lim; long i, j, k, n, vpol, cmpt, sep; GEN q, q1, p, T, modpr, W, I, MW, C, p1; GEN Tauinv, Tau, prhinv, pip, nfT, id, rnfId; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); modpr = nf_to_ff_init(nf,&pr,&T,&p); p1 = rnfdedekind_i(nf, pol, modpr, vdisc); if (!p1) { avma = av; return NULL; } if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); sep = itos((GEN)p1[3]); W = gmael(p1,2,1); I = gmael(p1,2,2); pip = basistoalg(nf, (GEN)pr[2]); nfT = (GEN)nf[1]; n = degpol(pol); vpol = varn(pol); q = T? gpowgs(p,degpol(T)): p; q1 = q; while (cmpis(q1,n) < 0) q1 = mulii(q1,q); rnfId = idmat(n); id = idmat(degpol(nfT)); prhinv = idealinv(nf, pr); C = cgetg(n+1, t_MAT); for (j=1; j<=n; j++) C[j] = lgetg(n*n+1, t_COL); MW = cgetg(n*n+1, t_MAT); for (j=1; j<=n*n; j++) MW[j] = lgetg(n+1, t_COL); Tauinv = cgetg(n+1, t_VEC); Tau = cgetg(n+1, t_VEC); av1 = avma; lim = stack_lim(av1,1); for(cmpt=1; ; cmpt++) { GEN I0 = dummycopy(I), Wa; GEN Wainv, Waa; GEN Ip, A, Ainv, MWmod, F; GEN pseudo, G; if (DEBUGLEVEL>1) fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); for (j=1; j<=n; j++) { GEN tau, tauinv; long v1, v2; if (gegal((GEN)I[j],id)) { Tau[j] = Tauinv[j] = un; continue; } p1 = ideal_two_elt(nf,(GEN)I[j]); v1 = element_val(nf,(GEN)p1[1],pr); v2 = element_val(nf,(GEN)p1[2],pr); tau = (v1 > v2)? (GEN)p1[2]: (GEN)p1[1]; tauinv = element_inv(nf, tau); Tau[j] = (long)tau; Tauinv[j] = (long)tauinv; W[j] = (long)element_mulvec(nf, tau, (GEN)W[j]); I[j] = (long)idealmul(nf, tauinv, (GEN)I[j]); } /* W = (Z_K/pr)-basis of O/pr. O = (W0,I0) ~ (W, I) */ Wa = basistoalg(nf,W); /* compute MW: W_i*W_j = sum MW_k,(i,j) W_k */ Waa = lift_intern(mat_to_vecpol(Wa,vpol)); Wainv = lift_intern(ginv(Wa)); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { GEN z = RXQX_rem(gmul((GEN)Waa[i],(GEN)Waa[j]), pol, nfT); long tz = typ(z); if (is_scalar_t(tz) || (tz == t_POL && varn(z) > vpol)) z = gmul(z, (GEN)Wainv[1]); else z = mulmat_pol(Wainv, z); for (k=1; k<=n; k++) { GEN c = gres((GEN)z[k], nfT); coeff(MW, k, (i-1)*n+j) = (long)c; coeff(MW, k, (j-1)*n+i) = (long)c; } } /* compute Ip = pr-radical [ could use Ker(trace) if q large ] */ MWmod = modprM(MW,nf,modpr); F = cgetg(n+1, t_MAT); F[1] = rnfId[1]; for (j=2; j<=n; j++) F[j] = (long)rnfelementid_powmod(MWmod, j, q1, T,p); Ip = FqM_ker(F,T,p); /* Fill C: W_k A_j = sum_i C_(i,j),k A_i */ if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr); for (j=1; j<lg(Ip); j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = (long)to_polmod((GEN)p1[i], nfT); } for ( ; j<=n; j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = lmul(pip, (GEN)p1[i]); } Ainv = lift_intern(ginv(A)); A = lift_intern(A); for (k=1; k<=n; k++) for (j=1; j<=n; j++) { GEN z = gmul(Ainv, gmod(element_mulid(MW, (GEN)A[j],k), nfT)); for (i=1; i<=n; i++) { GEN c = gres((GEN)z[i], nfT); coeff(C, (j-1)*n+i, k) = (long)nf_to_ff(nf,c,modpr); } } G = modprM_lift(FqM_ker(C,T,p), modpr); pseudo = rnfjoinmodules_i(nf, G,prhinv, rnfId,I); /* express W in terms of the power basis */ W = algtobasis(nf, gmul(Wa, basistoalg(nf,(GEN)pseudo[1]))); I = (GEN)pseudo[2]; /* restore the HNF property W[i,i] = 1. NB: Wa upper triangular, with * Wa[i,i] = Tau[i] */ for (j=1; j<=n; j++) if (Tau[j] != un) { W[j] = (long)element_mulvec(nf, (GEN)Tauinv[j], (GEN)W[j]); I[j] = (long)idealmul(nf, (GEN)Tau[j], (GEN)I[j] ); } if (DEBUGLEVEL>3) fprintferr(" new order:\n%Z\n%Z\n", W, I); if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); } if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepileall(av1,2, &W,&I); } }}
if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); }
if (sep <= 3 || gegal(I,I0)) break;
rnfordmax(GEN nf, GEN pol, GEN pr, long vdisc){ pari_sp av = avma, av1, lim; long i, j, k, n, vpol, cmpt, sep; GEN q, q1, p, T, modpr, W, I, MW, C, p1; GEN Tauinv, Tau, prhinv, pip, nfT, id, rnfId; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); modpr = nf_to_ff_init(nf,&pr,&T,&p); p1 = rnfdedekind_i(nf, pol, modpr, vdisc); if (!p1) { avma = av; return NULL; } if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); sep = itos((GEN)p1[3]); W = gmael(p1,2,1); I = gmael(p1,2,2); pip = basistoalg(nf, (GEN)pr[2]); nfT = (GEN)nf[1]; n = degpol(pol); vpol = varn(pol); q = T? gpowgs(p,degpol(T)): p; q1 = q; while (cmpis(q1,n) < 0) q1 = mulii(q1,q); rnfId = idmat(n); id = idmat(degpol(nfT)); prhinv = idealinv(nf, pr); C = cgetg(n+1, t_MAT); for (j=1; j<=n; j++) C[j] = lgetg(n*n+1, t_COL); MW = cgetg(n*n+1, t_MAT); for (j=1; j<=n*n; j++) MW[j] = lgetg(n+1, t_COL); Tauinv = cgetg(n+1, t_VEC); Tau = cgetg(n+1, t_VEC); av1 = avma; lim = stack_lim(av1,1); for(cmpt=1; ; cmpt++) { GEN I0 = dummycopy(I), Wa; GEN Wainv, Waa; GEN Ip, A, Ainv, MWmod, F; GEN pseudo, G; if (DEBUGLEVEL>1) fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); for (j=1; j<=n; j++) { GEN tau, tauinv; long v1, v2; if (gegal((GEN)I[j],id)) { Tau[j] = Tauinv[j] = un; continue; } p1 = ideal_two_elt(nf,(GEN)I[j]); v1 = element_val(nf,(GEN)p1[1],pr); v2 = element_val(nf,(GEN)p1[2],pr); tau = (v1 > v2)? (GEN)p1[2]: (GEN)p1[1]; tauinv = element_inv(nf, tau); Tau[j] = (long)tau; Tauinv[j] = (long)tauinv; W[j] = (long)element_mulvec(nf, tau, (GEN)W[j]); I[j] = (long)idealmul(nf, tauinv, (GEN)I[j]); } /* W = (Z_K/pr)-basis of O/pr. O = (W0,I0) ~ (W, I) */ Wa = basistoalg(nf,W); /* compute MW: W_i*W_j = sum MW_k,(i,j) W_k */ Waa = lift_intern(mat_to_vecpol(Wa,vpol)); Wainv = lift_intern(ginv(Wa)); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { GEN z = RXQX_rem(gmul((GEN)Waa[i],(GEN)Waa[j]), pol, nfT); long tz = typ(z); if (is_scalar_t(tz) || (tz == t_POL && varn(z) > vpol)) z = gmul(z, (GEN)Wainv[1]); else z = mulmat_pol(Wainv, z); for (k=1; k<=n; k++) { GEN c = gres((GEN)z[k], nfT); coeff(MW, k, (i-1)*n+j) = (long)c; coeff(MW, k, (j-1)*n+i) = (long)c; } } /* compute Ip = pr-radical [ could use Ker(trace) if q large ] */ MWmod = modprM(MW,nf,modpr); F = cgetg(n+1, t_MAT); F[1] = rnfId[1]; for (j=2; j<=n; j++) F[j] = (long)rnfelementid_powmod(MWmod, j, q1, T,p); Ip = FqM_ker(F,T,p); /* Fill C: W_k A_j = sum_i C_(i,j),k A_i */ if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr); for (j=1; j<lg(Ip); j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = (long)to_polmod((GEN)p1[i], nfT); } for ( ; j<=n; j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = lmul(pip, (GEN)p1[i]); } Ainv = lift_intern(ginv(A)); A = lift_intern(A); for (k=1; k<=n; k++) for (j=1; j<=n; j++) { GEN z = gmul(Ainv, gmod(element_mulid(MW, (GEN)A[j],k), nfT)); for (i=1; i<=n; i++) { GEN c = gres((GEN)z[i], nfT); coeff(C, (j-1)*n+i, k) = (long)nf_to_ff(nf,c,modpr); } } G = modprM_lift(FqM_ker(C,T,p), modpr); pseudo = rnfjoinmodules_i(nf, G,prhinv, rnfId,I); /* express W in terms of the power basis */ W = algtobasis(nf, gmul(Wa, basistoalg(nf,(GEN)pseudo[1]))); I = (GEN)pseudo[2]; /* restore the HNF property W[i,i] = 1. NB: Wa upper triangular, with * Wa[i,i] = Tau[i] */ for (j=1; j<=n; j++) if (Tau[j] != un) { W[j] = (long)element_mulvec(nf, (GEN)Tauinv[j], (GEN)W[j]); I[j] = (long)idealmul(nf, (GEN)Tau[j], (GEN)I[j] ); } if (DEBUGLEVEL>3) fprintferr(" new order:\n%Z\n%Z\n", W, I); if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); } if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepileall(av1,2, &W,&I); } }}
{ GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); }
rnfordmax(GEN nf, GEN pol, GEN pr, long vdisc){ pari_sp av = avma, av1, lim; long i, j, k, n, vpol, cmpt, sep; GEN q, q1, p, T, modpr, W, I, MW, C, p1; GEN Tauinv, Tau, prhinv, pip, nfT, id, rnfId; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); modpr = nf_to_ff_init(nf,&pr,&T,&p); p1 = rnfdedekind_i(nf, pol, modpr, vdisc); if (!p1) { avma = av; return NULL; } if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); sep = itos((GEN)p1[3]); W = gmael(p1,2,1); I = gmael(p1,2,2); pip = basistoalg(nf, (GEN)pr[2]); nfT = (GEN)nf[1]; n = degpol(pol); vpol = varn(pol); q = T? gpowgs(p,degpol(T)): p; q1 = q; while (cmpis(q1,n) < 0) q1 = mulii(q1,q); rnfId = idmat(n); id = idmat(degpol(nfT)); prhinv = idealinv(nf, pr); C = cgetg(n+1, t_MAT); for (j=1; j<=n; j++) C[j] = lgetg(n*n+1, t_COL); MW = cgetg(n*n+1, t_MAT); for (j=1; j<=n*n; j++) MW[j] = lgetg(n+1, t_COL); Tauinv = cgetg(n+1, t_VEC); Tau = cgetg(n+1, t_VEC); av1 = avma; lim = stack_lim(av1,1); for(cmpt=1; ; cmpt++) { GEN I0 = dummycopy(I), Wa; GEN Wainv, Waa; GEN Ip, A, Ainv, MWmod, F; GEN pseudo, G; if (DEBUGLEVEL>1) fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); for (j=1; j<=n; j++) { GEN tau, tauinv; long v1, v2; if (gegal((GEN)I[j],id)) { Tau[j] = Tauinv[j] = un; continue; } p1 = ideal_two_elt(nf,(GEN)I[j]); v1 = element_val(nf,(GEN)p1[1],pr); v2 = element_val(nf,(GEN)p1[2],pr); tau = (v1 > v2)? (GEN)p1[2]: (GEN)p1[1]; tauinv = element_inv(nf, tau); Tau[j] = (long)tau; Tauinv[j] = (long)tauinv; W[j] = (long)element_mulvec(nf, tau, (GEN)W[j]); I[j] = (long)idealmul(nf, tauinv, (GEN)I[j]); } /* W = (Z_K/pr)-basis of O/pr. O = (W0,I0) ~ (W, I) */ Wa = basistoalg(nf,W); /* compute MW: W_i*W_j = sum MW_k,(i,j) W_k */ Waa = lift_intern(mat_to_vecpol(Wa,vpol)); Wainv = lift_intern(ginv(Wa)); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { GEN z = RXQX_rem(gmul((GEN)Waa[i],(GEN)Waa[j]), pol, nfT); long tz = typ(z); if (is_scalar_t(tz) || (tz == t_POL && varn(z) > vpol)) z = gmul(z, (GEN)Wainv[1]); else z = mulmat_pol(Wainv, z); for (k=1; k<=n; k++) { GEN c = gres((GEN)z[k], nfT); coeff(MW, k, (i-1)*n+j) = (long)c; coeff(MW, k, (j-1)*n+i) = (long)c; } } /* compute Ip = pr-radical [ could use Ker(trace) if q large ] */ MWmod = modprM(MW,nf,modpr); F = cgetg(n+1, t_MAT); F[1] = rnfId[1]; for (j=2; j<=n; j++) F[j] = (long)rnfelementid_powmod(MWmod, j, q1, T,p); Ip = FqM_ker(F,T,p); /* Fill C: W_k A_j = sum_i C_(i,j),k A_i */ if (lg(Ip) == 1) A = rnfId; else A = modprM_lift(FqM_suppl(Ip,T,p), modpr); for (j=1; j<lg(Ip); j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = (long)to_polmod((GEN)p1[i], nfT); } for ( ; j<=n; j++) { p1 = (GEN)A[j]; for (i=1; i<=n; i++) p1[i] = lmul(pip, (GEN)p1[i]); } Ainv = lift_intern(ginv(A)); A = lift_intern(A); for (k=1; k<=n; k++) for (j=1; j<=n; j++) { GEN z = gmul(Ainv, gmod(element_mulid(MW, (GEN)A[j],k), nfT)); for (i=1; i<=n; i++) { GEN c = gres((GEN)z[i], nfT); coeff(C, (j-1)*n+i, k) = (long)nf_to_ff(nf,c,modpr); } } G = modprM_lift(FqM_ker(C,T,p), modpr); pseudo = rnfjoinmodules_i(nf, G,prhinv, rnfId,I); /* express W in terms of the power basis */ W = algtobasis(nf, gmul(Wa, basistoalg(nf,(GEN)pseudo[1]))); I = (GEN)pseudo[2]; /* restore the HNF property W[i,i] = 1. NB: Wa upper triangular, with * Wa[i,i] = Tau[i] */ for (j=1; j<=n; j++) if (Tau[j] != un) { W[j] = (long)element_mulvec(nf, (GEN)Tauinv[j], (GEN)W[j]); I[j] = (long)idealmul(nf, (GEN)Tau[j], (GEN)I[j] ); } if (DEBUGLEVEL>3) fprintferr(" new order:\n%Z\n%Z\n", W, I); if (sep <= 3 || gegal(I,I0)) { GEN res = cgetg(3,t_VEC); res[1] = (long)W; res[2] = (long)I; return gerepilecopy(av, res); } if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepileall(av1,2, &W,&I); } }}
flush_cache();
rtems_flush_entire_data_cache();
void _CPU_disable_paging() { cr0 regCr0; flush_cache(); regCr0.i = i386_get_cr0(); regCr0.cr0.paging = 0; i386_set_cr0( regCr0.i );}
case SIOCSIFTAP: ifp->if_tap = ifr->ifr_tap; return 0; case SIOCGIFTAP: ifr->ifr_tap = ifp->if_tap; return 0;
ifioctl(so, cmd, data, p) struct socket *so; int cmd; caddr_t data; struct proc *p;{ register struct ifnet *ifp; register struct ifreq *ifr; int error; switch (cmd) { case SIOCGIFCONF: case OSIOCGIFCONF: return (ifconf(cmd, data)); } ifr = (struct ifreq *)data; ifp = ifunit(ifr->ifr_name); if (ifp == 0) return (ENXIO); switch (cmd) { case SIOCGIFFLAGS: ifr->ifr_flags = ifp->if_flags; break; case SIOCGIFMETRIC: ifr->ifr_metric = ifp->if_metric; break; case SIOCGIFMTU: ifr->ifr_mtu = ifp->if_mtu; break; case SIOCGIFPHYS: ifr->ifr_phys = ifp->if_physical; break; case SIOCSIFFLAGS: error = suser(p->p_ucred, &p->p_acflag); if (error) return (error); if (ifp->if_flags & IFF_UP && (ifr->ifr_flags & IFF_UP) == 0) { int s = splimp(); if_down(ifp); splx(s); } if (ifr->ifr_flags & IFF_UP && (ifp->if_flags & IFF_UP) == 0) { int s = splimp(); if_up(ifp); splx(s); } ifp->if_flags = (ifp->if_flags & IFF_CANTCHANGE) | (ifr->ifr_flags &~ IFF_CANTCHANGE); if (ifp->if_ioctl) (void) (*ifp->if_ioctl)(ifp, cmd, data); microtime(&ifp->if_lastchange); break; case SIOCSIFMETRIC: error = suser(p->p_ucred, &p->p_acflag); if (error) return (error); ifp->if_metric = ifr->ifr_metric; microtime(&ifp->if_lastchange); break; case SIOCSIFPHYS: error = suser(p->p_ucred, &p->p_acflag); if (error) return error; if (!ifp->if_ioctl) return EOPNOTSUPP; error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == 0) microtime(&ifp->if_lastchange); return(error); case SIOCSIFMTU: error = suser(p->p_ucred, &p->p_acflag); if (error) return (error); if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); /* * 72 was chosen below because it is the size of a TCP/IP * header (40) + the minimum mss (32). */ if (ifr->ifr_mtu < 72 || ifr->ifr_mtu > 65535) return (EINVAL); error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == 0) microtime(&ifp->if_lastchange); return(error); case SIOCADDMULTI: case SIOCDELMULTI: error = suser(p->p_ucred, &p->p_acflag); if (error) return (error); if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == 0 ) microtime(&ifp->if_lastchange); return(error); case SIOCSIFMEDIA: error = suser(p->p_ucred, &p->p_acflag); if (error) return (error); if (ifp->if_ioctl == 0) return (EOPNOTSUPP); error = (*ifp->if_ioctl)(ifp, cmd, data); if (error == 0) microtime(&ifp->if_lastchange); return error; case SIOCGIFMEDIA: if (ifp->if_ioctl == 0) return (EOPNOTSUPP); return ((*ifp->if_ioctl)(ifp, cmd, data)); default: if (so->so_proto == 0) return (EOPNOTSUPP);#ifndef COMPAT_43 return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, ifp));#else { int ocmd = cmd; switch (cmd) { case SIOCSIFDSTADDR: case SIOCSIFADDR: case SIOCSIFBRDADDR: case SIOCSIFNETMASK:#if BYTE_ORDER != BIG_ENDIAN if (ifr->ifr_addr.sa_family == 0 && ifr->ifr_addr.sa_len < 16) { ifr->ifr_addr.sa_family = ifr->ifr_addr.sa_len; ifr->ifr_addr.sa_len = 16; }#else if (ifr->ifr_addr.sa_len == 0) ifr->ifr_addr.sa_len = 16;#endif break; case OSIOCGIFADDR: cmd = SIOCGIFADDR; break; case OSIOCGIFDSTADDR: cmd = SIOCGIFDSTADDR; break; case OSIOCGIFBRDADDR: cmd = SIOCGIFBRDADDR; break; case OSIOCGIFNETMASK: cmd = SIOCGIFNETMASK; } error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, ifp)); switch (ocmd) { case OSIOCGIFADDR: case OSIOCGIFDSTADDR: case OSIOCGIFBRDADDR: case OSIOCGIFNETMASK: *(u_short *)&ifr->ifr_addr = ifr->ifr_addr.sa_family; } return (error); }#endif } return (0);}
size = (long) (1.09 * maxnum/log((double)maxnum)) + 145;
size = (long) (1.09 * maxnum/log((double)maxnum)) + 146;
initprimes0(ulong maxnum, long *lenp, ulong *lastp){ long size, alloced, psize; byteptr q, fin, p, p1, fin1, plast, curdiff; ulong last, remains, curlow, rootnum, asize; ulong prime_above = 3; byteptr p_prime_above; if (maxnum <= 1ul<<17) /* Arbitrary. */ return initprimes1(maxnum>>1, lenp, (long*)lastp); /* Break recursion */ maxnum |= 1; /* make it odd. */ /* Checked to be enough up to 40e6, attained at 155893 */ /* Due to multibyte representation of large gaps, this estimate will be broken by large enough maxnum. However, assuming exponential distribution of gaps with the average log(n), we are safe up to circa exp(-256/log(1/0.09)) = 1.5e46. OK with LONG_BITS <= 128. ;-) */ size = (long) (1.09 * maxnum/log((double)maxnum)) + 145; p1 = (byteptr) gpmalloc(size); rootnum = (ulong) sqrt((double)maxnum); /* cast it back to a long */ rootnum |= 1; { byteptr p2 = initprimes0(rootnum, &psize, &last); /* recursive call */ memcpy(p1, p2, psize); free(p2); } fin1 = p1 + psize - 1; remains = (maxnum - rootnum) >> 1; /* number of odd numbers to check */ /* Actually, we access primes array of psize too; but we access it consequently, thus we do not include it in fixed_to_cache */ asize = good_arena_size((ulong)(rootnum * slow2_in_roots), remains + 1, 0, &cache_model, 0) - 1; /* enough room on the stack ? */ alloced = (((byteptr)avma) <= ((byteptr)bot) + asize); if (alloced) p = (byteptr) gpmalloc(asize + 1); else p = (byteptr) bot; fin = p + asize; /* the 0 sentinel goes at fin. */ curlow = rootnum + 2; /* First candidate: know primes up to rootnum (odd). */ curdiff = fin1; /* During each iteration p..fin-1 represents a range of odd numbers. plast is a pointer which represents the last prime seen, it may point before p..fin-1. */ plast = p - ((rootnum - last) >> 1) - 1; p_prime_above = p1 + 2; while (remains) /* Cycle over arenas. Performance is not crucial */ { unsigned char was_delta; if (asize > remains) { asize = remains; fin = p + asize; } /* Fake the upper limit appropriate for the given arena */ while (prime_above*prime_above <= curlow + (asize << 1) && *p_prime_above) prime_above += *p_prime_above++; was_delta = *p_prime_above; *p_prime_above = 0; /* Put a 0 sentinel for sieve_chunk */ (*sieve_chunk_p)(p1, curlow, p, asize); *p_prime_above = was_delta; /* Restore */ p[asize] = 0; /* Put a 0 sentinel for ZZZ */ /* now q runs over addresses corresponding to primes */ for (q = p; ; plast = q++) { long d; while (*q) q++; /* use ZZZ 0-sentinel at end */ if (q >= fin) break; d = (q - plast) << 1; while (d >= DIFFPTR_SKIP) *curdiff++ = DIFFPTR_SKIP, d -= DIFFPTR_SKIP; *curdiff++ = (unsigned char)d; } plast -= asize; remains -= asize; curlow += (asize<<1); } /* while (remains) */ last = curlow - ((p - plast) << 1); *curdiff++ = 0; /* sentinel */ *lenp = curdiff - p1; *lastp = last; if (alloced) free(p); return (byteptr) gprealloc(p1, *lenp);}
GEN N, P, M, d = qf_disc(Q);
GEN N, P, P1, P2, M, d = qf_disc(Q);
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
N = redrealsl2(Q);
M = N = redrealsl2(Q);
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
gel(P,2) = negi(gel(P,2)); P = M = redrealsl2(P);
P1 = redrealsl2(P); gel(P,2) = negi(gel(P,2)); P2 = redrealsl2(P);
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
while (!gequal(gel(M,1), gel(N,1)))
while (!gequal(gel(M,1), gel(P1,1)) && !gequal(gel(M,1), gel(P2,1)))
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; }
if (gequal(gel(M,1), gel(N,1))) { avma = ltop; return gen_0; }
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));
if (gequal(gel(M,1),gel(P1,1))) return gerepilecopy(ltop, SL2_div_mul_e1(gel(M,2),gel(P1,2))); else return gerepilecopy(ltop, SL2_div_mul_e1(gel(M,2),gel(P2,2)));
qfbrealsolvep(GEN Q, GEN p){ pari_sp ltop = avma, btop, st_lim; GEN N, P, M, d = qf_disc(Q); if (kronecker(d, p) < 0) { avma = ltop; return gen_0; } N = redrealsl2(Q); P = primeform(d, p, DEFAULTPREC); gel(P,2) = negi(gel(P,2));/*This form leads to a smaller solution*/ P = M = redrealsl2(P); btop = avma; st_lim = stack_lim(btop, 1); while (!gequal(gel(M,1), gel(N,1))) { M = redrealsl2step(M); if (gequal(gel(M,1), gel(P,1))) { avma = ltop; return gen_0; } if (low_stack(st_lim, stack_lim(btop, 1))) M = gerepileupto(btop, M); } return gerepilecopy(ltop, SL2_div_mul_e1(gel(N,2),gel(M,2)));}
cand = fincke_pohst(A, nB, 20000, prec2, &chk);
cand = fincke_pohst(A, nB, -1, prec2, &chk);
RecCoeff3(GEN nf, RC_data *d, long prec){ GEN A, M, nB, cand, p1, B2, C2, tB, beta2, eps, nf2, Bd; GEN beta = d->beta, B = d->B; long N = d->N, v = d->v; long i, j, k, l, ct = 0, prec2; pari_sp av = avma; FP_chk_fun chk = { &chk_reccoeff, &chk_reccoeff_init, NULL, 0 }; chk.data = (void*)d; d->G = min(-10, -bit_accuracy(prec) >> 4); eps = gpowgs(stoi(10), min(-8, (d->G >> 1))); tB = gpow(gmul2n(eps, N), gdivgs(gun, 1-N), DEFAULTPREC); Bd = gceil(gmin(B, tB)); p1 = gceil(gdiv(glog(Bd, DEFAULTPREC), dbltor(2.3026))); prec2 = max((prec << 1) - 2, (long)(itos(p1) * pariK1 + BIGDEFAULTPREC)); nf2 = nfnewprec(nf, prec2); beta2 = gprec_w(beta, prec2); LABrcf: ct++; B2 = sqri(Bd); C2 = gdiv(B2, gsqr(eps)); M = gmael(nf2, 5, 1); d->M = M; A = cgetg(N+2, t_MAT); for (i = 1; i <= N+1; i++) A[i] = lgetg(N+2, t_COL); coeff(A, 1, 1) = ladd(gmul(C2, gsqr(beta2)), B2); for (j = 2; j <= N+1; j++) { p1 = gmul(C2, gmul(gneg_i(beta2), gcoeff(M, v, j-1))); coeff(A, 1, j) = coeff(A, j, 1) = (long)p1; } for (i = 2; i <= N+1; i++) for (j = 2; j <= N+1; j++) { p1 = gzero; for (k = 1; k <= N; k++) { GEN p2 = gmul(gcoeff(M, k, j-1), gcoeff(M, k, i-1)); if (k == v) p2 = gmul(C2, p2); p1 = gadd(p1,p2); } coeff(A, i, j) = coeff(A, j, i) = (long)p1; } nB = mulsi(N+1, B2); d->nB = nB; cand = fincke_pohst(A, nB, 20000, prec2, &chk); if (!cand) { if (ct > 3) { avma = av; return NULL; } prec2 = (prec2 << 1) - 2; if (DEBUGLEVEL >= 2) err(warnprec,"RecCoeff", prec2); nf2 = nfnewprec(nf2, prec2); beta2 = gprec_w(beta2, prec2); goto LABrcf; } cand = (GEN)cand[1]; l = lg(cand) - 1; if (l == 1) return gerepileupto(av, basistoalg(nf, (GEN)cand[1])); if (DEBUGLEVEL >= 2) fprintferr("RecCoeff3: no solution found!\n"); avma = av; return NULL;}
for ( ; i < dg; i++) c2[i] = 0;
for ( ; i < (short)dg; i++) c2[i] = 0;
MulPolmodCoeff(GEN polmod, int* c1, int** reduc, long dg){ long av,i,j; int c, *c2, *c3; if (gcmp1(polmod)) return; for (i = 0; i < dg; i++) if (c1[i]) break; if (i == dg) return; av = avma; c3 = (int*)new_chunk(2*dg); c2 = (int*)new_chunk(dg); Polmod2Coeff(c2,polmod, dg); for (i = 0; i < 2*dg; i++) { c = 0; for (j = 0; j <= i; j++) if (j < dg && j > i - dg) c += c1[j] * c2[i-j]; c3[i] = c; } c2 = c1; for (i = 0; i < dg; i++) { c = c3[i]; for (j = 0; j < dg; j++) c += reduc[j][i] * c3[dg+j]; c2[i] = c; } for ( ; i < dg; i++) c2[i] = 0; avma = av;}
if (isexactzero(t)) x = bitprec;
if (isexactzero(t)) x = -bitprec;
roots_com(GEN q, long bitprec){ GEN L, p; long v = polvaluation_inexact(q, &p); if (lgef(p) == 3) L = cgetg(1,t_VEC); /* constant polynomial */ else L = isexactpol(p)? solve_exact_pol(p,bitprec): all_roots(p,bitprec); if (v) { GEN M, z, t = (GEN)q[2]; long i, x, y, l, n; if (isexactzero(t)) x = bitprec; else { n = gexpo(t); x = n / v; l = degpol(q); for (i = v; i <= l; i++) { t = (GEN)q[i+2]; if (isexactzero(t)) continue; y = (n - gexpo(t)) / i; if (y < x) x = y; } } z = realzero_bit(x); l = v + lg(L); M = cgetg(l, t_VEC); L -= v; for (i = 1; i <= v; i++) M[i] = (long)z; for ( ; i < l; i++) M[i] = L[i]; L = M; } return L;}
while (isdigit(*cp))
while (isdigit((int)*cp))
latlon2ul(latlonstrptr,which) char **latlonstrptr; int *which;{ char *cp; u_int32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval);}
while (isspace(*cp))
while (isspace((int)*cp))
latlon2ul(latlonstrptr,which) char **latlonstrptr; int *which;{ char *cp; u_int32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval);}
if (!(isdigit(*cp)))
if (!(isdigit((int)*cp)))
latlon2ul(latlonstrptr,which) char **latlonstrptr; int *which;{ char *cp; u_int32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval);}
if (isdigit(*cp)) {
if (isdigit((int)*cp)) {
latlon2ul(latlonstrptr,which) char **latlonstrptr; int *which;{ char *cp; u_int32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval);}
while (!isspace(*cp))
while (!isspace((int)*cp))
latlon2ul(latlonstrptr,which) char **latlonstrptr; int *which;{ char *cp; u_int32_t retval; int deg = 0, min = 0, secs = 0, secsfrac = 0; cp = *latlonstrptr; while (isdigit(*cp)) deg = deg * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) min = min * 10 + (*cp++ - '0'); while (isspace(*cp)) cp++; if (!(isdigit(*cp))) goto fndhemi; while (isdigit(*cp)) secs = secs * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal seconds */ cp++; if (isdigit(*cp)) { secsfrac = (*cp++ - '0') * 100; if (isdigit(*cp)) { secsfrac += (*cp++ - '0') * 10; if (isdigit(*cp)) { secsfrac += (*cp++ - '0'); } } } } while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) cp++; fndhemi: switch (*cp) { case 'N': case 'n': case 'E': case 'e': retval = ((unsigned)1<<31) + (((((deg * 60) + min) * 60) + secs) * 1000) + secsfrac; break; case 'S': case 's': case 'W': case 'w': retval = ((unsigned)1<<31) - (((((deg * 60) + min) * 60) + secs) * 1000) - secsfrac; break; default: retval = 0; /* invalid value -- indicates error */ break; } switch (*cp) { case 'N': case 'n': case 'S': case 's': *which = 1; /* latitude */ break; case 'E': case 'e': case 'W': case 'w': *which = 2; /* longitude */ break; default: *which = 0; /* error */ break; } cp++; /* skip the hemisphere */ while (!isspace(*cp)) /* if any trailing garbage */ cp++; while (isspace(*cp)) /* move to next field */ cp++; *latlonstrptr = cp; return (retval);}
GEN theta = gmodulcp(gadd(polx[varn(pol)], gmul(k, gmodulcp(polx[varn(T)],T))), pol); return poleval(x, theta);
return poleval(x, get_theta_abstorel(T,pol,k));
eltabstorel(GEN x, GEN T, GEN pol, GEN k){ GEN theta = gmodulcp(gadd(polx[varn(pol)], gmul(k, gmodulcp(polx[varn(T)],T))), pol); return poleval(x, theta);}
mapOverAll(int ismaster, int (*func)(int,int,volatile LERegister *,void*), void *arg)
mapOverAll(volatile LERegister *base, int ismaster, int (*func)(int,int,volatile LERegister *,void*), void *arg)
mapOverAll(int ismaster, int (*func)(int,int,volatile LERegister *,void*), void *arg){#define base vmeUniverse0BaseAddrvolatile LERegister *rptr;unsigned long port;int rval; /* get the universe base address */ if (!base && vmeUniverseInit()) { uprintf(stderr,"unable to find the universe in pci config space\n"); return -1; } rptr = (base + (ismaster ? UNIV_REGOFF_PCITGT0_CTRL : UNIV_REGOFF_VMESLV0_CTRL)/sizeof(LERegister));#undef TSILL#ifdef TSILL uprintf(stderr,"mapoverall: base is 0x%08x, rptr 0x%08x\n",base,rptr);#endif#undef TSILL for (port=0; port<4; port++) { if ((rval=func(ismaster,port,rptr,arg))) return rval; rptr+=5; /* register block spacing */ } /* only rev. 2 has 8 ports */ if (UNIV_REV(base)<2) return -1; rptr = (base + (ismaster ? UNIV_REGOFF_PCITGT4_CTRL : UNIV_REGOFF_VMESLV4_CTRL)/sizeof(LERegister)); for (port=4; port<UNIV_NUM_MPORTS; port++) { if ((rval=func(ismaster,port,rptr,arg))) return rval; rptr+=5; /* register block spacing */ } return 0;#undef base}
if (!base && vmeUniverseInit()) { uprintf(stderr,"unable to find the universe in pci config space\n"); return -1; } rptr = (base +
CHECK_DFLT_BASE(base); rptr = (base +
mapOverAll(int ismaster, int (*func)(int,int,volatile LERegister *,void*), void *arg){#define base vmeUniverse0BaseAddrvolatile LERegister *rptr;unsigned long port;int rval; /* get the universe base address */ if (!base && vmeUniverseInit()) { uprintf(stderr,"unable to find the universe in pci config space\n"); return -1; } rptr = (base + (ismaster ? UNIV_REGOFF_PCITGT0_CTRL : UNIV_REGOFF_VMESLV0_CTRL)/sizeof(LERegister));#undef TSILL#ifdef TSILL uprintf(stderr,"mapoverall: base is 0x%08x, rptr 0x%08x\n",base,rptr);#endif#undef TSILL for (port=0; port<4; port++) { if ((rval=func(ismaster,port,rptr,arg))) return rval; rptr+=5; /* register block spacing */ } /* only rev. 2 has 8 ports */ if (UNIV_REV(base)<2) return -1; rptr = (base + (ismaster ? UNIV_REGOFF_PCITGT4_CTRL : UNIV_REGOFF_VMESLV4_CTRL)/sizeof(LERegister)); for (port=4; port<UNIV_NUM_MPORTS; port++) { if ((rval=func(ismaster,port,rptr,arg))) return rval; rptr+=5; /* register block spacing */ } return 0;#undef base}
n=lx-1; if (n<=1) return lllall_trivial(x,n,flag);
n=lx-1; if (n<=1) return lllall_trivial(x,flag);
lllgramintwithcontent(GEN x, GEN veccon, long flag){ long lx=lg(x), i, j, k, l, n, kmax; gpmem_t av0=avma, av, lim; GEN u,u2,B,lam,q,r,h,la,bb,p1,p2,p3,p4,fl,corr,corr2,newcon; GEN *gptr[8]; if (typ(x) != t_MAT) err(typeer,"lllgramintwithcontent"); n=lx-1; if (n<=1) return lllall_trivial(x,n,flag); if (lg((GEN)x[1])!=lx) err(mattype1,"lllgramintwithcontent"); fl = new_chunk(lx); av=avma; lim=stack_lim(av,1); x=dummycopy(x); veccon=dummycopy(veccon); B=cgetg(lx+1,t_COL); B[1]=un; /* B[i+1]=B_i; le vrai B_i est B_i*prod(1,j=1,i,veccon[j]^2) */ for (i=1; i<lx; i++) { B[i+1]=zero; fl[i]=0; } lam=cgetg(lx,t_MAT); for (j=1; j<lx; j++) { p2=cgetg(lx,t_COL); lam[j]=(long)p2; for (i=1; i<lx; i++) p2[i]=zero; }/* le vrai lam[i,j] est lam[i,j]*veccon[i]*veccon[j]*prod(1,l=1,j-1,veccon[l]^2) */ k=2; h=idmat(n); kmax=1; u=gcoeff(x,1,1); if (typ(u)!=t_INT) err(lllger4); if (signe(u)) { B[2]=(long)u; coeff(lam,1,1)=un; fl[1]=1; } else { B[2]=un; fl[1]=0; } if (DEBUGLEVEL>5) { fprintferr("k = %ld",k); flusherr(); } for(;;) { if (k>kmax) { kmax=k; for (j=1; j<=k; j++) { if (j==k || fl[j]) { u=gcoeff(x,k,j); if (typ(u)!=t_INT) err(lllger4); for (i=1; i<j; i++) if (fl[i]) u=divii(subii(mulii((GEN)B[i+1],u),mulii(gcoeff(lam,k,i),gcoeff(lam,j,i))),(GEN)B[i]); if (j<k) coeff(lam,k,j)=(long)u; else { if (signe(u)) { B[k+1]=(long)u; coeff(lam,k,k)=un; fl[k]=1; } else { B[k+1]=B[k]; fl[k]=0; } } } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } u=shifti(mulii(gcoeff(lam,k,k-1),(GEN)veccon[k]),1); u2=mulii((GEN)B[k],(GEN)veccon[k-1]); if (cmpii(absi(u),u2)>0) { q=dvmdii(addii(u,u2),shifti(u2,1),&r); if (signe(r)<0) q=addsi(-1,q); h[k]=lsub((GEN)h[k],gmul(q,(GEN)h[k-1])); newcon=mppgcd((GEN)veccon[k],(GEN)veccon[k-1]); corr=divii((GEN)veccon[k],newcon); veccon[k]=(long)newcon; if(!gcmp1(corr)) { corr2=sqri(corr); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=lmulii(corr,gcoeff(x,k,j)); coeff(x,k,k)=lmulii(corr,gcoeff(x,k,k)); for (j=k; j<=kmax; j++) B[j+1]=lmulii(corr2,(GEN)B[j+1]); for (i=1; i<k; i++) coeff(lam,k,i)=lmulii(corr,gcoeff(lam,k,i)); for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=lmulii(corr,gcoeff(lam,i,k)); for (j=k+1; j<i; j++) coeff(lam,i,j)=lmulii(corr2,gcoeff(lam,i,j)); } } r=negi(mulii(q,divii((GEN)veccon[k-1],(GEN)veccon[k]))); p1=gcoeff(x,k,k-1); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=laddii(gcoeff(x,j,k),mulii(r,(j==k)?p1:gcoeff(x,j,k-1))); coeff(x,k,k)=laddii(gcoeff(x,k,k),mulii(r,gcoeff(x,k-1,k))); coeff(lam,k,k-1)=laddii(gcoeff(lam,k,k-1),mulii(r,(GEN)B[k])); for (i=1; i<k-1; i++) coeff(lam,k,i)=laddii(gcoeff(lam,k,i),mulii(r,gcoeff(lam,k-1,i))); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } p3=mulii((GEN)B[k-1],(GEN)B[k+1]);la=gcoeff(lam,k,k-1);p4=mulii(la,la); p2=mulsi(100,mulii(mulii((GEN)veccon[k],(GEN)veccon[k]),addii(p3,p4))); p1=mulii((GEN)veccon[k-1],(GEN)B[k]);p1=mulsi(99,mulii(p1,p1)); if (fl[k-1] && (cmpii(p1,p2)>0 || !fl[k])) { if (DEBUGLEVEL>=4 && k==n) { fprintferr(" (%ld)", expi(p1)-expi(p2)); flusherr(); } p1=(GEN)h[k-1]; h[k-1]=h[k]; h[k]=(long)p1; p1=(GEN)x[k-1]; x[k-1]=x[k]; x[k]=(long)p1; for (j=1; j<=n; j++) { p1=gcoeff(x,k-1,j); coeff(x,k-1,j)=coeff(x,k,j); coeff(x,k,j)=(long)p1; } p1=(GEN)veccon[k-1]; veccon[k-1]=veccon[k]; veccon[k]=(long)p1; for (j=1; j<=k-2; j++) { p1=gcoeff(lam,k-1,j); coeff(lam,k-1,j)=coeff(lam,k,j); coeff(lam,k,j)=(long)p1; } if (fl[k]) { for (i=k+1; i<=kmax; i++) { bb=gcoeff(lam,i,k); coeff(lam,i,k)=ldivii(subii(mulii((GEN)B[k+1],gcoeff(lam,i,k-1)),mulii(la,bb)),(GEN)B[k]); coeff(lam,i,k-1)=ldivii(addii(mulii(la,gcoeff(lam,i,k-1)),mulii((GEN)B[k-1],bb)),(GEN)B[k]); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[3]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&la; gptr[5]=&veccon; gptr[6]=&p3; gptr[7]=&p4; gerepilemany(av,gptr,8); } } B[k]=ldivii(addii(p3,p4),(GEN)B[k]); } else { if (signe(la)) { p2=(GEN)B[k]; p1=divii(p4,p2); for (i=k+1; i<=kmax; i++) coeff(lam,i,k-1)=ldivii(mulii(la,gcoeff(lam,i,k-1)),p2); for (j=k+1; j<kmax; j++) { for (i=j+1; i<=kmax; i++) coeff(lam,i,j)=ldivii(mulii(p1,gcoeff(lam,i,j)),p2); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[4]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&la; gptr[5]=&veccon; gptr[6]=&p1; gptr[7]=&p2; gerepilemany(av,gptr,8); } } B[k+1]=B[k]=(long)p1; for (i=k+2; i<=lx; i++) B[i]=ldivii(mulii(p1,(GEN)B[i]),p2); } else { coeff(lam,k,k-1)=zero; for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=coeff(lam,i,k-1); coeff(lam,i,k-1)=zero; } B[k]=B[k-1]; fl[k]=1; fl[k-1]=0; } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[5]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } if (k>2) k--; if (DEBUGLEVEL>5) { fprintferr(" %ld",k); flusherr(); } } else { for (l=k-2; l>=1; l--) { u=shifti(mulii(gcoeff(lam,k,l),(GEN)veccon[k]),1); u2=mulii((GEN)B[l+1],(GEN)veccon[l]); if (cmpii(absi(u),u2)>0) { q=dvmdii(addii(u,u2),shifti(u2,1),&r); if (signe(r)<0) q=addsi(-1,q); h[k]=lsub((GEN)h[k],gmul(q,(GEN)h[l])); newcon=mppgcd((GEN)veccon[k],(GEN)veccon[l]); corr=divii((GEN)veccon[k],newcon); veccon[k]=(long)newcon; if(!gcmp1(corr)) { corr2=sqri(corr); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=lmulii(corr,gcoeff(x,k,j)); coeff(x,k,k)=lmulii(corr,gcoeff(x,k,k)); for (j=k; j<=kmax; j++) B[j+1]=lmulii(corr2,(GEN)B[j+1]); for (i=1; i<k; i++) coeff(lam,k,i)=lmulii(corr,gcoeff(lam,k,i)); for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=lmulii(corr,gcoeff(lam,i,k)); for (j=k+1; j<i; j++) coeff(lam,i,j)=lmulii(corr2,gcoeff(lam,i,j)); } } r=negi(mulii(q,divii((GEN)veccon[l],(GEN)veccon[k]))); p1=gcoeff(x,k,l); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=laddii(gcoeff(x,j,k),mulii(r,(j==k)?p1:gcoeff(x,j,l))); coeff(x,k,k)=laddii(gcoeff(x,k,k),mulii(r,gcoeff(x,l,k))); coeff(lam,k,l)=laddii(gcoeff(lam,k,l),mulii(r,(GEN)B[l+1])); for (i=1; i<l; i++) coeff(lam,k,i)=laddii(gcoeff(lam,k,i),mulii(r,gcoeff(lam,l,i))); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[6]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } k++; if (DEBUGLEVEL>5) { fprintferr(" %ld",k); flusherr(); } if (k>n) { if (DEBUGLEVEL>5) { fprintferr("\n"); flusherr(); } return gerepilecopy(av0, lllgramall_finish(h,fl,flag,n)); } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[7]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } }}
return gerepilecopy(av0, lllgramall_finish(h,fl,flag,n));
return gerepilecopy(av0, lllgramall_finish(h,fl,flag));
lllgramintwithcontent(GEN x, GEN veccon, long flag){ long lx=lg(x), i, j, k, l, n, kmax; gpmem_t av0=avma, av, lim; GEN u,u2,B,lam,q,r,h,la,bb,p1,p2,p3,p4,fl,corr,corr2,newcon; GEN *gptr[8]; if (typ(x) != t_MAT) err(typeer,"lllgramintwithcontent"); n=lx-1; if (n<=1) return lllall_trivial(x,n,flag); if (lg((GEN)x[1])!=lx) err(mattype1,"lllgramintwithcontent"); fl = new_chunk(lx); av=avma; lim=stack_lim(av,1); x=dummycopy(x); veccon=dummycopy(veccon); B=cgetg(lx+1,t_COL); B[1]=un; /* B[i+1]=B_i; le vrai B_i est B_i*prod(1,j=1,i,veccon[j]^2) */ for (i=1; i<lx; i++) { B[i+1]=zero; fl[i]=0; } lam=cgetg(lx,t_MAT); for (j=1; j<lx; j++) { p2=cgetg(lx,t_COL); lam[j]=(long)p2; for (i=1; i<lx; i++) p2[i]=zero; }/* le vrai lam[i,j] est lam[i,j]*veccon[i]*veccon[j]*prod(1,l=1,j-1,veccon[l]^2) */ k=2; h=idmat(n); kmax=1; u=gcoeff(x,1,1); if (typ(u)!=t_INT) err(lllger4); if (signe(u)) { B[2]=(long)u; coeff(lam,1,1)=un; fl[1]=1; } else { B[2]=un; fl[1]=0; } if (DEBUGLEVEL>5) { fprintferr("k = %ld",k); flusherr(); } for(;;) { if (k>kmax) { kmax=k; for (j=1; j<=k; j++) { if (j==k || fl[j]) { u=gcoeff(x,k,j); if (typ(u)!=t_INT) err(lllger4); for (i=1; i<j; i++) if (fl[i]) u=divii(subii(mulii((GEN)B[i+1],u),mulii(gcoeff(lam,k,i),gcoeff(lam,j,i))),(GEN)B[i]); if (j<k) coeff(lam,k,j)=(long)u; else { if (signe(u)) { B[k+1]=(long)u; coeff(lam,k,k)=un; fl[k]=1; } else { B[k+1]=B[k]; fl[k]=0; } } } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } u=shifti(mulii(gcoeff(lam,k,k-1),(GEN)veccon[k]),1); u2=mulii((GEN)B[k],(GEN)veccon[k-1]); if (cmpii(absi(u),u2)>0) { q=dvmdii(addii(u,u2),shifti(u2,1),&r); if (signe(r)<0) q=addsi(-1,q); h[k]=lsub((GEN)h[k],gmul(q,(GEN)h[k-1])); newcon=mppgcd((GEN)veccon[k],(GEN)veccon[k-1]); corr=divii((GEN)veccon[k],newcon); veccon[k]=(long)newcon; if(!gcmp1(corr)) { corr2=sqri(corr); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=lmulii(corr,gcoeff(x,k,j)); coeff(x,k,k)=lmulii(corr,gcoeff(x,k,k)); for (j=k; j<=kmax; j++) B[j+1]=lmulii(corr2,(GEN)B[j+1]); for (i=1; i<k; i++) coeff(lam,k,i)=lmulii(corr,gcoeff(lam,k,i)); for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=lmulii(corr,gcoeff(lam,i,k)); for (j=k+1; j<i; j++) coeff(lam,i,j)=lmulii(corr2,gcoeff(lam,i,j)); } } r=negi(mulii(q,divii((GEN)veccon[k-1],(GEN)veccon[k]))); p1=gcoeff(x,k,k-1); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=laddii(gcoeff(x,j,k),mulii(r,(j==k)?p1:gcoeff(x,j,k-1))); coeff(x,k,k)=laddii(gcoeff(x,k,k),mulii(r,gcoeff(x,k-1,k))); coeff(lam,k,k-1)=laddii(gcoeff(lam,k,k-1),mulii(r,(GEN)B[k])); for (i=1; i<k-1; i++) coeff(lam,k,i)=laddii(gcoeff(lam,k,i),mulii(r,gcoeff(lam,k-1,i))); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } p3=mulii((GEN)B[k-1],(GEN)B[k+1]);la=gcoeff(lam,k,k-1);p4=mulii(la,la); p2=mulsi(100,mulii(mulii((GEN)veccon[k],(GEN)veccon[k]),addii(p3,p4))); p1=mulii((GEN)veccon[k-1],(GEN)B[k]);p1=mulsi(99,mulii(p1,p1)); if (fl[k-1] && (cmpii(p1,p2)>0 || !fl[k])) { if (DEBUGLEVEL>=4 && k==n) { fprintferr(" (%ld)", expi(p1)-expi(p2)); flusherr(); } p1=(GEN)h[k-1]; h[k-1]=h[k]; h[k]=(long)p1; p1=(GEN)x[k-1]; x[k-1]=x[k]; x[k]=(long)p1; for (j=1; j<=n; j++) { p1=gcoeff(x,k-1,j); coeff(x,k-1,j)=coeff(x,k,j); coeff(x,k,j)=(long)p1; } p1=(GEN)veccon[k-1]; veccon[k-1]=veccon[k]; veccon[k]=(long)p1; for (j=1; j<=k-2; j++) { p1=gcoeff(lam,k-1,j); coeff(lam,k-1,j)=coeff(lam,k,j); coeff(lam,k,j)=(long)p1; } if (fl[k]) { for (i=k+1; i<=kmax; i++) { bb=gcoeff(lam,i,k); coeff(lam,i,k)=ldivii(subii(mulii((GEN)B[k+1],gcoeff(lam,i,k-1)),mulii(la,bb)),(GEN)B[k]); coeff(lam,i,k-1)=ldivii(addii(mulii(la,gcoeff(lam,i,k-1)),mulii((GEN)B[k-1],bb)),(GEN)B[k]); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[3]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&la; gptr[5]=&veccon; gptr[6]=&p3; gptr[7]=&p4; gerepilemany(av,gptr,8); } } B[k]=ldivii(addii(p3,p4),(GEN)B[k]); } else { if (signe(la)) { p2=(GEN)B[k]; p1=divii(p4,p2); for (i=k+1; i<=kmax; i++) coeff(lam,i,k-1)=ldivii(mulii(la,gcoeff(lam,i,k-1)),p2); for (j=k+1; j<kmax; j++) { for (i=j+1; i<=kmax; i++) coeff(lam,i,j)=ldivii(mulii(p1,gcoeff(lam,i,j)),p2); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[4]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&la; gptr[5]=&veccon; gptr[6]=&p1; gptr[7]=&p2; gerepilemany(av,gptr,8); } } B[k+1]=B[k]=(long)p1; for (i=k+2; i<=lx; i++) B[i]=ldivii(mulii(p1,(GEN)B[i]),p2); } else { coeff(lam,k,k-1)=zero; for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=coeff(lam,i,k-1); coeff(lam,i,k-1)=zero; } B[k]=B[k-1]; fl[k]=1; fl[k-1]=0; } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[5]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } if (k>2) k--; if (DEBUGLEVEL>5) { fprintferr(" %ld",k); flusherr(); } } else { for (l=k-2; l>=1; l--) { u=shifti(mulii(gcoeff(lam,k,l),(GEN)veccon[k]),1); u2=mulii((GEN)B[l+1],(GEN)veccon[l]); if (cmpii(absi(u),u2)>0) { q=dvmdii(addii(u,u2),shifti(u2,1),&r); if (signe(r)<0) q=addsi(-1,q); h[k]=lsub((GEN)h[k],gmul(q,(GEN)h[l])); newcon=mppgcd((GEN)veccon[k],(GEN)veccon[l]); corr=divii((GEN)veccon[k],newcon); veccon[k]=(long)newcon; if(!gcmp1(corr)) { corr2=sqri(corr); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=lmulii(corr,gcoeff(x,k,j)); coeff(x,k,k)=lmulii(corr,gcoeff(x,k,k)); for (j=k; j<=kmax; j++) B[j+1]=lmulii(corr2,(GEN)B[j+1]); for (i=1; i<k; i++) coeff(lam,k,i)=lmulii(corr,gcoeff(lam,k,i)); for (i=k+1; i<=kmax; i++) { coeff(lam,i,k)=lmulii(corr,gcoeff(lam,i,k)); for (j=k+1; j<i; j++) coeff(lam,i,j)=lmulii(corr2,gcoeff(lam,i,j)); } } r=negi(mulii(q,divii((GEN)veccon[l],(GEN)veccon[k]))); p1=gcoeff(x,k,l); for (j=1; j<=n; j++) coeff(x,j,k)=coeff(x,k,j)=laddii(gcoeff(x,j,k),mulii(r,(j==k)?p1:gcoeff(x,j,l))); coeff(x,k,k)=laddii(gcoeff(x,k,k),mulii(r,gcoeff(x,l,k))); coeff(lam,k,l)=laddii(gcoeff(lam,k,l),mulii(r,(GEN)B[l+1])); for (i=1; i<l; i++) coeff(lam,k,i)=laddii(gcoeff(lam,k,i),mulii(r,gcoeff(lam,l,i))); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[6]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } } k++; if (DEBUGLEVEL>5) { fprintferr(" %ld",k); flusherr(); } if (k>n) { if (DEBUGLEVEL>5) { fprintferr("\n"); flusherr(); } return gerepilecopy(av0, lllgramall_finish(h,fl,flag,n)); } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[7]: lllgramintwithcontent"); gptr[0]=&B; gptr[1]=&lam; gptr[2]=&h; gptr[3]=&x; gptr[4]=&veccon; gerepilemany(av,gptr,5); } }}
if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case: ");
if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n");
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); gpmem_t av,tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { y[1] = lcopy(gcoeff(x,1,1)); y[2] = lcopy((GEN)x[2]); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gun; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { y[1] = lpilecopy(av,cx); y[2] = (long)gscalcol(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { GEN t, y = eltmul_get_table(nf, (GEN)x[i]); t = gmod(y, xZ); if (gcmp0(t)) continue; if (ok_elt(x,xZ, t)) { a = (GEN)x[i]; break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ mul[lm] = (long)t; lm++; } if (i>N) { GEN z = cgetg(lm, t_VECSMALL); gpmem_t av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case: "); for(av1=avma;;avma=av1) { c++; if (DEBUGLEVEL>3 && (c & 0x3f) == 0) fprintferr("%ld ", c); if (c == 100) { a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = (mymyrand() >> (BITS_IN_RANDOM-5)) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, (GEN)mul[i]); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], (GEN)beta[i]); if (DEBUGLEVEL>3) fprintferr("\n"); }END: a = centermod(a, xZ); tetpil = avma; y[1] = lmul(xZ,cx); y[2] = lmul(a, cx); gerepilemanyvec(av,tetpil,y+1,2); return y;}
c++; if (DEBUGLEVEL>3 && (c & 0x3f) == 0) fprintferr("%ld ", c); if (c == 100) { a = mat_ideal_two_elt2(nf, x, xZ); goto END; }
if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; }
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); gpmem_t av,tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { y[1] = lcopy(gcoeff(x,1,1)); y[2] = lcopy((GEN)x[2]); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gun; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { y[1] = lpilecopy(av,cx); y[2] = (long)gscalcol(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { GEN t, y = eltmul_get_table(nf, (GEN)x[i]); t = gmod(y, xZ); if (gcmp0(t)) continue; if (ok_elt(x,xZ, t)) { a = (GEN)x[i]; break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ mul[lm] = (long)t; lm++; } if (i>N) { GEN z = cgetg(lm, t_VECSMALL); gpmem_t av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case: "); for(av1=avma;;avma=av1) { c++; if (DEBUGLEVEL>3 && (c & 0x3f) == 0) fprintferr("%ld ", c); if (c == 100) { a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = (mymyrand() >> (BITS_IN_RANDOM-5)) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, (GEN)mul[i]); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], (GEN)beta[i]); if (DEBUGLEVEL>3) fprintferr("\n"); }END: a = centermod(a, xZ); tetpil = avma; y[1] = lmul(xZ,cx); y[2] = lmul(a, cx); gerepilemanyvec(av,tetpil,y+1,2); return y;}
if (DEBUGLEVEL>3) fprintferr("\n");
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); gpmem_t av,tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { y[1] = lcopy(gcoeff(x,1,1)); y[2] = lcopy((GEN)x[2]); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gun; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { y[1] = lpilecopy(av,cx); y[2] = (long)gscalcol(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { GEN t, y = eltmul_get_table(nf, (GEN)x[i]); t = gmod(y, xZ); if (gcmp0(t)) continue; if (ok_elt(x,xZ, t)) { a = (GEN)x[i]; break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ mul[lm] = (long)t; lm++; } if (i>N) { GEN z = cgetg(lm, t_VECSMALL); gpmem_t av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case: "); for(av1=avma;;avma=av1) { c++; if (DEBUGLEVEL>3 && (c & 0x3f) == 0) fprintferr("%ld ", c); if (c == 100) { a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = (mymyrand() >> (BITS_IN_RANDOM-5)) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, (GEN)mul[i]); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], (GEN)beta[i]); if (DEBUGLEVEL>3) fprintferr("\n"); }END: a = centermod(a, xZ); tetpil = avma; y[1] = lmul(xZ,cx); y[2] = lmul(a, cx); gerepilemanyvec(av,tetpil,y+1,2); return y;}
lllgramall_finish(GEN h,GEN fl,long flag,long n)
lllgramall_finish(GEN h,GEN fl,long flag)
lllgramall_finish(GEN h,GEN fl,long flag,long n){ long i, k; GEN y, g; k=1; while (k<=n && !fl[k]) k++; switch(flag) { case lll_KER: setlg(h,k); return h; case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); return h; } y = cgetg(3,t_VEC); g = cgetg(k, t_MAT); for (i=1; i<k; i++) g[i] = h[i]; y[1] = (long)g; h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); y[2] = (long)h; return y;}
long i, k;
long i, k, l = lg(fl);
lllgramall_finish(GEN h,GEN fl,long flag,long n){ long i, k; GEN y, g; k=1; while (k<=n && !fl[k]) k++; switch(flag) { case lll_KER: setlg(h,k); return h; case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); return h; } y = cgetg(3,t_VEC); g = cgetg(k, t_MAT); for (i=1; i<k; i++) g[i] = h[i]; y[1] = (long)g; h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); y[2] = (long)h; return y;}
k=1; while (k<=n && !fl[k]) k++;
k=1; while (k<l && !fl[k]) k++;
lllgramall_finish(GEN h,GEN fl,long flag,long n){ long i, k; GEN y, g; k=1; while (k<=n && !fl[k]) k++; switch(flag) { case lll_KER: setlg(h,k); return h; case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); return h; } y = cgetg(3,t_VEC); g = cgetg(k, t_MAT); for (i=1; i<k; i++) g[i] = h[i]; y[1] = (long)g; h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); y[2] = (long)h; return y;}
case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2);
case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(l-k+1);
lllgramall_finish(GEN h,GEN fl,long flag,long n){ long i, k; GEN y, g; k=1; while (k<=n && !fl[k]) k++; switch(flag) { case lll_KER: setlg(h,k); return h; case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); return h; } y = cgetg(3,t_VEC); g = cgetg(k, t_MAT); for (i=1; i<k; i++) g[i] = h[i]; y[1] = (long)g; h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); y[2] = (long)h; return y;}
h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2);
h += k-1; h[0] = evaltyp(t_MAT)| evallg(l-k+1);
lllgramall_finish(GEN h,GEN fl,long flag,long n){ long i, k; GEN y, g; k=1; while (k<=n && !fl[k]) k++; switch(flag) { case lll_KER: setlg(h,k); return h; case lll_IM: h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); return h; } y = cgetg(3,t_VEC); g = cgetg(k, t_MAT); for (i=1; i<k; i++) g[i] = h[i]; y[1] = (long)g; h += k-1; h[0] = evaltyp(t_MAT)| evallg(n-k+2); y[2] = (long)h; return y;}
asize = (1 + Xmin)*cache_arena - fixed_to_cache;
asize = (ulong)((1 + Xmin)*cache_arena - fixed_to_cache);
good_arena_size(ulong slow2_size, ulong total, ulong fixed_to_cache, cache_model_t *cache_model, long model_type){ ulong asize, cache_arena = cache_model->arena; double Xmin, Xmax, A, B, C1, C2, D, V; double alpha = cache_model->power, cut_off = cache_model->cutoff; /* Estimated relative slowdown, with overhead = max((fixed_to_cache+arena)/cache_arena - 1, 0): 1 + slow2_size/arena due to initialization overhead; max(1, 2.33 * overhead^0.29 ) due to footprint > cache size. [The latter is hard to substantiate theoretically, but this function describes benchmarks pretty close; it does not hurt that one can minimize it explicitly too ;-). The switch between diffenent choices of max() happens whe overhead=0.055.] Thus the problem is minimizing (1 + slow2_size/arena)*overhead**0.29. This boils down to F=((X+A)/(X+B))X^alpha, X=overhead, B = (1 - fixed_to_cache/cache_arena), A = B + slow2_size/cache_arena, alpha = 0.29, and X>=0.055, X>-B. It turns out that the minimization problem is not very nasty. (As usual with minimization problems which depend on parameters, different values of A,B lead to different algorithms. However, the boundaries between the domains in (A,B) plane where different algorithms work are explicitly calculatable.) Thus we need to find the rightmost root of (X+A)*(X+B) - alpha(A-B)X to the right of 0.055 (if such exists and is below Xmax). Then we manually check the remaining region [0, 0.055]. Since we cannot trust the purely-experimental cache-hit slowdown function, as a sanity check always prefer fitting into the cache (or "almost fitting") if F-law predicts that the larger value of the arena provides less than 10% speedup. */ if (model_type != 0) err(talker, "unsupported type of cache model"); /* Future expansion */ /* The simplest case: we fit into cache */ if (total + fixed_to_cache <= cache_arena) return total; /* The simple case: fitting into cache doesn't slow us down more than 10% */ if (cache_arena - fixed_to_cache > 10 * slow2_size) { asize = cache_arena - fixed_to_cache; if (asize > total) asize = total; /* Automatically false... */ return asize; } /* Slowdown of not fitting into cache is significant. Try to optimize. Do not be afraid to spend some time on optimization - in trivial cases we do not reach this point; any gain we get should compensate the time spent on optimization. */ B = (1 - ((double)fixed_to_cache)/cache_arena); A = B + ((double)slow2_size)/cache_arena; C2 = A*B; C1 = (A + B - 1/alpha*(A - B))/2; D = C1*C1 - C2; if (D > 0) V = cut_off*cut_off + 2*C1*cut_off + C2; /* Value at CUT_OFF */ else V = 0; /* Peacify the warning */ Xmin = cut_off; Xmax = ((double)total - fixed_to_cache)/cache_arena; /* Two candidates */ if ( D <= 0 || (V >= 0 && C1 + cut_off >= 0) ) /* slowdown increasing */ Xmax = cut_off; /* Only one candidate */ else if (V >= 0 && /* slowdown concave down */ ((Xmax + C1) <= 0 || (Xmax*Xmax + 2*C1*Xmax + C2) <= 0)) /* DO NOTHING */; /* Keep both candidates */ else if (V <= 0 && (Xmax*Xmax + 2*C1*Xmax + C2) <= 0) /* slowdown decreasing */ Xmin = cut_off; /* Only one candidate */ else /* Now we know: two root, the largest is in CUT_OFF..Xmax */ Xmax = sqrt(D) - C1; if (Xmax != Xmin) { /* Xmin == CUT_OFF; Check which one is better */ double v1 = (cut_off + A)/(cut_off + B); double v2 = 2.33 * (Xmax + A)/(Xmax + B) * pow(Xmax, alpha); if (1.1 * v2 >= v1) /* Prefer fitting into the cache if slowdown < 10% */ V = v1; else { Xmin = Xmax; V = v2; } } else if (B > 0) /* We need V */ V = 2.33 * (Xmin + A)/(Xmin + B) * pow(Xmin, alpha); if (B > 0 && 1.1 * V > A/B) /* Now Xmin is the minumum. Compare with 0 */ Xmin = 0; asize = (1 + Xmin)*cache_arena - fixed_to_cache; if (asize > total) asize = total; /* May happen due to approximations */ return asize;}
lllall_trivial(GEN x, long n, long flag)
lllall_trivial(GEN x, long flag)
lllall_trivial(GEN x, long n, long flag){ GEN y; if (!n) { if (flag != lll_ALL) return cgetg(1,t_MAT); y=cgetg(3,t_VEC); y[1]=lgetg(1,t_MAT); y[2]=lgetg(1,t_MAT); return y; } /* here n = 1 */ if (gcmp0((GEN)x[1])) { switch(flag ^ lll_GRAM) { case lll_KER: return idmat(1); case lll_IM : return cgetg(1,t_MAT); default: y=cgetg(3,t_VEC); y[1]=(long)idmat(1); y[2]=lgetg(1,t_MAT); return y; } } if (flag & lll_GRAM) flag ^= lll_GRAM; else x = NULL; switch (flag) { case lll_KER: return cgetg(1,t_MAT); case lll_IM : return idmat(1); default: y=cgetg(3,t_VEC); y[1]=lgetg(1,t_MAT); y[2]=x? lcopy(x): (long)idmat(1); return y; }}
if (!n) {
if (lg(x) == 1) {
lllall_trivial(GEN x, long n, long flag){ GEN y; if (!n) { if (flag != lll_ALL) return cgetg(1,t_MAT); y=cgetg(3,t_VEC); y[1]=lgetg(1,t_MAT); y[2]=lgetg(1,t_MAT); return y; } /* here n = 1 */ if (gcmp0((GEN)x[1])) { switch(flag ^ lll_GRAM) { case lll_KER: return idmat(1); case lll_IM : return cgetg(1,t_MAT); default: y=cgetg(3,t_VEC); y[1]=(long)idmat(1); y[2]=lgetg(1,t_MAT); return y; } } if (flag & lll_GRAM) flag ^= lll_GRAM; else x = NULL; switch (flag) { case lll_KER: return cgetg(1,t_MAT); case lll_IM : return idmat(1); default: y=cgetg(3,t_VEC); y[1]=lgetg(1,t_MAT); y[2]=x? lcopy(x): (long)idmat(1); return y; }}
void pci_initialize()
int pci_initialize()
void pci_initialize(){ int PciNumber; unchar ucBusNumber, ucSlotNumber, ucFnNumber, ucNumFuncs; unsigned int ulHeader; unsigned int pcidata, ulDeviceID;#if PCI_DEBUG unsigned int data, pcidata, ulClass; unsigned short sdata;#endif PCI_interface(); /* * Scan PCI0 and PCI1 bus0 */ for (PciNumber=0; PciNumber < 2; PciNumber++) { pciAccessInit(PciNumber); for (ucBusNumber=0; ucBusNumber< 2; ucBusNumber++) { for (ucSlotNumber=0;ucSlotNumber<PCI_MAX_DEVICES;ucSlotNumber++) { ucFnNumber = 0; PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_VENDOR_ID, &ulDeviceID); if( ulDeviceID==PCI_INVALID_VENDORDEVICEID) { /* This slot is empty */ continue; } if (++numPCIDevs > MAX_NUM_PCI_DEVICES) { BSP_panic("Too many PCI devices found; increase MAX_NUM_PCI_DEVICES in pcicache.c\n"); } switch(ulDeviceID) { case (PCI_VENDOR_ID_MARVELL+(PCI_DEVICE_ID_MARVELL_GT6426xAB<<16)):#if PCI_PRINT printk("Marvell GT6426xA/B hostbridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case (PCI_VENDOR_ID_PLX2+(PCI_DEVICE_ID_PLX2_PCI6154_HB2<<16)):#if PCI_PRINT printk("PLX PCI6154 PCI-PCI bridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case PCI_VENDOR_ID_TUNDRA:#if PCI_PRINT printk("TUNDRA PCI-VME bridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case (PCI_VENDOR_ID_INTEL+(PCI_DEVICE_INTEL_82544EI_COPPER<<16)):#if PCI_PRINT printk("INTEL 82544EI COPPER network controller detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; default : #if PCI_PRINT printk("PCI%d Bus%d Slot%d DeviceID 0x%x \n", PciNumber,ucBusNumber,ucSlotNumber, ulDeviceID);#endif break; }#if PCI_DEBUG PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_0, &data); printk("PCI%d_BASE_ADDRESS_0 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_1, &data); printk("PCI%d_BASE_ADDRESS_1 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_2, &data); printk("PCI%d_BASE_ADDRESS_2 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_3, &data); printk("PCI%d_BASE_ADDRESS_3 0x%x \n",PciNumber, data); PCIx_read_config_word(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_INTERRUPT_LINE, &sdata); printk("PCI%d_INTERRUPT_LINE 0x%x \n",PciNumber, sdata); /* We always enable internal memory. */ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_MEM_BASE_ADDR, &pcidata); printk("PCI%d_MEM_BASE_ADDR 0x%x \n", PciNumber,pcidata); /* We always enable internal IO. */ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_IO_BASE_ADDR, &pcidata); printk("PCI%d_IO_BASE_ADDR 0x%x \n", PciNumber,pcidata);#endif PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_CACHE_LINE_SIZE, &ulHeader); if ((ulHeader>>16)&PCI_MULTI_FUNCTION) ucNumFuncs=PCI_MAX_FUNCTIONS; else ucNumFuncs=1;#if PCI_DEBUG printk("PCI%d Slot 0x%x HEADER/LAT/CACHE 0x%x \n", PciNumber,ucSlotNumber, ulHeader); for (ucFnNumber=1;ucFnNumber<ucNumFuncs;ucFnNumber++) { PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, ucFnNumber, PCI0_VENDOR_ID, &ulDeviceID); if (ulDeviceID==PCI_INVALID_VENDORDEVICEID) { /* This slot/function is empty */ continue; } if (++numPCIDevs > MAX_NUM_PCI_DEVICES) { BSP_panic("Too many PCI devices found; increase MAX_NUM_PCI_DEVICES in pcicache.c\n"); } /* This slot/function has a device fitted.*/ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, ucFnNumber, PCI0_CLASS_REVISION, &ulClass); printk("PCI%d Slot 0x%x Func %d classID 0x%x \n",PciNumber,ucSlotNumber, ucFnNumber, ulClass); ulClass >>= 16; if (ulClass == PCI_CLASS_GT6426xAB) printk("GT64260-PCI%d bridge found \n", PciNumber); }#endif PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, &pcidata); #if PCI_DEBUG printk("MOTLoad command staus 0x%x, ", pcidata);#endif /* Clear the error on the host bridge */ if ( (ucBusNumber==0) && (ucSlotNumber==0)) pcidata |= PCI_STATUS_CLRERR_MASK; /* Enable bus,I/O and memory master access. */ pcidata |= (PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY); PCIx_write_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, pcidata); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, &pcidata); #if PCI_DEBUG printk("Now command/staus 0x%x\n", pcidata);#endif } } } /* PCI number */}
return PCIB_ERR_SUCCESS;
void pci_initialize(){ int PciNumber; unchar ucBusNumber, ucSlotNumber, ucFnNumber, ucNumFuncs; unsigned int ulHeader; unsigned int pcidata, ulDeviceID;#if PCI_DEBUG unsigned int data, pcidata, ulClass; unsigned short sdata;#endif PCI_interface(); /* * Scan PCI0 and PCI1 bus0 */ for (PciNumber=0; PciNumber < 2; PciNumber++) { pciAccessInit(PciNumber); for (ucBusNumber=0; ucBusNumber< 2; ucBusNumber++) { for (ucSlotNumber=0;ucSlotNumber<PCI_MAX_DEVICES;ucSlotNumber++) { ucFnNumber = 0; PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_VENDOR_ID, &ulDeviceID); if( ulDeviceID==PCI_INVALID_VENDORDEVICEID) { /* This slot is empty */ continue; } if (++numPCIDevs > MAX_NUM_PCI_DEVICES) { BSP_panic("Too many PCI devices found; increase MAX_NUM_PCI_DEVICES in pcicache.c\n"); } switch(ulDeviceID) { case (PCI_VENDOR_ID_MARVELL+(PCI_DEVICE_ID_MARVELL_GT6426xAB<<16)):#if PCI_PRINT printk("Marvell GT6426xA/B hostbridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case (PCI_VENDOR_ID_PLX2+(PCI_DEVICE_ID_PLX2_PCI6154_HB2<<16)):#if PCI_PRINT printk("PLX PCI6154 PCI-PCI bridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case PCI_VENDOR_ID_TUNDRA:#if PCI_PRINT printk("TUNDRA PCI-VME bridge detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; case (PCI_VENDOR_ID_INTEL+(PCI_DEVICE_INTEL_82544EI_COPPER<<16)):#if PCI_PRINT printk("INTEL 82544EI COPPER network controller detected at PCI%d bus%d slot%d\n", PciNumber,ucBusNumber,ucSlotNumber);#endif ucMaxPCIBus ++; break; default : #if PCI_PRINT printk("PCI%d Bus%d Slot%d DeviceID 0x%x \n", PciNumber,ucBusNumber,ucSlotNumber, ulDeviceID);#endif break; }#if PCI_DEBUG PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_0, &data); printk("PCI%d_BASE_ADDRESS_0 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_1, &data); printk("PCI%d_BASE_ADDRESS_1 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_2, &data); printk("PCI%d_BASE_ADDRESS_2 0x%x \n",PciNumber, data); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_BASE_ADDRESS_3, &data); printk("PCI%d_BASE_ADDRESS_3 0x%x \n",PciNumber, data); PCIx_read_config_word(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_INTERRUPT_LINE, &sdata); printk("PCI%d_INTERRUPT_LINE 0x%x \n",PciNumber, sdata); /* We always enable internal memory. */ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_MEM_BASE_ADDR, &pcidata); printk("PCI%d_MEM_BASE_ADDR 0x%x \n", PciNumber,pcidata); /* We always enable internal IO. */ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_IO_BASE_ADDR, &pcidata); printk("PCI%d_IO_BASE_ADDR 0x%x \n", PciNumber,pcidata);#endif PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_CACHE_LINE_SIZE, &ulHeader); if ((ulHeader>>16)&PCI_MULTI_FUNCTION) ucNumFuncs=PCI_MAX_FUNCTIONS; else ucNumFuncs=1;#if PCI_DEBUG printk("PCI%d Slot 0x%x HEADER/LAT/CACHE 0x%x \n", PciNumber,ucSlotNumber, ulHeader); for (ucFnNumber=1;ucFnNumber<ucNumFuncs;ucFnNumber++) { PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, ucFnNumber, PCI0_VENDOR_ID, &ulDeviceID); if (ulDeviceID==PCI_INVALID_VENDORDEVICEID) { /* This slot/function is empty */ continue; } if (++numPCIDevs > MAX_NUM_PCI_DEVICES) { BSP_panic("Too many PCI devices found; increase MAX_NUM_PCI_DEVICES in pcicache.c\n"); } /* This slot/function has a device fitted.*/ PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, ucFnNumber, PCI0_CLASS_REVISION, &ulClass); printk("PCI%d Slot 0x%x Func %d classID 0x%x \n",PciNumber,ucSlotNumber, ucFnNumber, ulClass); ulClass >>= 16; if (ulClass == PCI_CLASS_GT6426xAB) printk("GT64260-PCI%d bridge found \n", PciNumber); }#endif PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, &pcidata); #if PCI_DEBUG printk("MOTLoad command staus 0x%x, ", pcidata);#endif /* Clear the error on the host bridge */ if ( (ucBusNumber==0) && (ucSlotNumber==0)) pcidata |= PCI_STATUS_CLRERR_MASK; /* Enable bus,I/O and memory master access. */ pcidata |= (PCI_COMMAND_MASTER|PCI_COMMAND_IO|PCI_COMMAND_MEMORY); PCIx_write_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, pcidata); PCIx_read_config_dword(PciNumber, ucBusNumber, ucSlotNumber, 0, PCI0_COMMAND, &pcidata); #if PCI_DEBUG printk("Now command/staus 0x%x\n", pcidata);#endif } } } /* PCI number */}
p_sqrtu2(ulong u0, ulong u1, ulong *ps, ulong *pr)
p_sqrtu2(ulong *n, ulong *ps, ulong *pr)
p_sqrtu2(ulong u0, ulong u1, ulong *ps, ulong *pr){ ulong hi, r, s, t; LOCAL_HIREMAINDER; LOCAL_OVERFLOW; s = dblmantissa( sqrt((double)u0) ); /* high bit of s is set */ t = mulll(s, s); hi = u0 - hiremainder; if ((long)hi < 0) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 0; } if (!hi && t > u1) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 1; } r = subll(u1, t); if (overflow) hi--; /* remainder R = hi*2^BIL + r. hi <= 2 */ if (hi == 2) { /* correction, r := (2|r) - 2s - 1 */ r = subll(r, (s << 1) | 1); *pr = r; *ps = s + 1; return !overflow; } if (hi && (r > (s<<1))) { /* correction, r := (1|r) - 2s - 1 */ r -= (s << 1) | 1; s++; hi = 0; } *ps = s; *pr = r; return hi;}
ulong hi, r, s, t;
ulong hi, r, s, t, u0 = n[0], u1 = n[1];
p_sqrtu2(ulong u0, ulong u1, ulong *ps, ulong *pr){ ulong hi, r, s, t; LOCAL_HIREMAINDER; LOCAL_OVERFLOW; s = dblmantissa( sqrt((double)u0) ); /* high bit of s is set */ t = mulll(s, s); hi = u0 - hiremainder; if ((long)hi < 0) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 0; } if (!hi && t > u1) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 1; } r = subll(u1, t); if (overflow) hi--; /* remainder R = hi*2^BIL + r. hi <= 2 */ if (hi == 2) { /* correction, r := (2|r) - 2s - 1 */ r = subll(r, (s << 1) | 1); *pr = r; *ps = s + 1; return !overflow; } if (hi && (r > (s<<1))) { /* correction, r := (1|r) - 2s - 1 */ r -= (s << 1) | 1; s++; hi = 0; } *ps = s; *pr = r; return hi;}
s = dblmantissa( sqrt((double)u0) );
s = sqrtu2(n);
p_sqrtu2(ulong u0, ulong u1, ulong *ps, ulong *pr){ ulong hi, r, s, t; LOCAL_HIREMAINDER; LOCAL_OVERFLOW; s = dblmantissa( sqrt((double)u0) ); /* high bit of s is set */ t = mulll(s, s); hi = u0 - hiremainder; if ((long)hi < 0) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 0; } if (!hi && t > u1) { /* rare but may occur */ s--; t -= (s << 1) | 1; /* t := t - (2s + 1) */ *ps = s; *pr = u1 - t; return 1; } r = subll(u1, t); if (overflow) hi--; /* remainder R = hi*2^BIL + r. hi <= 2 */ if (hi == 2) { /* correction, r := (2|r) - 2s - 1 */ r = subll(r, (s << 1) | 1); *pr = r; *ps = s + 1; return !overflow; } if (hi && (r > (s<<1))) { /* correction, r := (1|r) - 2s - 1 */ r -= (s << 1) | 1; s++; hi = 0; } *ps = s; *pr = r; return hi;}
return gerepileupto(av, gcopy(m));
return gerepilecopy(av, m);
matqpascal(long n, GEN q){ long i,j,I, av = avma; GEN m, *qpow = NULL; /* gcc -Wall */ if (n<0) n = -1; n++; m = cgetg(n+1,t_MAT); for (j=1; j<=n; j++) m[j] = lgetg(n+1,t_COL); if (q) { I = (n+1)/2; if (I > 1) { qpow = (GEN*)new_chunk(I+1); qpow[2]=q; } for (j=3; j<=I; j++) qpow[j] = gmul(q, qpow[j-1]); } for (i=1; i<=n; i++) { I = (i+1)/2; coeff(m,i,1)=un; if (q) { for (j=2; j<=I; j++) coeff(m,i,j) = ladd(gmul(qpow[j],gcoeff(m,i-1,j)), gcoeff(m,i-1,j-1)); } else { for (j=2; j<=I; j++) coeff(m,i,j) = laddii(gcoeff(m,i-1,j), gcoeff(m,i-1,j-1)); } for ( ; j<=i; j++) coeff(m,i,j) = coeff(m,i,i+1-j); for ( ; j<=n; j++) coeff(m,i,j) = zero; } return gerepileupto(av, gcopy(m));}
y=x; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j;
y=x; j=1+bfffo((ulong)m); m<<=j; j = BITS_IN_LONG-j;
element_pow_mod_p(GEN nf, GEN x, GEN n, GEN p){ ulong av = avma; long s,N,i,j,m; GEN y,p1; if (typ(n)!=t_INT) err(talker,"not an integer exponent in nfpow"); nf=checknf(nf); N=degpol(nf[1]); s=signe(n); if (!s) return gscalcol_i(gun,N); if (typ(x)!=t_COL) x=algtobasis(nf,x); if (isnfscalar(x)) { y = gscalcol_i(gun,N); y[1] = (long)powmodulo((GEN)x[1],n,p); return y; } p1 = n+2; m = *p1; y=x; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = element_sqri(nf, y); if (m<0) y=element_muli(nf, y, x); y = FpV_red(y, p); } if (--i == 0) break; m = *++p1; j = BITS_IN_LONG; } if (s<0) y = FpV_red(element_inv(nf,y), p); return av==avma? gcopy(y): gerepileupto(av,y);}
y1 = itor(x, lz+1); x = y; y = y1;
y1 = itor(x, lz); x = y; y = y1;
mulir(GEN x, GEN y){ long sx=signe(x),sy,lz,lzz,ey,e,p1,i,j; ulong garde; GEN z,y1; LOCAL_HIREMAINDER; LOCAL_OVERFLOW; if (!sx) return gzero; if (!is_bigint(x)) return mulsr(itos(x),y); sy=signe(y); ey=expo(y); if (!sy) return realzero_bit(expi(x)+ey); if (sy<0) sx = -sx; lz=lg(y); z=cgetr(lz); y1 = itor(x, lz+1); x = y; y = y1; e = expo(y)+ey; if (lz==3) { (void)mulll(x[2],y[3]); garde=addmul(x[2],y[2]); if ((long)hiremainder < 0) { z[2]=hiremainder; e++; } else z[2]=(hiremainder<<1) | (garde>>(BITS_IN_LONG-1)); z[1] = evalsigne(sx) | evalexpo(e); avma=(pari_sp)z; return z; } (void)mulll(x[2],y[lz]); garde=hiremainder; lzz=lz-1; p1=x[lzz]; if (p1) { (void)mulll(p1,y[3]); garde=addll(addmul(p1,y[2]),garde); z[lzz] = overflow+hiremainder; } else z[lzz]=0; for (j=lz-2, y1=y-j; j>=3; j--) { p1=x[j]; y1++; if (p1) { (void)mulll(p1,y1[lz+1]); garde = addll(addmul(p1,y1[lz]), garde); for (i=lzz; i>j; i--) { hiremainder += overflow; z[i] = addll(addmul(p1,y1[i]), z[i]); } z[j] = hiremainder+overflow; } else z[j]=0; } p1=x[2]; y1++; garde = addll(mulll(p1,y1[lz]), garde); for (i=lzz; i>2; i--) { hiremainder += overflow; z[i] = addll(addmul(p1,y1[i]), z[i]); } z[2] = hiremainder+overflow; if (z[2] < 0) e++; else shift_left(z,z,2,lzz,garde, 1); z[1] = evalsigne(sx) | evalexpo(e); avma=(pari_sp)z; return z;}
is = gtrunc(s); N = itos(muluu(p,prec)) + xp;
N = itos(muluu(p,prec)) + xp;
zetap(GEN s){ ulong p; long xp, N, f, c, prec = precp(s); pari_sp av = avma; GEN gp, q, vz, is, cff, vtz, val, va, cft; if (valp(s) < 0) err(talker, "argument must be a gp-adic integer"); gp = (GEN)s[2]; p = itou(gp); xp = (long) log2(p); /* the extra precision; FIXME: quite arbitrary */ if (DEBUGLEVEL > 2) fprintferr("zetap: extra prec = %ld\n", xp); is = gtrunc(s); /* make s an integer */ N = itos(muluu(p,prec)) + xp; /* FIXME: crude estimation */ q = gpowgs(gp, prec + xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (DEBUGLEVEL > 1) fprintferr("zetap: computing (p-1)th roots of 1\n"); vz = init_teich(p, q, prec + xp); if (p == 2UL) { f = 4; c = 3; } else { f = (long)p; c = 2; } /* compute the first N coefficients of the Mahler expansion of phi^(-1)_s skipping the first one (which is zero) */ if (DEBUGLEVEL > 1) fprintferr("zetap: computing Mahler expansion of phi^(-1)_s\n"); cff = coeff_of_phi_ms(p, q, -1, is, N, vz); /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding gp-adic Dirichlet L-functions */ va = perm_identity(f - 1); if (DEBUGLEVEL > 1) fprintferr("zetap: computing twisted partial zeta functions\n"); vtz = twistpartialzeta(gp, q, f, c, va, cff); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ if (DEBUGLEVEL > 1) fprintferr("zetap: summing up and multiplying by correcting factor\n"); /* sum and multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(p, q, -1, is, c, vz)), 1); val = gdiv(sum(vtz, 1, f-1), cft); /* adjust the precision and return */ return gerepileupto(av, cvtop(val, gp, prec));}
else { bnd = 1; if (typ(B) != t_INT) B = gfloor(B); }
if (typ(B) != t_INT) B = gceil(B); if (cmpis(X, X_SMALL) <= 0) return do_exhaustive(P0, N, itos(X), B); if (!egalii(B,N)) bnd = 1;
zncoppersmith(GEN P0, GEN N, GEN X, GEN B){ GEN Q, R, N0, M, sh, short_pol, *Xpowers, z, r, sol, nsp, P, tst, Z; int delta, ltop = avma, i, j, row, d, l, dim, t, bnd = 10; if (typ(P0) != t_POL || typ(N) != t_INT) err(typeer, "Coppersmith"); if (typ(X) != t_INT) X = gfloor(X); if (!B) B = N; else { bnd = 1; /* bnd-hack is only for the case B = N */ if (typ(B) != t_INT) B = gfloor(B); } P = dummycopy(P0); d = degpol(P); if (!gcmp1((GEN)P[d+2])) { P[d+2] = (long)bezout((GEN)P[d+2], N, &z, &r); for (j = 0; j < d; j++) P[j+2] = lmodii(mulii((GEN)P[j+2], z), N); } if (DEBUGLEVEL >= 2) fprintferr("Modified P: %Z\n", P); choose_params(P, N, X, B, &delta, &t); if (DEBUGLEVEL >= 2) fprintferr("Init: trying delta = %d, t = %d\n", delta, t); for(;;) { dim = d * delta + t; /* TODO: In case of failure do not recompute the full vector */ Xpowers = (GEN*)new_chunk(dim + 1); Xpowers[0] = gun; for (j = 1; j <= dim; j++) Xpowers[j] = gmul(Xpowers[j-1], X); /* TODO: in case of failure, use the part of the matrix already computed */ M = cgetg(dim + 1, t_MAT); for (j = 1; j <= dim; j++) M[j] = (long)zerocol(dim); /* Rows of M correspond to the polynomials * N^delta, N^delta Xi, ... N^delta (Xi)^d-1, * N^(delta-1)P(Xi), N^(delta-1)XiP(Xi), ... N^(delta-1)P(Xi)(Xi)^d-1, * ... * P(Xi)^delta, XiP(Xi)^delta, ..., P(Xi)^delta(Xi)^t-1 */ for (j = 1; j <= d; j++) coeff(M, j, j) = (long)Xpowers[j-1]; for ( ; j <= dim; j++) coeff(M, j, j) = un; /* P-part */ row = d + 1; Q = P; for (i = 1; i < delta; i++) { for (j = 0; j < d; j++,row++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); Q = RgX_mul(Q, P); } for (j = 0; j < t; row++, j++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); /* N-part */ row = dim - t; N0 = N; while (row >= 1) { for (j = 0; j < d; j++,row--) for (l = 1; l <= row; l++) coeff(M, l, row) = lmulii(gmael(M, row, l), N0); if (row >= 1) N0 = mulii(N0, N); } /* Z is the upper bound for the L^1 norm of the polynomial, ie. N^delta if B = N, B^delta otherwise */ if (B != N) Z = gpowgs(B, delta); else Z = N0; if (DEBUGLEVEL >= 2) { if (DEBUGLEVEL >= 6) fprintferr("Matrix to be reduced:\n%Z\n", M); fprintferr("Entering LLL\nbitsize bound: %ld\n", expi(Z)); fprintferr("expected shvector bitsize: %ld\n", expi(dethnf_i(M))/dim); } sh = lllint_fp_ip(M, 4); short_pol = (GEN)sh[1]; nsp = gzero; for (j = 1; j <= dim; j++) nsp = addii(nsp, absi((GEN)short_pol[j])); if (DEBUGLEVEL >= 2) { fprintferr("Candidate: %Z\n", short_pol); fprintferr("bitsize Norm: %ld\n", expi(nsp)); fprintferr("bitsize bound: %ld\n", expi(mulsi(bnd, Z))); } if (cmpii(nsp, mulsi(bnd, Z)) < 0) break; /* SUCCESS */ /* Failed with the precomputed or supplied value */ t++; if (t == d) { delta++; t = 1; } if (DEBUGLEVEL >= 2) fprintferr("Increasing dim, delta = %d t = %d\n", delta, t); } bnd = itos(divii(nsp, Z)) + 1; while (!signe(short_pol[dim])) dim--; R = cgetg(dim + 2, t_POL); R[1] = P[1]; for (j = 1; j <= dim; j++) R[j+1] = (long)diviiexact((GEN)short_pol[j], Xpowers[j-1]); R[2] = (long)subii((GEN)R[2], mulsi(bnd - 1, N0)); sol = cgetg(1, t_VEC); for (i = -bnd + 1; i < bnd; i++) { r = nfrootsQ(R); if (DEBUGLEVEL >= 2) fprintferr("Roots: %Z\n", r); for (j = 1; j < lg(r); j++) { z = (GEN)r[j]; tst = gcdii(FpX_eval(P, z, N), N); if (cmpii(tst, B) >= 0) /* We have found a factor of N >= B */ { for (l = 1; l < lg(sol) && !egalii(z, (GEN)sol[l]); l++) /*empty*/; if (l == lg(sol)) sol = concatsp(sol, z); } } if (i < bnd) R[2] = (long)addii((GEN)R[2], Z); } return gerepilecopy(ltop, sol);}
for ( ; j <= dim; j++) coeff(M, j, j) = un;
zncoppersmith(GEN P0, GEN N, GEN X, GEN B){ GEN Q, R, N0, M, sh, short_pol, *Xpowers, z, r, sol, nsp, P, tst, Z; int delta, ltop = avma, i, j, row, d, l, dim, t, bnd = 10; if (typ(P0) != t_POL || typ(N) != t_INT) err(typeer, "Coppersmith"); if (typ(X) != t_INT) X = gfloor(X); if (!B) B = N; else { bnd = 1; /* bnd-hack is only for the case B = N */ if (typ(B) != t_INT) B = gfloor(B); } P = dummycopy(P0); d = degpol(P); if (!gcmp1((GEN)P[d+2])) { P[d+2] = (long)bezout((GEN)P[d+2], N, &z, &r); for (j = 0; j < d; j++) P[j+2] = lmodii(mulii((GEN)P[j+2], z), N); } if (DEBUGLEVEL >= 2) fprintferr("Modified P: %Z\n", P); choose_params(P, N, X, B, &delta, &t); if (DEBUGLEVEL >= 2) fprintferr("Init: trying delta = %d, t = %d\n", delta, t); for(;;) { dim = d * delta + t; /* TODO: In case of failure do not recompute the full vector */ Xpowers = (GEN*)new_chunk(dim + 1); Xpowers[0] = gun; for (j = 1; j <= dim; j++) Xpowers[j] = gmul(Xpowers[j-1], X); /* TODO: in case of failure, use the part of the matrix already computed */ M = cgetg(dim + 1, t_MAT); for (j = 1; j <= dim; j++) M[j] = (long)zerocol(dim); /* Rows of M correspond to the polynomials * N^delta, N^delta Xi, ... N^delta (Xi)^d-1, * N^(delta-1)P(Xi), N^(delta-1)XiP(Xi), ... N^(delta-1)P(Xi)(Xi)^d-1, * ... * P(Xi)^delta, XiP(Xi)^delta, ..., P(Xi)^delta(Xi)^t-1 */ for (j = 1; j <= d; j++) coeff(M, j, j) = (long)Xpowers[j-1]; for ( ; j <= dim; j++) coeff(M, j, j) = un; /* P-part */ row = d + 1; Q = P; for (i = 1; i < delta; i++) { for (j = 0; j < d; j++,row++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); Q = RgX_mul(Q, P); } for (j = 0; j < t; row++, j++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); /* N-part */ row = dim - t; N0 = N; while (row >= 1) { for (j = 0; j < d; j++,row--) for (l = 1; l <= row; l++) coeff(M, l, row) = lmulii(gmael(M, row, l), N0); if (row >= 1) N0 = mulii(N0, N); } /* Z is the upper bound for the L^1 norm of the polynomial, ie. N^delta if B = N, B^delta otherwise */ if (B != N) Z = gpowgs(B, delta); else Z = N0; if (DEBUGLEVEL >= 2) { if (DEBUGLEVEL >= 6) fprintferr("Matrix to be reduced:\n%Z\n", M); fprintferr("Entering LLL\nbitsize bound: %ld\n", expi(Z)); fprintferr("expected shvector bitsize: %ld\n", expi(dethnf_i(M))/dim); } sh = lllint_fp_ip(M, 4); short_pol = (GEN)sh[1]; nsp = gzero; for (j = 1; j <= dim; j++) nsp = addii(nsp, absi((GEN)short_pol[j])); if (DEBUGLEVEL >= 2) { fprintferr("Candidate: %Z\n", short_pol); fprintferr("bitsize Norm: %ld\n", expi(nsp)); fprintferr("bitsize bound: %ld\n", expi(mulsi(bnd, Z))); } if (cmpii(nsp, mulsi(bnd, Z)) < 0) break; /* SUCCESS */ /* Failed with the precomputed or supplied value */ t++; if (t == d) { delta++; t = 1; } if (DEBUGLEVEL >= 2) fprintferr("Increasing dim, delta = %d t = %d\n", delta, t); } bnd = itos(divii(nsp, Z)) + 1; while (!signe(short_pol[dim])) dim--; R = cgetg(dim + 2, t_POL); R[1] = P[1]; for (j = 1; j <= dim; j++) R[j+1] = (long)diviiexact((GEN)short_pol[j], Xpowers[j-1]); R[2] = (long)subii((GEN)R[2], mulsi(bnd - 1, N0)); sol = cgetg(1, t_VEC); for (i = -bnd + 1; i < bnd; i++) { r = nfrootsQ(R); if (DEBUGLEVEL >= 2) fprintferr("Roots: %Z\n", r); for (j = 1; j < lg(r); j++) { z = (GEN)r[j]; tst = gcdii(FpX_eval(P, z, N), N); if (cmpii(tst, B) >= 0) /* We have found a factor of N >= B */ { for (l = 1; l < lg(sol) && !egalii(z, (GEN)sol[l]); l++) /*empty*/; if (l == lg(sol)) sol = concatsp(sol, z); } } if (i < bnd) R[2] = (long)addii((GEN)R[2], Z); } return gerepilecopy(ltop, sol);}
row = d + 1; Q = P;
if (delta) row = d + 1; else row = 0; Q = P;
zncoppersmith(GEN P0, GEN N, GEN X, GEN B){ GEN Q, R, N0, M, sh, short_pol, *Xpowers, z, r, sol, nsp, P, tst, Z; int delta, ltop = avma, i, j, row, d, l, dim, t, bnd = 10; if (typ(P0) != t_POL || typ(N) != t_INT) err(typeer, "Coppersmith"); if (typ(X) != t_INT) X = gfloor(X); if (!B) B = N; else { bnd = 1; /* bnd-hack is only for the case B = N */ if (typ(B) != t_INT) B = gfloor(B); } P = dummycopy(P0); d = degpol(P); if (!gcmp1((GEN)P[d+2])) { P[d+2] = (long)bezout((GEN)P[d+2], N, &z, &r); for (j = 0; j < d; j++) P[j+2] = lmodii(mulii((GEN)P[j+2], z), N); } if (DEBUGLEVEL >= 2) fprintferr("Modified P: %Z\n", P); choose_params(P, N, X, B, &delta, &t); if (DEBUGLEVEL >= 2) fprintferr("Init: trying delta = %d, t = %d\n", delta, t); for(;;) { dim = d * delta + t; /* TODO: In case of failure do not recompute the full vector */ Xpowers = (GEN*)new_chunk(dim + 1); Xpowers[0] = gun; for (j = 1; j <= dim; j++) Xpowers[j] = gmul(Xpowers[j-1], X); /* TODO: in case of failure, use the part of the matrix already computed */ M = cgetg(dim + 1, t_MAT); for (j = 1; j <= dim; j++) M[j] = (long)zerocol(dim); /* Rows of M correspond to the polynomials * N^delta, N^delta Xi, ... N^delta (Xi)^d-1, * N^(delta-1)P(Xi), N^(delta-1)XiP(Xi), ... N^(delta-1)P(Xi)(Xi)^d-1, * ... * P(Xi)^delta, XiP(Xi)^delta, ..., P(Xi)^delta(Xi)^t-1 */ for (j = 1; j <= d; j++) coeff(M, j, j) = (long)Xpowers[j-1]; for ( ; j <= dim; j++) coeff(M, j, j) = un; /* P-part */ row = d + 1; Q = P; for (i = 1; i < delta; i++) { for (j = 0; j < d; j++,row++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); Q = RgX_mul(Q, P); } for (j = 0; j < t; row++, j++) for (l = j + 1; l <= row; l++) coeff(M, l, row) = lmulii(Xpowers[l-1], (GEN)Q[l-j+1]); /* N-part */ row = dim - t; N0 = N; while (row >= 1) { for (j = 0; j < d; j++,row--) for (l = 1; l <= row; l++) coeff(M, l, row) = lmulii(gmael(M, row, l), N0); if (row >= 1) N0 = mulii(N0, N); } /* Z is the upper bound for the L^1 norm of the polynomial, ie. N^delta if B = N, B^delta otherwise */ if (B != N) Z = gpowgs(B, delta); else Z = N0; if (DEBUGLEVEL >= 2) { if (DEBUGLEVEL >= 6) fprintferr("Matrix to be reduced:\n%Z\n", M); fprintferr("Entering LLL\nbitsize bound: %ld\n", expi(Z)); fprintferr("expected shvector bitsize: %ld\n", expi(dethnf_i(M))/dim); } sh = lllint_fp_ip(M, 4); short_pol = (GEN)sh[1]; nsp = gzero; for (j = 1; j <= dim; j++) nsp = addii(nsp, absi((GEN)short_pol[j])); if (DEBUGLEVEL >= 2) { fprintferr("Candidate: %Z\n", short_pol); fprintferr("bitsize Norm: %ld\n", expi(nsp)); fprintferr("bitsize bound: %ld\n", expi(mulsi(bnd, Z))); } if (cmpii(nsp, mulsi(bnd, Z)) < 0) break; /* SUCCESS */ /* Failed with the precomputed or supplied value */ t++; if (t == d) { delta++; t = 1; } if (DEBUGLEVEL >= 2) fprintferr("Increasing dim, delta = %d t = %d\n", delta, t); } bnd = itos(divii(nsp, Z)) + 1; while (!signe(short_pol[dim])) dim--; R = cgetg(dim + 2, t_POL); R[1] = P[1]; for (j = 1; j <= dim; j++) R[j+1] = (long)diviiexact((GEN)short_pol[j], Xpowers[j-1]); R[2] = (long)subii((GEN)R[2], mulsi(bnd - 1, N0)); sol = cgetg(1, t_VEC); for (i = -bnd + 1; i < bnd; i++) { r = nfrootsQ(R); if (DEBUGLEVEL >= 2) fprintferr("Roots: %Z\n", r); for (j = 1; j < lg(r); j++) { z = (GEN)r[j]; tst = gcdii(FpX_eval(P, z, N), N); if (cmpii(tst, B) >= 0) /* We have found a factor of N >= B */ { for (l = 1; l < lg(sol) && !egalii(z, (GEN)sol[l]); l++) /*empty*/; if (l == lg(sol)) sol = concatsp(sol, z); } } if (i < bnd) R[2] = (long)addii((GEN)R[2], Z); } return gerepilecopy(ltop, sol);}
if ( !_POSIX_signals_Pending )
if ( !_POSIX_signals_Pending && _Thread_Do_post_task_switch_extension )
void _POSIX_signals_Clear_process_signals( sigset_t mask){ ISR_Level level; _ISR_Disable( level ); _POSIX_signals_Pending &= ~mask; if ( !_POSIX_signals_Pending ) _Thread_Do_post_task_switch_extension--; _ISR_Enable( level );}
assert( _POSIX_signals_Vectors[ signo ].sa_handler || _POSIX_signals_Vectors[ signo ].sa_sigaction );
boolean _POSIX_signals_Check_signal( POSIX_API_Control *api, int signo, boolean is_global){ sigset_t mask; ISR_Level level; boolean do_callout; siginfo_t *siginfo = NULL; /* really needs to be set below */ siginfo_t siginfo_struct; mask = signo_to_mask( signo ); do_callout = FALSE; _ISR_Disable( level ); if ( is_global ) { ; /* XXX check right place for thread versus global */ } else { if ( mask & (api->signals_pending & ~api->signals_blocked ) ) { api->signals_pending &= ~mask; do_callout = TRUE; } } _ISR_Enable( level ); if ( !do_callout ) return FALSE; switch ( _POSIX_signals_Vectors[ signo ].sa_flags ) { case SA_SIGINFO: assert( 0 ); /* XXX we haven't completely implemented this yet */ if ( !is_global ) { siginfo = &siginfo_struct; siginfo->si_signo = signo; siginfo->si_code = SI_USER; siginfo->si_value.sival_int = 0; } (*_POSIX_signals_Vectors[ signo ].sa_sigaction)( signo, siginfo, NULL /* context is undefined per 1003.1b-1993, p. 66 */ ); break; default: (*_POSIX_signals_Vectors[ signo ].sa_handler)( signo ); break; } return TRUE;}
p1 = ggcd(x1, y2); if (!gcmp1(p1)) { x1 = gdiv(x1,p1); y2 = gdiv(y2,p1); } p1 = ggcd(x2, y1); if (!gcmp1(p1)) { x2 = gdiv(x2,p1); y1 = gdiv(y1,p1); }
p1 = ggcd(x1, y2); if (!gcmp1(p1)) { x1 = gdeuc(x1,p1); y2 = gdeuc(y2,p1); } p1 = ggcd(x2, y1); if (!gcmp1(p1)) { x2 = gdeuc(x2,p1); y1 = gdeuc(y1,p1); }
mul_rfrac(GEN x1, GEN x2, GEN y1, GEN y2){ GEN z = cgetg(3,t_RFRAC), p1; pari_sp tetpil; p1 = ggcd(x1, y2); if (!gcmp1(p1)) { x1 = gdiv(x1,p1); y2 = gdiv(y2,p1); } p1 = ggcd(x2, y1); if (!gcmp1(p1)) { x2 = gdiv(x2,p1); y1 = gdiv(y1,p1); } tetpil = avma; gel(z,2) = gmul(x2,y2); gel(z,1) = gmul(x1,y1); p1 = fix_rfrac_if_pol(gel(z,1),gel(z,2)); if (p1) return gerepileupto((pari_sp)(z+3), p1); gerepilecoeffssp((pari_sp)z,tetpil,z+1,2); return z;}
shiftpol_i(GEN x, long v)
shiftpol_i(GEN x, long vx)
shiftpol_i(GEN x, long v){ long i, lz; GEN z; if (!v) return x; lz = lg(x)-v; z = cgetg(lz, t_POL); z[1] = x[1]; x += v; for (i=2; i<lz; i++) z[i] = x[i]; return z;}
if (!v) return x; lz = lg(x)-v;
if (!vx) return x; lz = lg(x)-vx;
shiftpol_i(GEN x, long v){ long i, lz; GEN z; if (!v) return x; lz = lg(x)-v; z = cgetg(lz, t_POL); z[1] = x[1]; x += v; for (i=2; i<lz; i++) z[i] = x[i]; return z;}
x += v;
x += vx;
shiftpol_i(GEN x, long v){ long i, lz; GEN z; if (!v) return x; lz = lg(x)-v; z = cgetg(lz, t_POL); z[1] = x[1]; x += v; for (i=2; i<lz; i++) z[i] = x[i]; return z;}
if (DEBUGLEVEL) timer(); N1 = modii(N, et);
N1 = resii(N, et);
step6(GEN N, ulong t, GEN et){ GEN N1,r,p1; ulong i,av; if (DEBUGLEVEL) timer(); N1 = modii(N, et); r = gun; av = avma; for (i=1; i<t; i++) { avma = av; r = modii(mulii(r,N1), et); if (!signe(modii(N,r)) && !gcmp1(r) && !egalii(r,N)) { p1 = cgetg(3,t_VEC); p1[1] = (long)r; p1[2] = zero; return p1; } } if (DEBUGLEVEL) sgt6=timer(); return gun;}
avma = av; r = modii(mulii(r,N1), et); if (!signe(modii(N,r)) && !gcmp1(r) && !egalii(r,N))
r = resii(mulii(r,N1), et); if (!signe(resii(N,r)) && !gcmp1(r) && !egalii(r,N))
step6(GEN N, ulong t, GEN et){ GEN N1,r,p1; ulong i,av; if (DEBUGLEVEL) timer(); N1 = modii(N, et); r = gun; av = avma; for (i=1; i<t; i++) { avma = av; r = modii(mulii(r,N1), et); if (!signe(modii(N,r)) && !gcmp1(r) && !egalii(r,N)) { p1 = cgetg(3,t_VEC); p1[1] = (long)r; p1[2] = zero; return p1; } } if (DEBUGLEVEL) sgt6=timer(); return gun;}
if (DEBUGLEVEL) sgt6=timer();
step6(GEN N, ulong t, GEN et){ GEN N1,r,p1; ulong i,av; if (DEBUGLEVEL) timer(); N1 = modii(N, et); r = gun; av = avma; for (i=1; i<t; i++) { avma = av; r = modii(mulii(r,N1), et); if (!signe(modii(N,r)) && !gcmp1(r) && !egalii(r,N)) { p1 = cgetg(3,t_VEC); p1[1] = (long)r; p1[2] = zero; return p1; } } if (DEBUGLEVEL) sgt6=timer(); return gun;}
int i, j;
int i, j, n = lg(L);
matrixbase2(GEN L, GEN T, GEN den){ ulong ltop = avma, lbot; int i, j; long x = varn(T); GEN M, P, Tp; if (DEBUGLEVEL >= 1) timer2(); M = cgetg(lg(L), t_MAT); Tp = deriv(T, x); for (i = 1; i < lg(L); i++) { M[i] = lgetg(lg(L), t_COL); P = gdiv(gdivround(T, gsub(polx[x], (GEN) L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < lg(L); j++) ((GEN *) M)[i][j] = P[1 + j]; } if (DEBUGLEVEL >= 1) msgtimer("matrixbase2"); lbot = avma; M = gmul(den, M); return gerepile(ltop, lbot, M);}
M = cgetg(lg(L), t_MAT);
M = cgetg(n, t_MAT);
matrixbase2(GEN L, GEN T, GEN den){ ulong ltop = avma, lbot; int i, j; long x = varn(T); GEN M, P, Tp; if (DEBUGLEVEL >= 1) timer2(); M = cgetg(lg(L), t_MAT); Tp = deriv(T, x); for (i = 1; i < lg(L); i++) { M[i] = lgetg(lg(L), t_COL); P = gdiv(gdivround(T, gsub(polx[x], (GEN) L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < lg(L); j++) ((GEN *) M)[i][j] = P[1 + j]; } if (DEBUGLEVEL >= 1) msgtimer("matrixbase2"); lbot = avma; M = gmul(den, M); return gerepile(ltop, lbot, M);}
for (i = 1; i < lg(L); i++)
for (i = 1; i < n; i++)
matrixbase2(GEN L, GEN T, GEN den){ ulong ltop = avma, lbot; int i, j; long x = varn(T); GEN M, P, Tp; if (DEBUGLEVEL >= 1) timer2(); M = cgetg(lg(L), t_MAT); Tp = deriv(T, x); for (i = 1; i < lg(L); i++) { M[i] = lgetg(lg(L), t_COL); P = gdiv(gdivround(T, gsub(polx[x], (GEN) L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < lg(L); j++) ((GEN *) M)[i][j] = P[1 + j]; } if (DEBUGLEVEL >= 1) msgtimer("matrixbase2"); lbot = avma; M = gmul(den, M); return gerepile(ltop, lbot, M);}
M[i] = lgetg(lg(L), t_COL); P = gdiv(gdivround(T, gsub(polx[x], (GEN) L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < lg(L); j++)
M[i] = lgetg(n, t_COL); P = gdiv(gdeuc(T, gsub(polx[x], (GEN)L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < n; j++)
matrixbase2(GEN L, GEN T, GEN den){ ulong ltop = avma, lbot; int i, j; long x = varn(T); GEN M, P, Tp; if (DEBUGLEVEL >= 1) timer2(); M = cgetg(lg(L), t_MAT); Tp = deriv(T, x); for (i = 1; i < lg(L); i++) { M[i] = lgetg(lg(L), t_COL); P = gdiv(gdivround(T, gsub(polx[x], (GEN) L[i])), gsubst(Tp, x, (GEN) L[i])); for (j = 1; j < lg(L); j++) ((GEN *) M)[i][j] = P[1 + j]; } if (DEBUGLEVEL >= 1) msgtimer("matrixbase2"); lbot = avma; M = gmul(den, M); return gerepile(ltop, lbot, M);}
buchinitfu(GEN g1,GEN g2,GEN g3,GEN g4, GEN g5,long l1,long l2,long prec) { return buchall(g1,gtodouble(g2),gtodouble(g3),l1,nf_INIT|nf_UNITS,prec); }
buchinitfu(B_ARGS) { return B_CALL(nf_INIT|nf_UNITS); }
buchinitfu(GEN g1,GEN g2,GEN g3,GEN g4, GEN g5,long l1,long l2,long prec) { return buchall(g1,gtodouble(g2),gtodouble(g3),l1,nf_INIT|nf_UNITS,prec);}
unsigned32 key1, unsigned32 key2,
uint32_t key1, uint32_t key2,
_hash_search( rtems_filesystem_mount_table_entry_t *mt_entry, Chain_Control *hash, unsigned32 key1, unsigned32 key2, fat_file_fd_t **ret ){ unsigned32 mod = (key1) % FAT_HASH_MODULE; Chain_Node *the_node = ((Chain_Control *)((hash) + mod))->first; for ( ; !_Chain_Is_tail((hash) + mod, the_node) ; ) { fat_file_fd_t *ffd = (fat_file_fd_t *)the_node; unsigned32 ck = fat_construct_key(mt_entry, ffd->info_cln, ffd->info_ofs); if ( (key1) == ck) { if ( ((key2) == 0) || ((key2) == ffd->ino) ) { *ret = (void *)the_node; return 0; } } the_node = the_node->next; } return -1; }
unsigned32 mod = (key1) % FAT_HASH_MODULE;
uint32_t mod = (key1) % FAT_HASH_MODULE;
_hash_search( rtems_filesystem_mount_table_entry_t *mt_entry, Chain_Control *hash, unsigned32 key1, unsigned32 key2, fat_file_fd_t **ret ){ unsigned32 mod = (key1) % FAT_HASH_MODULE; Chain_Node *the_node = ((Chain_Control *)((hash) + mod))->first; for ( ; !_Chain_Is_tail((hash) + mod, the_node) ; ) { fat_file_fd_t *ffd = (fat_file_fd_t *)the_node; unsigned32 ck = fat_construct_key(mt_entry, ffd->info_cln, ffd->info_ofs); if ( (key1) == ck) { if ( ((key2) == 0) || ((key2) == ffd->ino) ) { *ret = (void *)the_node; return 0; } } the_node = the_node->next; } return -1; }
unsigned32 ck =
uint32_t ck =
_hash_search( rtems_filesystem_mount_table_entry_t *mt_entry, Chain_Control *hash, unsigned32 key1, unsigned32 key2, fat_file_fd_t **ret ){ unsigned32 mod = (key1) % FAT_HASH_MODULE; Chain_Node *the_node = ((Chain_Control *)((hash) + mod))->first; for ( ; !_Chain_Is_tail((hash) + mod, the_node) ; ) { fat_file_fd_t *ffd = (fat_file_fd_t *)the_node; unsigned32 ck = fat_construct_key(mt_entry, ffd->info_cln, ffd->info_ofs); if ( (key1) == ck) { if ( ((key2) == 0) || ((key2) == ffd->ino) ) { *ret = (void *)the_node; return 0; } } the_node = the_node->next; } return -1; }
u1 = reducemodHNF(U, h, NULL);
u1 = reducemodHNF(u1, h, NULL);
buchrayall(GEN bnf,GEN module,long flag){ GEN nf,cyc,gen,genplus,fa2,sarch,hmatu,u,clg,logs; GEN dataunit,p1,p2,h,genray,met,u1,u2,U,cycgen; GEN racunit,bigres,bid,cycbid,genbid,x,y,funits,hmat,vecel; long RU,Ri,i,j,ngen,lh,lo,c,av=avma; bnf = checkbnf(bnf); nf = checknf(bnf); funits = check_units(bnf, "buchrayall"); RU = lg(funits); vecel = genplus = NULL; /* gcc -Wall */ bigres = (GEN)bnf[8]; cyc = gmael(bigres,1,2); gen = gmael(bigres,1,3); ngen = lg(cyc)-1; bid = zidealstarinitall(nf,module,1); cycbid = gmael(bid,2,2); genbid = gmael(bid,2,3); Ri = lg(cycbid)-1; lh = ngen+Ri; x = idealhermite(nf,module); if (Ri || flag & (nf_INIT|nf_GEN)) { vecel = cgetg(ngen+1,t_VEC); for (j=1; j<=ngen; j++) { p1 = idealcoprime(nf,(GEN)gen[j],x); if (isnfscalar(p1)) p1 = (GEN)p1[1]; vecel[j]=(long)p1; } } if (flag & nf_GEN) { genplus = cgetg(lh+1,t_VEC); for (j=1; j<=ngen; j++) genplus[j] = (long) idealmul(nf,(GEN)vecel[j],(GEN)gen[j]); for ( ; j<=lh; j++) genplus[j] = genbid[j-ngen]; } if (!Ri) { if (!(flag & nf_GEN)) clg = cgetg(3,t_VEC); else { clg = cgetg(4,t_VEC); clg[3] = (long)genplus; } clg[1] = mael(bigres,1,1); clg[2] = (long)cyc; if (!(flag & nf_INIT)) return gerepilecopy(av,clg); y = cgetg(7,t_VEC); y[1] = lcopy(bnf); y[2] = lcopy(bid); y[3] = lcopy(vecel); y[4] = (long)idmat(ngen); y[5] = lcopy(clg); u = cgetg(3,t_VEC); y[6] = (long)u; u[1] = lgetg(1,t_MAT); u[2] = (long)idmat(RU); return gerepileupto(av,y); } fa2 = (GEN)bid[4]; sarch = (GEN)fa2[lg(fa2)-1]; cycgen = check_and_build_cycgen(bnf); dataunit = cgetg(RU+1,t_MAT); racunit = gmael(bigres,4,2); dataunit[1] = (long)zideallog(nf,racunit,bid); for (j=2; j<=RU; j++) dataunit[j] = (long)zideallog(nf,(GEN)funits[j-1],bid); dataunit = concatsp(dataunit, diagonal(cycbid)); hmatu = hnfall(dataunit); hmat = (GEN)hmatu[1]; logs = cgetg(ngen+1, t_MAT); /* FIXME: cycgen[j] is not necessarily coprime to bid, but it is made coprime * in zideallog using canonical uniformizers [from bid data]: no need to * correct it here. The same ones will be used in isprincipalrayall. Hence * modification by vecel is useless. */ for (j=1; j<=ngen; j++) { p1 = (GEN)cycgen[j]; if (typ(vecel[j]) != t_INT) /* <==> != 1 */ p1 = arch_mul(to_famat_all((GEN)vecel[j], (GEN)cyc[j]), p1); logs[j] = (long)zideallog(nf,p1,bid); /* = log(genplus[j]) */ } /* [ cyc 0 ] * [-logs hmat] = relation matrix for Cl_f */ h = concatsp( vconcat(diagonal(cyc), gneg_i(logs)), vconcat(zeromat(ngen, Ri), hmat) ); h = hnf(h); met = smithall(h, &U, NULL); /* cf smithrel */ lo = lg(met)-1; for (c=1; c<=lo; c++) if (gcmp1(gcoeff(met,c,c))) break; setlg(met,c); if (flag & nf_GEN) { GEN Id = idmat(degpol(nf[1])), arch = (GEN)module[2]; u1 = ginv(U); setlg(u1,c); u1 = reducemodHNF(U, h, NULL); genray = cgetg(c,t_VEC); for (j=1; j<c; j++) { GEN *op, minus = Id, plus = Id; long av1 = avma, s; for (i=1; i<=lo; i++) { p1 = gcoeff(u1,i,j); if (!(s = signe(p1))) continue; if (s > 0) op = &plus; else { op = &minus; p1 = negi(p1); } p1 = idealpowmodidele(nf,(GEN)genplus[i],p1,x,sarch,arch); *op = *op==Id? p1 : idealmulmodidele(nf,*op,p1,x,sarch,arch); } if (minus == Id) p1 = plus; else { p2 = ideleaddone_aux(nf,minus,module); p1 = idealdivexact(nf,idealmul(nf,p2,plus),minus); p1 = idealmodidele(nf,p1,x,sarch,arch); } genray[j]=lpileupto(av1,p1); } clg = cgetg(4,t_VEC); clg[3] = lcopy(genray); } else clg = cgetg(3,t_VEC); met = mattodiagonal(met); clg[1] = (long)dethnf_i(h); clg[2] = (long)met; if (!(flag & nf_INIT)) return gerepileupto(av,clg); u2 = cgetg(Ri+1,t_MAT); u1 = cgetg(RU+1,t_MAT); u = (GEN)hmatu[2]; for (j=1; j<=RU; j++) { u1[j]=u[j]; setlg(u[j],RU+1); } u += RU; for (j=1; j<=Ri; j++) { u2[j]=u[j]; setlg(u[j],RU+1); } y = cgetg(7,t_VEC); y[1] = (long)bnf; y[2] = (long)bid; y[3] = (long)vecel; y[4] = (long)U; y[5] = (long)clg; u = cgetg(3,t_VEC); y[6] = (long)u; u[1] = lmul(u2, ginv(hmat)); u[2] = lmul(u1, lllint(u1)); return gerepilecopy(av,y);}
if (!isfundamental(Disc)) err(warner,"not a fundamental discriminant in quadclassunit");
buchquad(GEN D, double cbach, double cbach2, long RELSUP0, long flag, long prec){ pari_sp av0 = avma, av; long KCCO, i, j, s, **mat; long nrelsup, nreldep, LIMC, LIMC2, cp, nlze; GEN h, W, cyc, res, gen, dep, C, B, extramat, extraC; GEN R, resc, Res, z; double drc, lim, LOGD, LOGD2; const long MAXRELSUP = 7; Disc = D; if (typ(Disc)!=t_INT) err(typeer,"buchquad"); s = mod4(Disc); switch(signe(Disc)) { case -1: if (cmpis(Disc,-4) >= 0) { GEN p1=cgetg(6,t_VEC); p1[1]=p1[4]=p1[5]=un; p1[2]=p1[3]=lgetg(1,t_VEC); return p1; } if (s==2 || s==1) err(funder2,"buchquad"); PRECREG=0; break; case 1: if (s==2 || s==3) err(funder2,"buchquad"); if (flag) err(talker,"sorry, narrow class group not implemented. Use bnfnarrow"); PRECREG=1; break; default: err(talker,"zero discriminant in quadclassunit"); } if (carreparfait(Disc)) err(talker,"square argument in quadclassunit"); if (!isfundamental(Disc)) err(warner,"not a fundamental discriminant in quadclassunit"); buch_init(); RELSUP = RELSUP0; drc = fabs(gtodouble(Disc)); LOGD = log(drc); LOGD2 = LOGD * LOGD; lim = sqrt(drc); /* resc = sqrt(D) w / 2^r1 (2pi)^r2 ~ hR / L(chi,1) */ if (PRECREG) resc = dbltor(lim / 2.); else resc = dbltor(lim / PI); if (!PRECREG) lim /= sqrt(3.); R = gun; cp = (long)exp(sqrt(LOGD*log(LOGD)/8.0)); if (cp < 13) cp = 13; av = avma; cbach /= 2; mat = NULL;START: avma = av; cbach = check_bach(cbach,6.); if (mat) { desalloc(mat); mat = NULL; } nreldep = nrelsup = 0; LIMC = (long)(cbach*LOGD2); if (LIMC < cp) { LIMC = cp; cbach = LIMC / LOGD2; } LIMC2 = (long)(max(cbach,cbach2)*LOGD2); if (LIMC2 < LIMC) LIMC2 = LIMC; if (PRECREG) { PRECREG = max(prec+1, MEDDEFAULTPREC + 2*(expi(Disc)>>TWOPOTBITS_IN_LONG)); sqrtD = gsqrt(Disc,PRECREG); isqrtD = gfloor(sqrtD); } Res = FBquad(Disc,LIMC2,LIMC); if (!Res) goto START; subFB = subFBquad(Disc, lim + 0.5, KC); if (!subFB) goto START; powsubFB = powsubFBquad(CBUCH+1); limhash = ((ulong)LIMC < (MAXHALFULONG>>1))? LIMC*LIMC: (long)(HIGHBIT>>1); for (i=0; i<HASHT; i++) hashtab[i]=NULL; KCCO = KC + RELSUP; if (DEBUGLEVEL) fprintferr("KC = %ld, KCCO = %ld\n",KC,KCCO); mat = (long**)cgetalloc(NULL, KCCO+1, t_VEC); for (i=1; i<=KCCO; i++) { GEN t = cgetalloc(NULL, KC+1, t_VECSMALL); for (j=1; j<=KC; j++) t[j]=0; mat[i] = t; } s = lg(subFB)-1 + RELSUP; C = PRECREG? real_relations(KCCO,s,LIMC,mat) : imag_relations(KCCO,s,LIMC,mat); W = hnfspec(mat,vperm,&dep,&B,&C,lg(subFB)-1); nlze = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (nlze) {MORE: extramat = extra_relations(LIMC,nlze, &extraC); if (!extramat) { goto START; } W = hnfadd(W,vperm,&dep,&B,&C, extramat,extraC); nlze = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; KCCO += lg(extramat)-1; if (nlze) { if (++nreldep > 5) goto START; goto MORE; } } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch(get_R(C, KCCO - (lg(B)-1) - (lg(W)-1), divir(h,z), &R)) { case PRECI: prec = (PRECREG<<1)-2; goto START; case RELAT: if (++nrelsup <= MAXRELSUP) { nlze = min(KC, nrelsup); goto MORE; } goto START; } /* DONE */ if (!quad_be_honest()) goto START; gen = get_clgp(Disc,W,&cyc,PRECREG); desalloc(mat); res=cgetg(6,t_VEC); res[1]=(long)h; res[2]=(long)cyc; res[3]=(long)gen; res[4]=(long)R; res[5]=ldiv(mpmul(R,h), z); return gerepilecopy(av0,res);}
long av,tetpil,f, N=degpol(pol), m=lg(ideal)-1;
long f, N=degpol(pol), m=lg(ideal)-1; ulong av;
prime_two_elt(GEN nf, GEN p, GEN ideal){ GEN beta,a,pf, pol = (GEN)nf[1]; long av,tetpil,f, N=degpol(pol), m=lg(ideal)-1; if (!m) return gscalcol_i(p,N); /* we want v_p(Norm(beta)) = p^f, f = N-m */ av = avma; f = N-m; pf = gpuigs(p,f); ideal = centerlift(ideal); ideal = concatsp(gscalcol(p,N), ideal); ideal = ideal_better_basis(nf, ideal, p); beta = gmul((GEN)nf[7], ideal);#if 0 a = prime_two_elt_loop(beta,pol,p,pf); if (!a) err(bugparier, "prime_two_elt (failed)");#else a = random_prime_two_elt_loop(beta,pol,p,pf);#endif a = centermod(algtobasis_intern(nf,a), p); if (resii(divii(subres(gmul((GEN)nf[7],a),pol),pf),p) == gzero) a[1] = laddii((GEN)a[1],p); tetpil = avma; return gerepile(av,tetpil,gcopy(a));}
tetpil = avma; return gerepile(av,tetpil,gcopy(a));
return gerepilecopy(av,a);
prime_two_elt(GEN nf, GEN p, GEN ideal){ GEN beta,a,pf, pol = (GEN)nf[1]; long av,tetpil,f, N=degpol(pol), m=lg(ideal)-1; if (!m) return gscalcol_i(p,N); /* we want v_p(Norm(beta)) = p^f, f = N-m */ av = avma; f = N-m; pf = gpuigs(p,f); ideal = centerlift(ideal); ideal = concatsp(gscalcol(p,N), ideal); ideal = ideal_better_basis(nf, ideal, p); beta = gmul((GEN)nf[7], ideal);#if 0 a = prime_two_elt_loop(beta,pol,p,pf); if (!a) err(bugparier, "prime_two_elt (failed)");#else a = random_prime_two_elt_loop(beta,pol,p,pf);#endif a = centermod(algtobasis_intern(nf,a), p); if (resii(divii(subres(gmul((GEN)nf[7],a),pol),pf),p) == gzero) a[1] = laddii((GEN)a[1],p); tetpil = avma; return gerepile(av,tetpil,gcopy(a));}
long i,j,ls,ltop=avma,lbot;
ulong ltop = avma; long i,j,ls;
bnfsunit(GEN bnf,GEN S,long prec){ long i,j,ls,ltop=avma,lbot; GEN p1,nf,classgp,gen,M,U,H; GEN sunit,card,sreg,res,pow,fa = cgetg(3, t_MAT); if (typ(S) != t_VEC) err(typeer,"bnfsunit"); bnf = checkbnf(bnf); nf=(GEN)bnf[7]; classgp=gmael(bnf,8,1); gen = (GEN)classgp[3]; sreg = gmael(bnf,8,2); res=cgetg(7,t_VEC); res[1]=res[2]=res[3]=lgetg(1,t_VEC); res[4]=(long)sreg; res[5]=(long)classgp; res[6]=(long)S; ls=lg(S); /* M = relation matrix for the S class group (in terms of the class group * generators given by gen) * 1) ideals in S */ M = cgetg(ls,t_MAT); for (i=1; i<ls; i++) { p1 = (GEN)S[i]; checkprimeid(p1); M[i] = (long)isprincipal(bnf,p1); } /* 2) relations from bnf class group */ M = concatsp(M, diagonal((GEN) classgp[2])); /* S class group */ H = hnfall(M); U = (GEN)H[2]; H= (GEN)H[1]; card = gun; if (lg(H) > 1) { /* non trivial (rare!) */ GEN SNF, ClS = cgetg(4,t_VEC); SNF = smith2(H); p1 = (GEN)SNF[3]; card = dethnf_i(p1); ClS[1] = (long)card; /* h */ for(i=1; i<lg(p1); i++) if (gcmp1((GEN)p1[i])) break; setlg(p1,i); ClS[2]=(long)p1; /* cyc */ p1=cgetg(i,t_VEC); pow=ZM_inv((GEN)SNF[1],gun); fa[1] = (long)gen; for(i--; i; i--) { fa[2] = pow[i]; p1[i] = (long)factorback_i(fa, nf, 1); } ClS[3]=(long)p1; /* gen */ res[5]=(long) ClS; } /* S-units */ if (ls>1) { GEN den, Sperm, perm, dep, B, U1 = U; long lH, lB, fl = nf_GEN|nf_FORCE; /* U1 = upper left corner of U, invertible. S * U1 = principal ideals * whose generators generate the S-units */ setlg(U1,ls); p1 = cgetg(ls, t_MAT); /* p1 is junk for mathnfspec */ for (i=1; i<ls; i++) { setlg(U1[i],ls); p1[i] = lgetg(1,t_COL); } H = mathnfspec(U1,&perm,&dep,&B,&p1); lH = lg(H); lB = lg(B); if (lg(dep) > 1 && lg(dep[1]) > 1) err(bugparier,"bnfsunit"); /* [ H B ] [ H^-1 - H^-1 B ] * perm o HNF(U1) = [ 0 Id ], inverse = [ 0 Id ] * (permute the rows) * S * HNF(U1) = _integral_ generators for S-units = sunit */ Sperm = cgetg(ls, t_VEC); sunit = cgetg(ls, t_VEC); for (i=1; i<ls; i++) Sperm[i] = S[perm[i]]; /* S o perm */ setlg(Sperm, lH); fa[1] = (long)Sperm; for (i=1; i<lH; i++) sunit[i] = isprincipalfact(bnf,Sperm,(GEN)H[i],NULL,fl)[2]; for (j=1; j<lB; j++,i++) sunit[i] = isprincipalfact(bnf,Sperm,(GEN)B[j],(GEN)Sperm[i],fl)[2]; p1 = cgetg(4,t_VEC); den = dethnf_i(H); H = ZM_inv(H,den); p1[1] = (long)perm; p1[2] = (long)concatsp(H, gneg(gmul(H,B))); /* top part of inverse * den */ p1[3] = (long)den; /* keep denominator separately */ sunit = basistoalg(nf,sunit); res[2] = (long)p1; /* HNF in split form perm + (H B) [0 Id missing] */ res[1] = (long)lift_intern(sunit); } /* S-regulator */ sreg = gmul(sreg,card); for (i=1; i<ls; i++) { GEN p = (GEN)S[i]; if (typ(p) == t_VEC) p = (GEN) p[1]; sreg = gmul(sreg,glog(p,prec)); } res[4]=(long) sreg; lbot=avma; return gerepile(ltop,lbot,gcopy(res));}
res[4]=(long) sreg; lbot=avma; return gerepile(ltop,lbot,gcopy(res));
res[4]=(long) sreg; return gerepilecopy(ltop,res);
bnfsunit(GEN bnf,GEN S,long prec){ long i,j,ls,ltop=avma,lbot; GEN p1,nf,classgp,gen,M,U,H; GEN sunit,card,sreg,res,pow,fa = cgetg(3, t_MAT); if (typ(S) != t_VEC) err(typeer,"bnfsunit"); bnf = checkbnf(bnf); nf=(GEN)bnf[7]; classgp=gmael(bnf,8,1); gen = (GEN)classgp[3]; sreg = gmael(bnf,8,2); res=cgetg(7,t_VEC); res[1]=res[2]=res[3]=lgetg(1,t_VEC); res[4]=(long)sreg; res[5]=(long)classgp; res[6]=(long)S; ls=lg(S); /* M = relation matrix for the S class group (in terms of the class group * generators given by gen) * 1) ideals in S */ M = cgetg(ls,t_MAT); for (i=1; i<ls; i++) { p1 = (GEN)S[i]; checkprimeid(p1); M[i] = (long)isprincipal(bnf,p1); } /* 2) relations from bnf class group */ M = concatsp(M, diagonal((GEN) classgp[2])); /* S class group */ H = hnfall(M); U = (GEN)H[2]; H= (GEN)H[1]; card = gun; if (lg(H) > 1) { /* non trivial (rare!) */ GEN SNF, ClS = cgetg(4,t_VEC); SNF = smith2(H); p1 = (GEN)SNF[3]; card = dethnf_i(p1); ClS[1] = (long)card; /* h */ for(i=1; i<lg(p1); i++) if (gcmp1((GEN)p1[i])) break; setlg(p1,i); ClS[2]=(long)p1; /* cyc */ p1=cgetg(i,t_VEC); pow=ZM_inv((GEN)SNF[1],gun); fa[1] = (long)gen; for(i--; i; i--) { fa[2] = pow[i]; p1[i] = (long)factorback_i(fa, nf, 1); } ClS[3]=(long)p1; /* gen */ res[5]=(long) ClS; } /* S-units */ if (ls>1) { GEN den, Sperm, perm, dep, B, U1 = U; long lH, lB, fl = nf_GEN|nf_FORCE; /* U1 = upper left corner of U, invertible. S * U1 = principal ideals * whose generators generate the S-units */ setlg(U1,ls); p1 = cgetg(ls, t_MAT); /* p1 is junk for mathnfspec */ for (i=1; i<ls; i++) { setlg(U1[i],ls); p1[i] = lgetg(1,t_COL); } H = mathnfspec(U1,&perm,&dep,&B,&p1); lH = lg(H); lB = lg(B); if (lg(dep) > 1 && lg(dep[1]) > 1) err(bugparier,"bnfsunit"); /* [ H B ] [ H^-1 - H^-1 B ] * perm o HNF(U1) = [ 0 Id ], inverse = [ 0 Id ] * (permute the rows) * S * HNF(U1) = _integral_ generators for S-units = sunit */ Sperm = cgetg(ls, t_VEC); sunit = cgetg(ls, t_VEC); for (i=1; i<ls; i++) Sperm[i] = S[perm[i]]; /* S o perm */ setlg(Sperm, lH); fa[1] = (long)Sperm; for (i=1; i<lH; i++) sunit[i] = isprincipalfact(bnf,Sperm,(GEN)H[i],NULL,fl)[2]; for (j=1; j<lB; j++,i++) sunit[i] = isprincipalfact(bnf,Sperm,(GEN)B[j],(GEN)Sperm[i],fl)[2]; p1 = cgetg(4,t_VEC); den = dethnf_i(H); H = ZM_inv(H,den); p1[1] = (long)perm; p1[2] = (long)concatsp(H, gneg(gmul(H,B))); /* top part of inverse * den */ p1[3] = (long)den; /* keep denominator separately */ sunit = basistoalg(nf,sunit); res[2] = (long)p1; /* HNF in split form perm + (H B) [0 Id missing] */ res[1] = (long)lift_intern(sunit); } /* S-regulator */ sreg = gmul(sreg,card); for (i=1; i<ls; i++) { GEN p = (GEN)S[i]; if (typ(p) == t_VEC) p = (GEN) p[1]; sreg = gmul(sreg,glog(p,prec)); } res[4]=(long) sreg; lbot=avma; return gerepile(ltop,lbot,gcopy(res));}
tty->rawOutBufState = rob_busy;
osend (const char *buf, int len, struct rtems_termios_tty *tty){ unsigned int newHead; rtems_interrupt_level level; rtems_status_code sc; if (!tty->device.outputUsesInterrupts) { (*tty->device.write)(tty->minor, buf, len); return; } newHead = tty->rawOutBufHead; while (len) { /* * Performance improvement could be made here. * Copy multiple bytes to raw buffer: * if (len > 1) && (space to buffer end, or tail > 1) * ncopy = MIN (len, space to buffer end or tail) * memcpy (raw buffer, buf, ncopy) * buf += ncopy * len -= ncopy * * To minimize latency, the memcpy should be done * with interrupts enabled. */ newHead = (newHead + 1) % RAW_OUTPUT_BUFFER_SIZE; rtems_interrupt_disable (level); while (newHead == tty->rawOutBufTail) { tty->rawOutBufState = rob_wait; rtems_interrupt_enable (level); sc = rtems_semaphore_obtain (tty->rawOutBufSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (sc); rtems_interrupt_disable (level); } tty->rawOutBuf[tty->rawOutBufHead] = *buf++; tty->rawOutBufHead = newHead; if (tty->rawOutBufState == rob_idle) { tty->rawOutBufState = rob_busy; (*tty->device.write)(tty->minor, (char *)&tty->rawOutBuf[tty->rawOutBufTail], 1); } rtems_interrupt_enable (level); len--; }}
tty->rawOutBufState = rob_busy;
osend (const char *buf, int len, struct rtems_termios_tty *tty){ unsigned int newHead; rtems_interrupt_level level; rtems_status_code sc; if (!tty->device.outputUsesInterrupts) { (*tty->device.write)(tty->minor, buf, len); return; } newHead = tty->rawOutBufHead; while (len) { /* * Performance improvement could be made here. * Copy multiple bytes to raw buffer: * if (len > 1) && (space to buffer end, or tail > 1) * ncopy = MIN (len, space to buffer end or tail) * memcpy (raw buffer, buf, ncopy) * buf += ncopy * len -= ncopy * * To minimize latency, the memcpy should be done * with interrupts enabled. */ newHead = (newHead + 1) % RAW_OUTPUT_BUFFER_SIZE; rtems_interrupt_disable (level); while (newHead == tty->rawOutBufTail) { tty->rawOutBufState = rob_wait; rtems_interrupt_enable (level); sc = rtems_semaphore_obtain (tty->rawOutBufSemaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (sc != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred (sc); rtems_interrupt_disable (level); } tty->rawOutBuf[tty->rawOutBufHead] = *buf++; tty->rawOutBufHead = newHead; if (tty->rawOutBufState == rob_idle) { tty->rawOutBufState = rob_busy; (*tty->device.write)(tty->minor, (char *)&tty->rawOutBuf[tty->rawOutBufTail], 1); } rtems_interrupt_enable (level); len--; }}
svg_matrix_multiply(&c->gm, &c->gm, &tm);
svg_matrix_multiply(&c->gm, &tm, &c->gm);
void svg_render_solid(SDL_svg_context *c){int i,j;int colorstops;//void (*renderfunc)(SDL_svg_context *c, int x, int y, int w);IPoint *path;svg_paint_t *paint;const svg_color_t *rgb;int alpha;svg_matrix_t tm; c->renderfunc = 0; path = c->path; paint = c->paint; switch(paint->type) { case SVG_PAINT_TYPE_COLOR: rgb = &paint->p.color; alpha = 255.0 * c->FillOpacity; c->solidcolor = maprgb(c->surface, svg_color_get_red(rgb), svg_color_get_green(rgb), svg_color_get_blue(rgb)) | (alpha << 24); c->renderfunc = solidstrip; break; case SVG_PAINT_TYPE_GRADIENT: colorstops = paint->p.gradient->num_stops; for(i=0;i<colorstops-1;++i) { int c1,c2; int r1,g1,b1,a1,r2,g2,b2,a2; unsigned long t; int v; c1=NUM_GRADIENT_COLORS*i/(colorstops-1); c2=NUM_GRADIENT_COLORS*(i+1)/(colorstops-1); t=paint->p.gradient->stops[i].color.rgb; a1=255.0 * paint->p.gradient->stops[i].opacity; r1 = (t>>16) & 255; g1 = (t>>8) & 255; b1 = t & 255; t=paint->p.gradient->stops[i+1].color.rgb; a2=255.0 * paint->p.gradient->stops[i+1].opacity; r2 = (t>>16) & 255; g2 = (t>>8) & 255; b2 = t & 255; r2-=r1; g2-=g1; b2-=b1; a2-=a1; v=c2-c1-1; for(j=0;j<=v;++j) { c->gradient_colors[c1+j]=maprgb(c->surface, r1 + r2*j/v, g1 + g2*j/v, b1 + b2*j/v) | ((a1 + a2*j/v)<<24); } } c->gradient_policy = paint->p.gradient->spread; if (paint->p.gradient->type == SVG_GRADIENT_LINEAR) { c->renderfunc = lineargradient; c->gradient_p1 = (IPoint) { ConvertLength(&paint->p.gradient->u.linear.x1), ConvertLength(&paint->p.gradient->u.linear.y1)}; c->gradient_p2 = (IPoint) { ConvertLength(&paint->p.gradient->u.linear.x2), ConvertLength(&paint->p.gradient->u.linear.y2)}; } else if(paint->p.gradient->type == SVG_GRADIENT_RADIAL) { c->renderfunc = radialgradient; c->gradient_p1 = (IPoint) { ConvertLength(&paint->p.gradient->u.radial.cx), ConvertLength(&paint->p.gradient->u.radial.cy)}; c->gradient_p2 = (IPoint) { ConvertLength(&paint->p.gradient->u.radial.fx), ConvertLength(&paint->p.gradient->u.radial.fy)}; c->gradient_r = ConvertLength(&paint->p.gradient->u.radial.r); } else c->renderfunc = 0; if(paint->p.gradient->units==SVG_GRADIENT_UNITS_USER) { c->gradient_p1 = FixCoords(c, c->gradient_p1); c->gradient_p2 = FixCoords(c, c->gradient_p2); c->gradient_r = FixSizes(c, (IPoint) {c->gradient_r, 0.0}).x; c->gm.a = c->gm.d = 1.0; c->gm.c = c->gm.b = c->gm.e = c->gm.f = 0.0; } else // BBOX { IPoint vx, vy, tv; float xx,xy,yx,yy, det; tv = FixCoords(c, (IPoint) {c->minx, c->miny}); vx = FixCoords(c, (IPoint) {c->maxx, c->miny}); vy = FixCoords(c, (IPoint) {c->minx, c->maxy});// x' = x+e// y' = y+f// x'' = ax' + by'// y'' = cx' + dy' xx = vx.x - tv.x; xy = vx.y - tv.y; yx = vy.x - tv.x; yy = vy.y - tv.y; det = xx*yy - xy*yx; if(det != 0.0) { c->gm.a = yy / det; c->gm.c = -yx / det; c->gm.b = -xy / det; c->gm.d = xx / det; } else c->gm.a = c->gm.b = c->gm.c = c->gm.d = 0.0; c->gm.e = -(c->gm.a * tv.x + c->gm.c * tv.y); c->gm.f = -(c->gm.b * tv.x + c->gm.d * tv.y); }// go get the gradient transform svg_matrix_init(&tm, paint->p.gradient->transform[0], paint->p.gradient->transform[1], paint->p.gradient->transform[2], paint->p.gradient->transform[3], paint->p.gradient->transform[4], paint->p.gradient->transform[5]);// invert it tm = svg_matrix_invert(&tm);// apply it to our own gm svg_matrix_multiply(&c->gm, &c->gm, &tm); break; default: c->renderfunc = 0; break; } do_render(c);}
return FqX_red(derivpol(f), T, p);
return FpXQX_red(derivpol(f), T, p);
FqX_deriv(GEN f, GEN T, GEN p){ return FqX_red(derivpol(f), T, p);}
if ( the_object->name == the_name ) {
if ( the_object->name == name_to_use ) {
rtems_status_code _Objects_MP_Global_name_search ( Objects_Information *information, Objects_Name the_name, unsigned32 nodes_to_search, Objects_Id *the_id){ unsigned32 low_node; unsigned32 high_node; unsigned32 node_index; Chain_Control *the_chain; Chain_Node *the_node; Objects_MP_Control *the_object; if ( nodes_to_search > _Configuration_MP_table->maximum_nodes ) return ( RTEMS_INVALID_NODE ); if ( information->global_table == NULL ) return ( RTEMS_INVALID_NAME ); if ( nodes_to_search == RTEMS_SEARCH_ALL_NODES || nodes_to_search == RTEMS_SEARCH_OTHER_NODES ) { low_node = 1; high_node = _Configuration_MP_table->maximum_nodes; } else { low_node = high_node = nodes_to_search; } _Thread_Disable_dispatch(); for ( node_index = low_node ; node_index <= high_node ; node_index++ ) { /* * NOTE: The local node was search (if necessary) by * _Objects_Name_to_id before this was invoked. */ if ( !_Objects_Is_local_node( node_index ) ) { the_chain = &information->global_table[ node_index ]; for ( the_node = the_chain->first ; !_Chain_Is_tail( the_chain, the_node ) ; the_node = the_node->next ) { the_object = (Objects_MP_Control *) the_node; if ( the_object->name == the_name ) { *the_id = the_object->Object.id; _Thread_Enable_dispatch(); return ( RTEMS_SUCCESSFUL ); } } } } _Thread_Enable_dispatch(); return ( RTEMS_INVALID_NAME );}