Changeset a355723 in git
- Timestamp:
- Oct 22, 2012, 2:45:46 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 314f0a2563593c2ed06d4bf520c64eabc6b2c701becbea965e6c5de8e8ab195c7f480cabc295ac0c
- Parents:
- b79ed5b79606bbec4a3bc2f9ad41e76c5d40137e
- Location:
- libpolys/polys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/clapsing.cc
rb79ed5 ra355723 177 177 CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) ); 178 178 res= convFactoryPSingTrP( resultant( F, G, X ),r ); 179 if ((nf!=NULL)&&(!n_IsOne(nf,r->cf)) &&(!n_IsZero(nf,r->cf)))179 if ((nf!=NULL)&&(!n_IsOne(nf,r->cf))) 180 180 { 181 181 number n=n_Invers(nf,r->cf); … … 188 188 } 189 189 n_Delete(&nf,r->cf); 190 if ((ng!=NULL)&&(!n_IsOne(ng,r->cf)) &&(!n_IsZero(ng,r->cf)))190 if ((ng!=NULL)&&(!n_IsOne(ng,r->cf))) 191 191 { 192 192 number n=n_Invers(ng,r->cf); -
libpolys/polys/ext_fields/transext.cc
rb79ed5 ra355723 161 161 162 162 const poly den = DEN(t); 163 163 164 164 if (den != NULL) // !DENIS1(f) 165 165 { 166 166 assume( p_Test(den, ntRing) ); 167 167 168 168 if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntRing->cf))) 169 169 { … … 171 171 return FALSE; 172 172 } 173 173 174 174 if( !n_GreaterZero(pGetCoeff(den), ntRing->cf) ) 175 175 { … … 177 177 return FALSE; 178 178 } 179 179 180 180 // test that den is over integers!? 181 181 182 182 } else 183 183 { // num != NULL // den == NULL 184 184 185 185 // if( COM(t) != 0 ) 186 186 // { 187 // Print("?//NULL with non-zero complexity: %d in %s:%d\n", COM(t), f, l); 187 // Print("?//NULL with non-zero complexity: %d in %s:%d\n", COM(t), f, l); 188 188 // return FALSE; 189 189 // } … … 293 293 ntTest(a); 294 294 definiteGcdCancellation(a, cf, FALSE); 295 295 296 296 if (IS0(a)) return NULL; 297 297 … … 307 307 { 308 308 assume( DEN (f) == NULL ); 309 309 310 310 number g; 311 311 // TODO/NOTE: the following should not be necessary (due to 312 // Hannes!) as NUM (f) should be over Z!!! 312 // Hannes!) as NUM (f) should be over Z!!! 313 313 CPolyCoeffsEnumerator itr(NUM(f)); 314 314 … … 324 324 325 325 // g should be a positive integer now! 326 assume( n_GreaterZero(g, ntRing->cf) ); 327 326 assume( n_GreaterZero(g, ntRing->cf) ); 327 328 328 if( !n_IsOne(g, ntRing->cf) ) 329 329 { 330 330 DEN (f) = p_NSet(g, ntRing); // update COM(f)??? 331 331 COM (f) ++; 332 assume( DEN (f) != NULL ); 332 assume( DEN (f) != NULL ); 333 333 } 334 334 else … … 339 339 340 340 // Call ntNormalize instead of above?!? 341 341 342 342 NUM (result) = p_Copy (NUM (f), ntRing); // ??? 343 343 DEN (result) = NULL; 344 344 COM (result) = 0; 345 345 346 346 ntTest((number)result); 347 347 return (number)result; … … 361 361 362 362 const BOOLEAN denis1 = DENIS1 (f); 363 363 364 364 if( IS0(f) || (denis1 && getCoeffType (ntCoeffs) != n_Q) ) // */1 or 0 365 365 { … … 388 388 // NUM (result) = p_One(ntRing); // NOTE: just in order to be sure... 389 389 } 390 390 391 391 // */1 / Q 392 392 assume( getCoeffType (ntCoeffs) == n_Q ); 393 assume( DEN (f) == NULL ); 394 395 number g; 393 assume( DEN (f) == NULL ); 394 395 number g; 396 396 // poly num= p_Copy (NUM (f), ntRing); // ??? 397 397 … … 400 400 // Hannes!) as NUM (f) should be over Z!!! 401 401 CPolyCoeffsEnumerator itr(NUM(f)); 402 403 n_ClearDenominators(itr, g, ntRing->cf); // may return -1 :((( 402 403 n_ClearDenominators(itr, g, ntRing->cf); // may return -1 :((( 404 404 // nlClearDenominators(itr, g, ntRing->cf); 405 405 406 406 407 407 if( !n_GreaterZero(g, ntRing->cf) ) 408 408 { … … 414 414 415 415 // g should be a positive integer now! 416 assume( n_GreaterZero(g, ntRing->cf) ); 416 assume( n_GreaterZero(g, ntRing->cf) ); 417 417 418 418 if( !n_IsOne(g, ntRing->cf) ) … … 420 420 assume( n_GreaterZero(g, ntRing->cf) ); 421 421 assume( !n_IsOne(g, ntRing->cf) ); 422 422 423 423 DEN (f) = p_NSet(g, ntRing); // update COM(f)??? 424 424 assume( DEN (f) != NULL ); 425 425 COM (f) ++; 426 426 427 427 NUM (result)= p_Copy (DEN (f), ntRing); 428 428 } … … 431 431 NUM (result)= p_NSet(g, ntRing); // p_Copy (DEN (f), ntRing); 432 432 // n_Delete(&g, ntRing->cf); 433 } 434 433 } 434 435 435 // if (!p_IsConstant (num, ntRing) && pNext(num) != NULL) 436 436 // else … … 444 444 BOOLEAN ntIsOne(number a, const coeffs cf) 445 445 { 446 ntTest(a); // !!! 446 ntTest(a); // !!! 447 447 definiteGcdCancellation(a, cf, FALSE); 448 448 fraction f = (fraction)a; … … 498 498 n_Delete(&n, C); 499 499 return NULL; 500 } 500 } 501 501 502 502 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 503 503 504 504 number den = n_GetDenom(n, C); 505 505 506 506 assume( n_GreaterZero(den, C) ); 507 507 508 508 if( n_IsOne(den, C) ) 509 509 { 510 510 NUM(result) = p_NSet(n, A); 511 DEN(result) = NULL; 512 n_Delete(&den, C); 511 DEN(result) = NULL; 512 n_Delete(&den, C); 513 513 } else 514 514 { 515 DEN(result) = p_NSet(den, A); 516 NUM(result) = p_NSet(n_GetNumerator(n, C), A); 517 n_Delete(&n, C); 515 DEN(result) = p_NSet(den, A); 516 NUM(result) = p_NSet(n_GetNumerator(n, C), A); 517 n_Delete(&n, C); 518 518 } 519 519 … … 525 525 } 526 526 527 527 528 528 number ntInit(long i, const coeffs cf) 529 529 { … … 545 545 { 546 546 if (p == 0) return NULL; 547 547 548 548 number g; 549 549 // TODO/NOTE: the following should not be necessary (due to 550 // Hannes!) as NUM (f) should be over Z!!! 550 // Hannes!) as NUM (f) should be over Z!!! 551 551 CPolyCoeffsEnumerator itr(p); 552 552 … … 561 561 562 562 // g should be a positive integer now! 563 assume( n_GreaterZero(g, ntRing->cf) ); 563 assume( n_GreaterZero(g, ntRing->cf) ); 564 564 565 565 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 566 566 567 567 if( !n_IsOne(g, ntRing->cf) ) 568 568 { 569 DEN (f) = p_NSet(g, ntRing); 569 DEN (f) = p_NSet(g, ntRing); 570 570 // COM (f) ++; // update COM(f)??? 571 assume( DEN (f) != NULL ); 571 assume( DEN (f) != NULL ); 572 572 } 573 573 else 574 574 { 575 DEN(f) = NULL; 575 DEN(f) = NULL; 576 576 n_Delete(&g, ntRing->cf); 577 } 578 577 } 578 579 579 NUM(f) = p; 580 580 COM(f) = 0; … … 591 591 fraction f = (fraction)a; 592 592 if (!DENIS1(f)) return 0; 593 593 594 594 const poly aAsPoly = NUM(f); 595 595 596 596 if(aAsPoly == NULL) 597 597 return 0; 598 598 599 599 if (!p_IsConstant(aAsPoly, ntRing)) 600 600 return 0; 601 601 602 602 assume( aAsPoly != NULL ); 603 603 604 604 return n_Int(p_GetCoeff(aAsPoly, ntRing), ntCoeffs); 605 605 } … … 720 720 721 721 // ntTest((number)result); 722 722 723 723 return (number)result; 724 724 } … … 763 763 ntTest(a); // !!!? 764 764 ntTest(b); // !!!? 765 765 766 766 if (IS0(a) || IS0(b)) return NULL; 767 767 … … 780 780 const poly db = DEN(fb); 781 781 782 782 783 783 if (db == NULL) 784 784 { 785 785 // b = ? // NULL 786 786 787 787 if(da == NULL) 788 788 { // both fa && fb are ?? // NULL! … … 791 791 COM(result) = 0; 792 792 } 793 else 793 else 794 794 { 795 795 assume (da != NULL && db == NULL); … … 817 817 818 818 // ntTest((number)result); 819 819 820 820 return (number)result; 821 821 } … … 1046 1046 p_Delete(&DEN(f), ntRing); DEN(f) = NULL; 1047 1047 } 1048 1048 1049 1049 if( DEN(f) != NULL ) 1050 1050 if( !n_GreaterZero(pGetCoeff(DEN(f)), ntCoeffs) ) … … 1052 1052 NUM(f) = p_Neg(NUM(f), ntRing); 1053 1053 DEN(f) = p_Neg(DEN(f), ntRing); 1054 } 1055 1054 } 1055 1056 1056 ntTest((number)f); // TODO! 1057 1057 } … … 1076 1076 } else 1077 1077 { 1078 if (COM(f) > BOUND_COMPLEXITY) 1078 if (COM(f) > BOUND_COMPLEXITY) 1079 1079 definiteGcdCancellation(a, cf, TRUE); 1080 1080 … … 1085 1085 NUM(f) = p_Neg(NUM(f), ntRing); 1086 1086 DEN(f) = p_Neg(DEN(f), ntRing); 1087 } 1088 } 1089 1090 1087 } 1088 } 1089 1090 1091 1091 ntTest(a); // !!!!???? 1092 1092 } … … 1164 1164 NUM(f) = p_Neg(NUM(f), ntRing); 1165 1165 DEN(f) = p_Neg(DEN(f), ntRing); 1166 } 1166 } 1167 1167 #endif /* HAVE_FACTORY */ 1168 1168 1169 1169 ntTest(a); // !!!! 1170 1170 } … … 1192 1192 p_String0Long(DEN(f), ntRing, ntRing); 1193 1193 if (!omitBrackets) StringAppendS(")"); 1194 } 1194 } 1195 1195 } 1196 1196 ntTest(a); // !!!! … … 1259 1259 } 1260 1260 1261 return FALSE; 1261 return FALSE; 1262 1262 } 1263 1263 … … 1287 1287 1288 1288 ntTest((number)result); // !!!! 1289 1289 1290 1290 return (number)result; 1291 1291 } 1292 1292 1293 1293 1294 1294 /* return pa*pb/gcd */ … … 1299 1299 ntTest((number)result); // !!!! 1300 1300 return (number)result; 1301 1301 1302 1302 #else 1303 1303 Print("// factory needed: transext.cc:ntLcm\n"); … … 1378 1378 ntTest(a); 1379 1379 if (IS0(a)) 1380 { 1380 { 1381 1381 WerrorS(nDivBy0); 1382 1382 return NULL; 1383 } 1383 } 1384 1384 fraction f = (fraction)a; 1385 1385 assume( f != NULL ); … … 1389 1389 assume( NUM(f) != NULL ); 1390 1390 const poly den = DEN(f); 1391 1391 1392 1392 if (den == NULL) 1393 1393 NUM(result) = p_One(ntRing); … … 1397 1397 if( !NUMIS1(f) ) 1398 1398 { 1399 DEN(result) = p_Copy(NUM(f), ntRing); 1399 poly num_f=NUM(f); 1400 BOOLEAN neg= !n_GreaterZero(pGetCoeff(num_f),ntRing->cf); 1401 if (neg) 1402 { 1403 num_f=p_Neg(p_Copy(num_f, ntRing), ntRing); 1404 NUM(result)=p_Neg(NUM(result), ntRing); 1405 } 1406 else 1407 { 1408 num_f=p_Copy(num_f, ntRing); 1409 } 1410 DEN(result) = num_f; 1400 1411 COM(result) = COM(f); 1412 if (neg) 1413 { 1414 if (p_IsOne(num_f, ntRing)) 1415 { 1416 DEN(result)=NULL; 1417 COM(result) = 0; 1418 p_Delete(&num_f,ntRing); 1419 } 1420 } 1401 1421 } 1402 1422 else … … 1439 1459 { 1440 1460 // if (n_IsZero(a, cf)) return NULL; 1441 1461 1442 1462 ntTest(a); 1443 1463 1444 1464 if (IS0(a)) return NULL; 1445 1465 1446 1466 const ring rSrc = cf->extRing; 1447 1467 const ring rDst = dst->extRing; 1448 1468 1449 1469 if( rSrc == rDst ) 1450 1470 return ntCopy(a, dst); // USUALLY WRONG! 1451 1471 1452 1472 fraction f = (fraction)a; 1453 1473 poly g = prCopyR(NUM(f), rSrc, rDst); 1454 1474 1455 1475 poly h = NULL; 1456 1476 1457 1477 if (!DENIS1(f)) 1458 1478 h = prCopyR(DEN(f), rSrc, rDst); 1459 1479 1460 1480 fraction result = (fraction)omAlloc0Bin(fractionObjectBin); 1461 1481 1462 1482 NUM(result) = g; 1463 1483 DEN(result) = h; 1464 1484 COM(result) = COM(f); 1465 1485 assume(n_Test((number)result, dst)); 1466 return (number)result; 1486 return (number)result; 1467 1487 } 1468 1488 … … 1471 1491 assume( n_Test(a, cf) ); 1472 1492 if (n_IsZero(a, cf)) return NULL; 1473 1474 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 1493 1494 fraction f = (fraction)omAlloc0Bin(fractionObjectBin); 1475 1495 // DEN(f) = NULL; COM(f) = 0; 1476 1496 NUM(f) = prCopyR((poly)a, cf->extRing, dst->extRing); … … 1492 1512 return NULL; 1493 1513 } 1494 1514 1495 1515 poly g = p_NSet(q, dst->extRing); 1496 1516 … … 1576 1596 if (nCoeff_is_Q(bSrc) && nCoeff_is_Q(bDst)) 1577 1597 { 1578 if (rVar(src->extRing) > rVar(dst->extRing)) 1598 if (rVar(src->extRing) > rVar(dst->extRing)) 1579 1599 return NULL; 1580 1600 1581 1601 for (int i = 0; i < rVar(src->extRing); i++) 1582 if (strcmp(rRingVar(i, src->extRing), rRingVar(i, dst->extRing)) != 0) 1583 1584 1602 if (strcmp(rRingVar(i, src->extRing), rRingVar(i, dst->extRing)) != 0) 1603 return NULL; 1604 1585 1605 if (src->type==n_transExt) 1586 1606 return ntCopyMap; /// Q(T') --> Q(T) … … 1591 1611 if (nCoeff_is_Zp(bSrc) && nCoeff_is_Zp(bDst)) 1592 1612 { 1593 if (rVar(src->extRing) > rVar(dst->extRing)) 1613 if (rVar(src->extRing) > rVar(dst->extRing)) 1594 1614 return NULL; 1595 1615 1596 1616 for (int i = 0; i < rVar(src->extRing); i++) 1597 if (strcmp(rRingVar(i, src->extRing), rRingVar(i, dst->extRing)) != 0) 1598 1599 1617 if (strcmp(rRingVar(i, src->extRing), rRingVar(i, dst->extRing)) != 0) 1618 return NULL; 1619 1600 1620 if (src->type==n_transExt) 1601 1621 return ntCopyMap; /// Z/p(T') --> Z/p(T) … … 1716 1736 const ring R = cf->extRing; 1717 1737 assume(R != NULL); 1718 const coeffs Q = R->cf; 1719 assume(Q != NULL); 1720 assume(nCoeff_is_Q(Q)); 1721 1722 1738 const coeffs Q = R->cf; 1739 assume(Q != NULL); 1740 assume(nCoeff_is_Q(Q)); 1741 1742 1723 1743 numberCollectionEnumerator.Reset(); 1724 1744 … … 1760 1780 while( numberCollectionEnumerator.MoveNext() ) ; 1761 1781 1762 1782 1763 1783 // part2: all coeffs = all coeffs * cand 1764 1784 if( cand != NULL ) … … 1766 1786 if( !p_IsConstant(cand, R) ) 1767 1787 { 1768 c = ntInit(cand, cf); 1788 c = ntInit(cand, cf); 1769 1789 numberCollectionEnumerator.Reset(); 1770 1790 while (numberCollectionEnumerator.MoveNext() ) … … 1778 1798 else { p_Delete(&cand, R); cand = NULL; } 1779 1799 } 1780 1800 1781 1801 // Quick and dirty fix for constant content clearing: consider numerators??? 1782 1802 CRecursivePolyCoeffsEnumerator<NTNumConverter> itr(numberCollectionEnumerator); // recursively treat the NUM(numbers) as polys! 1783 1803 number cc; 1784 1804 1785 1805 // nlClearContentNoPositiveLead(itr, cc, Q); // TODO: get rid of (-LC) normalization!? 1786 1806 nlClearContent(itr, cc, Q); 1787 1807 number g = ntInit(p_NSet(cc, R), cf); 1788 1808 1789 1809 if( cand != NULL ) 1790 1810 { 1791 1811 number gg = ntMult(g, c, cf); 1792 ntDelete(&g, cf); 1812 ntDelete(&g, cf); 1793 1813 ntDelete(&c, cf); c = gg; 1794 } else 1814 } else 1795 1815 c = g; 1796 1816 ntTest(c); … … 1817 1837 1818 1838 const ring R = cf->extRing; 1819 assume(R != NULL); 1820 1821 const coeffs Q = R->cf; 1822 assume(Q != NULL); 1823 // assume(nCoeff_is_Q(Q)); 1839 assume(R != NULL); 1840 1841 const coeffs Q = R->cf; 1842 assume(Q != NULL); 1843 // assume(nCoeff_is_Q(Q)); 1824 1844 1825 1845 do 1826 1846 { 1827 1847 number &n = numberCollectionEnumerator.Current(); 1828 1848 1829 1849 ntNormalize(n, cf); 1830 1850 … … 1847 1867 poly gcd = singclap_gcd(p_Copy(cand, R), p_Copy(den, R), R); // gcd(cand, den) is monic no mater leading coeffs! :(((( 1848 1868 // assume( n_IsOne(pGetCoeff(gcd), Q) ); // TODO: this may be wrong... 1849 cand = p_Mult_q(cand, p_Copy(den, R), R); // cand *= den 1869 cand = p_Mult_q(cand, p_Copy(den, R), R); // cand *= den 1850 1870 const poly t = singclap_pdivide( cand, gcd, R ); // cand' * den / gcd(cand', den) 1851 1871 p_Delete(&cand, R); … … 1860 1880 c = ntInit(1, cf); 1861 1881 return; 1862 } 1863 1864 c = ntInit(cand, cf); 1882 } 1883 1884 c = ntInit(cand, cf); 1865 1885 1866 1886 numberCollectionEnumerator.Reset(); 1867 1887 1868 1888 number d = NULL; 1869 1889 … … 1876 1896 ntNormalize(t, cf); // TODO: needed? 1877 1897 n = t; 1878 1898 1879 1899 fraction f = (fraction)t; 1880 1900 assume( f != NULL ); … … 1886 1906 assume( p_IsConstant(den, R) ); 1887 1907 assume( pNext(den) == NULL ); 1888 1908 1889 1909 if( d == NULL ) 1890 1910 d = n_Copy(pGetCoeff(den), Q); 1891 1911 else 1892 1912 { 1893 1913 number g = n_Lcm(d, pGetCoeff(den), Q); 1894 1914 n_Delete(&d, Q); d = g; 1895 1915 } 1896 1916 } 1897 1917 } 1898 1918 1899 1919 if( d != NULL ) 1900 1920 { … … 1915 1935 assume( p_IsConstant(den, R) ); 1916 1936 assume( pNext(den) == NULL ); 1917 1918 1937 1938 number ddd = n_Div(d, pGetCoeff(den), Q); // but be an integer now!!! 1919 1939 NUM(f) = p_Mult_nn(NUM(f), ddd, R); 1920 1921 1922 p_Delete(&DEN(f), R); 1923 1924 } 1925 1940 n_Delete(&ddd, Q); 1941 1942 p_Delete(&DEN(f), R); 1943 DEN(f) = NULL; // TODO: check if this is needed!? 1944 } 1945 1926 1946 assume( DEN(f) == NULL ); 1927 1947 } 1928 1948 1929 1949 NUM(c) = p_Mult_nn(NUM(c), d, R); 1930 1950 n_Delete(&d, Q); 1931 1951 } 1932 1933 1952 1953 1934 1954 ntTest(c); 1935 1955 } … … 1951 1971 ring R = e->r; 1952 1972 assume(R != NULL); 1953 1973 1954 1974 R->ref ++; // increase the ref.counter for the ground poly. ring! 1955 1975 … … 1959 1979 cf->ch = R->cf->ch; 1960 1980 cf->factoryVarOffset = R->cf->factoryVarOffset + rVar(R); 1961 1981 1962 1982 cf->cfGreaterZero = ntGreaterZero; 1963 1983 cf->cfGreater = ntGreater; -
libpolys/polys/monomials/p_polys.cc
rb79ed5 ra355723 2712 2712 } 2713 2713 2714 assume( n_GreaterZero(pGetCoeff(ph),C) );2715 2714 if(!n_GreaterZero(pGetCoeff(ph),C)) 2716 2715 {
Note: See TracChangeset
for help on using the changeset viewer.