Changeset 67e0dc in git for libpolys/polys/ext_fields/transext.cc
- Timestamp:
- Oct 21, 2015, 2:57:17 PM (9 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 5bd9ec36b87fa8f176a21995de2b56724d67be2d
- Parents:
- a1b6c917a1c8886b1bba1b05680ff06cfd39c82def1a968e317a12b42f88e04cd7f9483e47fba2f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/transext.cc
ref1a96 r67e0dc 72 72 73 73 #ifdef LDEBUG 74 #define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)75 74 BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs r); 76 #else77 #define ntTest(a) do {} while (0)78 75 #endif 76 77 #define ntTest(a) n_Test(a, cf) 79 78 80 79 /// Our own type! … … 184 183 //check_N(a,cf); 185 184 const poly num = NUM(t); 186 assume(num != NULL); / **< t != 0 ==> numerator(t) != 0 */185 assume(num != NULL); ///< t != 0 ==> numerator(t) != 0 187 186 188 187 p_Test(num, ntRing); 189 188 189 if (getCoeffType(ntCoeffs)==n_Q) 190 for( poly p = num; p != NULL; pIter(p) ) 191 if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) ) 192 { 193 Print("ERROR in %s:%d: non-integer Q coeff in num. poly\n",f,l); 194 Print("TERM: "); p_wrp(p, ntRing); PrintLn(); 195 return FALSE; 196 } 197 190 198 const poly den = DEN(t); 191 199 … … 193 201 { 194 202 p_Test(den, ntRing); 203 204 if (getCoeffType(ntCoeffs)==n_Q) 205 for( poly p = den; p != NULL; pIter(p) ) 206 if (! nlIsInteger( p_GetCoeff(p, ntRing), ntCoeffs) ) 207 { 208 Print("ERROR in %s:%d: non-integer Q coeff in den. poly\n",f,l); 209 Print("TERM: "); p_wrp(p, ntRing); PrintLn(); 210 return FALSE; 211 } 212 213 if (getCoeffType(ntCoeffs)==n_Zp) 214 { 215 if( p_IsConstant(den, ntRing) ) 216 { 217 Print("ERROR in %s:%d: constant den. poly / Zp\n",f,l); 218 Print("NUM: "); p_Write(num, ntRing); 219 Print("DEN: "); p_Write(den, ntRing); 220 return FALSE; 221 } 222 223 if( !n_IsOne(pGetCoeff(den), ntCoeffs) ) 224 { 225 Print("ERROR in %s:%d: non-monic den. poly / Zp\n",f,l); 226 Print("NUM: "); p_Write(num, ntRing); 227 Print("DEN: "); p_Write(den, ntRing); 228 return FALSE; 229 } 230 } 231 232 if (COM(t)==0) 233 { 234 poly gcd = singclap_gcd_r( num, den, ntRing ); 235 if( !p_IsOne(gcd, ntRing) ) 236 { 237 Print("ERROR in %s:%d: 1 != GCD between num. & den. poly\n",f,l); 238 Print("GCD: "); p_Write(gcd, ntRing); 239 Print("NUM: "); p_Write(num, ntRing); 240 Print("DEN: "); p_Write(den, ntRing); 241 return FALSE; 242 } 243 p_Delete( &gcd, ntRing ); 244 } 245 return TRUE; 246 247 248 195 249 if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs))) 196 250 { … … 206 260 } 207 261 else 208 { // num != NULL // den == NULL 262 { 263 return TRUE; 264 265 // num != NULL // den == NULL 209 266 // if( COM(t) != 0 ) 210 267 // { … … 279 336 //check_N(*a,cf); 280 337 ntTest(*a); // !!! 338 281 339 fraction f = (fraction)(*a); 282 340 if (IS0(f)) return; … … 580 638 if (p == NULL) return NULL; 581 639 640 p_Test( p, ntRing); 582 641 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 583 642 … … 792 851 COM(result) = COM(fa); 793 852 //check_N((number)result,cf); 853 ntTest((number)result); 794 854 return (number)result; 795 855 } … … 804 864 805 865 //check_N((number)result,cf); 866 ntTest((number)result); 806 867 return (number)result; 807 868 } … … 845 906 846 907 //check_N((number)result,cf); 908 ntTest((number)result); 847 909 return (number)result; 848 910 } … … 883 945 // ntTest((number)result); 884 946 //check_N((number)result,cf); 947 ntTest((number)result); 885 948 return (number)result; 886 949 } … … 953 1016 954 1017 //check_N((number)result,cf); 1018 ntTest((number)result); 955 1019 return (number)result; 956 1020 } … … 989 1053 } 990 1054 COM(result) = COM(fa) + COM(fb) + MULT_COMPLEXITY; 1055 // definiteGcdCancellation((number)result, cf,FALSE); 991 1056 heuristicGcdCancellation((number)result, cf); 992 1057 // ntTest((number)result); 993 1058 //check_N((number)result,cf); 1059 ntTest((number)result); 994 1060 return (number)result; 995 1061 } … … 1186 1252 1187 1253 /* modifies a */ 1254 /* this is an intermediate simplification routine - not a comple "normalize" */ 1188 1255 void heuristicGcdCancellation(number a, const coeffs cf) 1189 1256 { 1190 // ntTest(a); // !!!!????1191 1257 if (IS0(a)) return; 1192 1258 … … 1232 1298 } 1233 1299 } 1234 } 1235 } 1236 1237 ntTest(a); 1300 if ((DEN(f)!=NULL) 1301 && (pNext(DEN(f))==NULL)) 1302 { 1303 poly den_f=DEN(f); 1304 poly h=NUM(f); 1305 loop 1306 { 1307 if (h==NULL) 1308 { 1309 h=NUM(f); 1310 do 1311 { 1312 p_ExpVectorDiff(h,h,den_f,ntRing); 1313 pIter(h); 1314 } while(h!=NULL); 1315 p_ExpVectorDiff(den_f,den_f,den_f,ntRing); 1316 break; 1317 } 1318 int i=0; 1319 do 1320 { 1321 i++; 1322 if (p_GetExp(den_f,i,ntRing) > p_GetExp(h,i,ntRing)) return; 1323 } while(i<ntRing->N); 1324 pIter(h); 1325 } 1326 } 1327 } 1328 } 1238 1329 } 1239 1330 … … 1242 1333 BOOLEAN simpleTestsHaveAlreadyBeenPerformed) 1243 1334 { 1244 ntTest(a); // !!!!1335 // ntTest(a); // !!!! 1245 1336 1246 1337 fraction f = (fraction)a; 1247 1338 1248 1339 if (IS0(a)) return; 1249 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }1340 if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; ntTest(a); return; } 1250 1341 if (!simpleTestsHaveAlreadyBeenPerformed) 1251 1342 { … … 1344 1435 to be != 1. */ 1345 1436 if (p_IsConstant(DEN(f), ntRing) && 1346 1437 n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs)) 1347 1438 { 1348 1439 /* DEN(f) = 1 needs to be represented by NULL! */ … … 1367 1458 } 1368 1459 } 1460 p_Delete(&pGcd, ntRing); 1369 1461 COM(f) = 0; 1370 p_Delete(&pGcd, ntRing);1371 1462 1372 1463 if( DEN(f) != NULL ) 1464 { 1373 1465 if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) ) 1374 1466 { … … 1383 1475 } 1384 1476 } 1477 } 1385 1478 ntTest(a); // !!!! 1386 1479 } … … 1442 1535 if (p == NULL) *a = NULL; 1443 1536 else *a = ntInit(p, cf); 1537 ntTest(*a); 1444 1538 return result; 1445 1539 } … … 1570 1664 return (number)result; 1571 1665 1572 return NULL;1666 return NULL; 1573 1667 } 1574 1668 … … 1661 1755 int noOfTerms = 0; 1662 1756 int numDegree = 0; 1663 while (p != NULL) 1664 { 1665 noOfTerms++; 1666 int d = 0; 1667 for (int i = 1; i <= rVar(ntRing); i++) 1668 d += p_GetExp(p, i, ntRing); 1669 if (d > numDegree) numDegree = d; 1670 pIter(p); 1757 if (p!=NULL) 1758 { 1759 numDegree = p_Totaldegree(p,ntRing); 1760 noOfTerms = pLength(p); 1671 1761 } 1672 1762 int denDegree = 0; 1673 1763 if (!DENIS1(f)) 1674 1764 { 1675 p = DEN(f); 1676 while (p != NULL) 1677 { 1678 noOfTerms++; 1679 int d = 0; 1680 for (int i = 1; i <= rVar(ntRing); i++) 1681 d += p_GetExp(p, i, ntRing); 1682 if (d > denDegree) denDegree = d; 1683 pIter(p); 1684 } 1765 denDegree = p_Totaldegree(DEN(f),ntRing); 1766 noOfTerms += pLength(DEN(f)); 1685 1767 } 1686 1768 ntTest(a); // !!!! … … 1748 1830 number ntMap00(number a, const coeffs src, const coeffs dst) 1749 1831 { 1832 n_Test(a, src); 1833 1750 1834 if (n_IsZero(a, src)) return NULL; 1751 n_Test(a, src);1752 1835 assume(src->rep == dst->extRing->cf->rep); 1753 1836 if ((SR_HDL(a) & SR_INT) || (a->s==3)) 1754 1837 { 1755 1838 number res=ntInit(p_NSet(n_Copy(a, src), dst->extRing), dst); 1756 n_Test(res, dst);1839 n_Test(res, dst); 1757 1840 return res; 1758 1841 } … … 1763 1846 if (n_IsOne(nn,src)) DEN(ff)=NULL; 1764 1847 else DEN(ff)=p_NSet(nn,dst->extRing); 1848 1765 1849 n_Test((number)ff,dst); 1766 1850 //check_N((number)ff,dst); … … 1770 1854 number ntMapZ0(number a, const coeffs src, const coeffs dst) 1771 1855 { 1856 n_Test(a, src); 1772 1857 if (n_IsZero(a, src)) return NULL; 1773 n_Test(a, src);1774 1858 nMapFunc nMap=n_SetMap(src,dst->extRing->cf); 1775 1859 poly p=p_NSet(nMap(a, src,dst->extRing->cf), dst->extRing); … … 1784 1868 number ntMapP0(number a, const coeffs src, const coeffs dst) 1785 1869 { 1870 n_Test(a, src); 1786 1871 if (n_IsZero(a, src)) return NULL; 1787 n_Test(a, src);1788 1872 /* mapping via intermediate int: */ 1789 1873 int n = n_Int(a, src); … … 2380 2464 { 2381 2465 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 2382 int i;2383 2466 2384 2467 poly *P=(poly*)omAlloc(rl*sizeof(poly*)); 2385 2468 number *X=(number *)omAlloc(rl*sizeof(number)); 2469 2470 int i; 2386 2471 2387 2472 for(i=0;i<rl;i++) P[i]=p_Copy(NUM((fraction)(x[i])),cf->extRing); … … 2402 2487 p_Delete(&DEN(result),ntRing); 2403 2488 } 2489 ntTest((number)result); 2404 2490 return ((number)result); 2405 2491 } … … 2411 2497 NUM(result)=p_Farey(p_Copy(NUM((fraction)p),cf->extRing),n,cf->extRing); 2412 2498 DEN(result)=p_Farey(p_Copy(DEN((fraction)p),cf->extRing),n,cf->extRing); 2499 ntTest((number)result); 2413 2500 return ((number)result); 2414 2501 }
Note: See TracChangeset
for help on using the changeset viewer.