- Timestamp:
- Feb 8, 2013, 6:03:33 PM (11 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- c462b60ab56fe1781c7f591d40ccd2799acd6c92
- Parents:
- 67242b64d178faf65f7a6059740248dcfbf15c53
- Location:
- libpolys/polys/monomials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/monomials/p_polys.cc
r67242b r0b0bc3 59 59 #endif 60 60 61 /* 62 * lift ideal with coeffs over Z (mod N) to Q via Farey 63 */ 64 poly p_Farey(poly p, number N, const ring r) 65 { 66 poly h=p_Copy(p,r); 67 poly hh=h; 68 while(h!=NULL) 69 { 70 number c=pGetCoeff(h); 71 pSetCoeff0(h,n_Farey(c,N,r->cf)); 72 n_Delete(&c,r->cf); 73 pIter(h); 74 } 75 while((hh!=NULL)&&(n_IsZero(pGetCoeff(hh),r->cf))) 76 { 77 p_LmDelete(&hh,r); 78 } 79 h=hh; 80 while((h!=NULL) && (pNext(h)!=NULL)) 81 { 82 if(n_IsZero(pGetCoeff(pNext(h)),r->cf)) 83 { 84 p_LmDelete(&pNext(h),r); 85 } 86 else pIter(h); 87 } 88 return hh; 89 } 90 /*2 91 * xx,q: arrays of length 0..rl-1 92 * xx[i]: SB mod q[i] 93 * assume: char=0 94 * assume: q[i]!=0 95 * destroys xx 96 */ 97 poly p_ChineseRemainder(poly *xx, number *x,number *q, int rl, const ring R) 98 { 99 poly r,h,hh; 100 int j; 101 poly res_p=NULL; 102 loop 103 { 104 /* search the lead term */ 105 r=NULL; 106 for(j=rl-1;j>=0;j--) 107 { 108 h=xx[j]; 109 if ((h!=NULL) 110 &&((r==NULL)||(p_LmCmp(r,h,R)==-1))) 111 r=h; 112 } 113 /* nothing found -> return */ 114 if (r==NULL) break; 115 /* create the monomial in h */ 116 h=p_Head(r,R); 117 /* collect the coeffs in x[..]*/ 118 for(j=rl-1;j>=0;j--) 119 { 120 hh=xx[j]; 121 if ((hh!=NULL) && (p_LmCmp(r,hh,R)==0)) 122 { 123 x[j]=pGetCoeff(hh); 124 hh=p_LmFreeAndNext(hh,R); 125 xx[j]=hh; 126 } 127 else 128 x[j]=n_Init(0, R); 129 } 130 number n=n_ChineseRemainder(x,q,rl,R->cf); 131 for(j=rl-1;j>=0;j--) 132 { 133 x[j]=NULL; // nlInit(0...) takes no memory 134 } 135 if (n_IsZero(n,R)) p_Delete(&h,R); 136 else 137 { 138 p_SetCoeff(h,n,R); 139 //Print("new mon:");pWrite(h); 140 pNext(h)=res_p; 141 res_p=h; // building res_p in reverse order! 142 } 143 } 144 return pReverse(res_p); 145 } 61 146 /*************************************************************** 62 147 * -
libpolys/polys/monomials/p_polys.h
r67242b r0b0bc3 36 36 #endif 37 37 38 poly p_Farey(poly p, number N, const ring r); 39 /* 40 * xx,q: arrays of length 0..rl-1 41 * xx[i]: SB mod q[i] 42 * assume: char=0 43 * assume: q[i]!=0 44 * destroys xx 45 */ 46 poly p_ChineseRemainder(poly *xx, number *x,number *q, int rl, const ring R); 38 47 /*************************************************************** 39 48 *
Note: See TracChangeset
for help on using the changeset viewer.