Changeset 5a4e17 in git
- Timestamp:
- Aug 14, 2013, 5:44:47 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- e7af713b2118666efd56a51c8fd09dcc0b99e0ee
- Parents:
- adae8b2811aa80401958b914b4cfc7d0ad8eb36b
- Location:
- libpolys/polys
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/clapsing.cc
radae8b r5a4e17 59 59 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); 60 60 61 staticpoly singclap_gcd_r ( poly f, poly g, const ring r )61 poly singclap_gcd_r ( poly f, poly g, const ring r ) 62 62 { 63 63 poly res=NULL; … … 66 66 assume(g!=NULL); 67 67 68 if( (pNext(f)==NULL) && (pNext(g)==NULL))68 if(pNext(f)==NULL) 69 69 { 70 70 poly p=p_One(r); 71 if (pNext(g)==NULL) 72 { 73 for(int i=rVar(r);i>0;i--) 74 p_SetExp(p,i,si_min(p_GetExp(f,i,r),p_GetExp(g,i,r)),r); 75 p_Setm(p,r); 76 return p; 77 } 78 #if 0 79 else 80 { 81 poly h=g; 82 for(int i=rVar(r);i>0;i--) 83 p_SetExp(p,i,p_GetExp(f,i,r),r); 84 while(h!=NULL) 85 { 86 for(int i=rVar(r);i>0;i--) 87 p_SetExp(p,i,si_min(p_GetExp(p,i,r),p_GetExp(h,i,r)),r); 88 pIter(h); 89 } 90 p_Setm(p,r); 91 return p; 92 } 93 #endif 94 } 95 #if 0 96 else if (pNext(g)==NULL) 97 { 98 poly p=p_One(r); 99 poly h=f; 71 100 for(int i=rVar(r);i>0;i--) 72 p_SetExp(p,i,si_min(p_GetExp(f,i,r),p_GetExp(g,i,r)),r); 101 p_SetExp(p,i,p_GetExp(g,i,r),r); 102 while(h!=NULL) 103 { 104 for(int i=rVar(r);i>0;i--) 105 p_SetExp(p,i,si_min(p_GetExp(p,i,r),p_GetExp(h,i,r)),r); 106 pIter(h); 107 } 73 108 p_Setm(p,r); 74 109 return p; 75 110 } 111 #endif 76 112 77 113 Off(SW_RATIONAL); -
libpolys/polys/clapsing.h
radae8b r5a4e17 29 29 /// destroys f and g 30 30 poly singclap_gcd ( poly f, poly g, const ring r ); 31 32 poly singclap_gcd_r ( poly f, poly g, const ring r ); 31 33 32 34 /// clears denominators of f and g, divides by gcd(f,g) -
libpolys/polys/ext_fields/transext.cc
radae8b r5a4e17 1100 1100 1101 1101 fraction f = (fraction)a; 1102 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; } 1102 if (COM(f)!=0) p_Normalize(NUM(f), ntRing); 1103 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; } 1104 1105 p_Normalize(DEN(f), ntRing); 1103 1106 1104 1107 assume( DEN(f) != NULL ); … … 1153 1156 1154 1157 if (IS0(a)) return; 1155 if (NUM(f)!=NULL) p_Normalize(NUM(f), ntRing);1156 if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing);1157 1158 if (!simpleTestsHaveAlreadyBeenPerformed) 1158 1159 { 1160 p_Normalize(NUM(f), ntRing); 1161 if (DEN(f)!=NULL) p_Normalize(DEN(f), ntRing); 1159 1162 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; } 1160 1163 … … 1169 1172 } 1170 1173 } 1174 if (rField_is_Q(ntRing)) 1175 { 1176 number c=n_Copy(pGetCoeff(NUM(f)),ntCoeffs); 1177 poly p=pNext(NUM(f)); 1178 while((p!=NULL)&&(!n_IsOne(c,ntCoeffs))) 1179 { 1180 number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs); 1181 n_Delete(&c,ntCoeffs); 1182 c=cc; 1183 pIter(p); 1184 }; 1185 p=DEN(f); 1186 while((p!=NULL)&&(!n_IsOne(c,ntCoeffs))) 1187 { 1188 number cc=n_Gcd(c,pGetCoeff(p),ntCoeffs); 1189 n_Delete(&c,ntCoeffs); 1190 c=cc; 1191 pIter(p); 1192 }; 1193 if(!n_IsOne(c,ntCoeffs)) 1194 { 1195 p=NUM(f); 1196 do 1197 { 1198 number cc=n_Div(pGetCoeff(p),c,ntCoeffs); 1199 n_Normalize(cc,ntCoeffs); 1200 p_SetCoeff(p,cc,ntRing); 1201 pIter(p); 1202 } while(p!=NULL); 1203 p=DEN(f); 1204 do 1205 { 1206 number cc=n_Div(pGetCoeff(p),c,ntCoeffs); 1207 n_Normalize(cc,ntCoeffs); 1208 p_SetCoeff(p,cc,ntRing); 1209 pIter(p); 1210 } while(p!=NULL); 1211 n_Delete(&c,ntCoeffs); 1212 if(pNext(DEN(f))==NULL) 1213 { 1214 if (p_IsOne(DEN(f),ntRing)) 1215 { 1216 p_LmDelete(&DEN(f),ntRing); 1217 COM(f)=0; 1218 return; 1219 } 1220 else 1221 { 1222 return; 1223 } 1224 } 1225 } 1226 } 1171 1227 1172 1228 #ifdef HAVE_FACTORY 1173 /* Note that, over Q, singclap_gcd will remove the denominators in all 1174 rational coefficients of pNum and pDen, before starting to compute 1175 the gcd. Thus, we do not need to ensure that the coefficients of 1176 pNum and pDen live in Z; they may well be elements of Q\Z. */ 1177 /* singclap_gcd destroys its arguments; we hence need copies: */ 1178 poly pGcd = singclap_gcd(p_Copy(NUM(f), ntRing), p_Copy(DEN(f), ntRing), cf->extRing); 1179 if (p_IsConstant(pGcd, ntRing) && 1180 n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs)) 1229 poly pGcd; 1230 /* here we assume: NUM(f), DEN(f) !=NULL, in Z_a reqp. Z/p_a */ 1231 pGcd = singclap_gcd_r(NUM(f), DEN(f), ntRing); 1232 if (p_IsConstant(pGcd, ntRing) 1233 //&& n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs) 1234 ) 1181 1235 { /* gcd = 1; nothing to cancel; 1182 1236 Suppose the given rational function field is over Q. Although the … … 1350 1404 the gcd. Thus, we do not need to ensure that the coefficients of 1351 1405 pa and pb live in Z; they may well be elements of Q\Z. */ 1352 poly pGcd = singclap_gcd(pa, pb, cf->extRing);1406 poly pGcd = singclap_gcd(pa, pb, ntRing); 1353 1407 if (p_IsConstant(pGcd, ntRing) && 1354 1408 n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs)) -
libpolys/polys/monomials/p_polys.cc
radae8b r5a4e17 1237 1237 #ifdef HAVE_RINGS 1238 1238 if (rField_is_Ring(r)) 1239 1240 1241 1242 1239 { 1240 if (p == NULL) return 0; 1241 if (!n_IsUnit(pGetCoeff(p), r->cf)) return 0; 1242 } 1243 1243 #endif 1244 1244 int i,k=0; … … 2178 2178 p=ph; 2179 2179 while (p!=NULL) 2180 { // each monom: coeff in Q_a 2180 { // each monom: coeff in Q_a (Z_a) 2181 2181 fraction f=(fraction)pGetCoeff(p); 2182 2182 poly c_n=NUM(f); … … 2187 2187 } 2188 2188 while ((c_n!=NULL)&&(!n_IsOne(hzz,r->cf->extRing->cf))) 2189 { // each monom: coeff in Q 2189 { // each monom: coeff in Q (Z) 2190 2190 d=n_Gcd(hzz,pGetCoeff(c_n),r->cf->extRing->cf); 2191 2191 n_Delete(&hzz,r->cf->extRing->cf); … … 2203 2203 p=ph; 2204 2204 while (p!=NULL) 2205 { // each monom: coeff in Q_a 2205 { // each monom: coeff in Q_a (Z_a) 2206 2206 fraction f=(fraction)pGetCoeff(p); 2207 2207 NUM(f)=p_Mult_nn(NUM(f),h,r->cf->extRing); … … 2550 2550 p_SetCoeff(p,n_Init(1,r->cf),r); 2551 2551 2552 assume( n_GreaterZero(pGetCoeff(p),C) );2552 /*assume( n_GreaterZero(pGetCoeff(p),C) ); 2553 2553 if(!n_GreaterZero(pGetCoeff(p),C)) p = p_Neg(p,r); 2554 2554 */ 2555 2555 return p; 2556 2556 } … … 2613 2613 n_Delete(&h,r->cf); 2614 2614 } 2615 if (h!=NULL)n_Delete(&h,r->cf);2615 n_Delete(&h,r->cf); 2616 2616 p=start; 2617 2617 … … 2832 2832 p_Content(ph,r); 2833 2833 if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r); 2834 2834 assume( n_GreaterZero(pGetCoeff(ph),C) ); 2835 2835 return; 2836 2836 }
Note: See TracChangeset
for help on using the changeset viewer.