Changeset f0b01f in git
- Timestamp:
- May 19, 2011, 10:30:09 AM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
- Children:
- c28ecf1b368527a9ec9e39a3db43a7b75040f036
- Parents:
- c5484888248231a7dfff33b9693cdd46980c1448
- git-author:
- Frank Seelisch <seelisch@mathematik.uni-kl.de>2011-05-19 10:30:09+02:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:36:12+01:00
- Location:
- libpolys/polys
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/algext.cc
rc54848 rf0b01f 74 74 { 75 75 assume(getCoeffType(cf) == naID); 76 #ifdef LDEBUG 77 omCheckAddr(&a); 78 #endif 76 if (a == NULL) return TRUE; 77 p_Test((poly)a, naRing); // cannot use omCheckAddrSize(a, sizeof(*a)) here 79 78 assume(p_Deg((poly)a, naRing) <= p_Deg(naMinpoly, naRing)); 80 79 return TRUE; … … 430 429 omCheckAddr(p); omCheckAddr(reducer); 431 430 #endif 432 p_PolyDiv( &p, reducer, FALSE, naRing);431 p_PolyDiv(p, reducer, FALSE, naRing); 433 432 } 434 433 … … 444 443 naTest(a); 445 444 if (a == NULL) WerrorS(nDivBy0); 446 poly *aFactor; poly *mFactor;445 poly aFactor; poly mFactor; 447 446 poly theGcd = p_ExtGcd((poly)a, aFactor, naMinpoly, mFactor, naRing); 448 447 /* the gcd must be one since naMinpoly is irreducible and a != NULL: */ 449 448 assume(naIsOne((number)theGcd, cf)); 450 449 p_Delete(&theGcd, naRing); 451 p_Delete( mFactor, naRing);452 return (number)( *aFactor);450 p_Delete(&mFactor, naRing); 451 return (number)(aFactor); 453 452 } 454 453 -
libpolys/polys/monomials/p_polys.cc
rc54848 rf0b01f 1430 1430 } 1431 1431 1432 /* assumes that *p and divisor are univariate polynomials in r,1432 /* assumes that p and divisor are univariate polynomials in r, 1433 1433 mentioning the same variable; 1434 1434 assumes divisor != NULL; 1435 *p may be NULL;1435 p may be NULL; 1436 1436 assumes a global monomial ordering in r; 1437 performs polynomial division of *p by divisor:1438 - afterwards *p contains the remainder of the division, i.e.,1439 *p_before = result * divisor + *p_afterwards;1437 performs polynomial division of p by divisor: 1438 - afterwards p contains the remainder of the division, i.e., 1439 p_before = result * divisor + p_afterwards; 1440 1440 - if needResult == TRUE, then the method computes and returns 'result', 1441 1441 otherwise NULL is returned (This parametrization can be used when 1442 1442 one is only interested in the remainder of the division. In this 1443 case, the method will be faster.) */ 1444 poly p_PolyDiv(poly * p, poly divisor, BOOLEAN needResult, ring r) 1445 { 1443 case, the method will be slightly faster.) 1444 leaves divisor unmodified */ 1445 poly p_PolyDiv(poly &p, poly divisor, BOOLEAN needResult, ring r) 1446 { 1447 //printf("p_PolyDiv:\n"); 1446 1448 assume(divisor != NULL); 1447 if ( *p == NULL) return NULL;1449 if (p == NULL) return NULL; 1448 1450 1449 1451 poly result = NULL; 1450 number divisorLT = p_GetCoeff(divisor, r); 1451 int divisorExp = p_GetExp(divisor, 1, r); 1452 while (p_Deg(*p, r) > p_Deg(divisor, r)) 1453 { 1454 /* determine t = LT(*p) / LT(divisor) */ 1452 number divisorLC = p_GetCoeff(divisor, r); 1453 int divisorLE = p_GetExp(divisor, 1, r); 1454 //p_Write(p, r); p_Write(divisor, r); 1455 while ((p != NULL) && (p_Deg(p, r) > p_Deg(divisor, r))) 1456 { 1457 /* determine t = LT(p) / LT(divisor) */ 1455 1458 poly t = p_ISet(1, r); 1456 number c = n_Div(p_GetCoeff( *p, r), divisorLT, r->cf);1459 number c = n_Div(p_GetCoeff(p, r), divisorLC, r->cf); 1457 1460 p_SetCoeff(t, c, r); 1458 int e = p_GetExp( *p, 1, r) - divisorExp;1461 int e = p_GetExp(p, 1, r) - divisorLE; 1459 1462 p_SetExp(t, 1, e, r); 1460 1463 p_Setm(t, r); 1461 result = p_Add_q(result, p_Copy(t, r), r); 1462 *p = p_Add_q(*p, p_Neg(t, r), r); 1463 } 1464 n_Delete(&divisorLT, r->cf); 1464 //printf("t\n"); p_Write(t, r); 1465 if (needResult) result = p_Add_q(result, p_Copy(t, r), r); 1466 //t = p_Mult_q(t, p_Copy(divisor, r), r); p_Write(t, r); 1467 //t = p_Neg(t, r); p_Write(t, r); 1468 //printf("p\n"); p_Write(p, r); 1469 //t = p_Add_q(p, t, r); p_Write(t, r); 1470 //p = t; 1471 p = p_Add_q(p, p_Neg(p_Mult_q(t, p_Copy(divisor, r), r), r), r); 1472 //printf("EXECUTION STOPPED\n"); while (1) { }; 1473 } 1474 n_Delete(&divisorLC, r->cf); 1465 1475 return result; 1466 1476 } 1467 1477 1468 1478 /* see p_Gcd; 1469 additional assumption: deg( *p) >= deg(*q);1470 must destroy *p and *q (unless one of them is returned) */1471 poly p_GcdHelper(poly * p, poly *q, ring r)1472 { 1473 if (q == NULL) return *p;1479 additional assumption: deg(p) >= deg(q); 1480 must destroy p and q (unless one of them is returned) */ 1481 poly p_GcdHelper(poly &p, poly &q, ring r) 1482 { 1483 if (q == NULL) return p; 1474 1484 else 1475 1485 { 1476 p_PolyDiv(p, *q, FALSE, r);1486 p_PolyDiv(p, q, FALSE, r); 1477 1487 return p_GcdHelper(q, p, r); 1478 1488 } … … 1492 1502 if (p_Deg(a, r) < p_Deg(b, r)) { a = q; b = p; } 1493 1503 a = p_Copy(a, r); b = p_Copy(b, r); 1494 return p_GcdHelper( &a, &b, r);1504 return p_GcdHelper(a, b, r); 1495 1505 } 1496 1506 1497 1507 /* see p_ExtGcd; 1498 additional assumption: deg( *p) >= deg(*q);1499 must destroy *p and *q (unless one of them is returned) */1500 poly p_ExtGcdHelper(poly * p, poly * pFactor, poly * q, poly *qFactor,1508 additional assumption: deg(p) >= deg(q); 1509 must destroy p and q (unless one of them is returned) */ 1510 poly p_ExtGcdHelper(poly &p, poly &pFactor, poly &q, poly &qFactor, 1501 1511 ring r) 1502 1512 { 1513 //printf("p_ExtGcdHelper:\n"); 1503 1514 if (q == NULL) 1504 1515 { 1505 *qFactor = NULL; *pFactor = p_ISet(1, r); return *p;1516 qFactor = NULL; pFactor = p_ISet(1, r); return p; 1506 1517 } 1507 1518 else 1508 1519 { 1509 poly pDivQ = p_PolyDiv(p, *q, TRUE, r); 1510 poly * ppFactor; poly * qqFactor; 1520 //p_Write(p, r); p_Write(q, r); 1521 poly pDivQ = p_PolyDiv(p, q, TRUE, r); 1522 poly ppFactor; poly qqFactor; 1511 1523 poly theGcd = p_ExtGcdHelper(q, ppFactor, p, qqFactor, r); 1512 1524 pFactor = qqFactor; 1513 *qFactor = p_Add_q(*ppFactor,1514 p_Neg(p_Mult_q(pDivQ, p_Copy(*qqFactor, r), r), r),1515 1525 qFactor = p_Add_q(ppFactor, 1526 p_Neg(p_Mult_q(pDivQ, p_Copy(qqFactor, r), r), r), 1527 r); 1516 1528 return theGcd; 1517 1529 } … … 1523 1535 assumes that not both p and q are NULL; 1524 1536 returns the gcd of p and q; 1525 moreover, afterwards *pFactor and *qFactor contain appropriate1526 factors such that gcd(p, q) = p * (*pFactor) + q * (*qFactor);1537 moreover, afterwards pFactor and qFactor contain appropriate 1538 factors such that gcd(p, q) = p * pFactor + q * qFactor; 1527 1539 leaves p and q unmodified */ 1528 poly p_ExtGcd(poly p, poly * pFactor, poly q, poly * qFactor, ring r) 1529 { 1530 assume((p != NULL) || (q != NULL)); 1531 1540 poly p_ExtGcd(poly p, poly &pFactor, poly q, poly &qFactor, ring r) 1541 { 1542 //printf("p_ExtGcd:\n"); 1543 //p_Write(p, r); p_Write(q, r); 1544 assume((p != NULL) || (q != NULL)); 1532 1545 poly a = p; poly b = q; 1533 poly * aFactor = pFactor; poly *bFactor = qFactor;1546 poly aFactor = pFactor; poly bFactor = qFactor; 1534 1547 if (p_Deg(a, r) < p_Deg(b, r)) 1535 1548 { a = q; b = p; aFactor = qFactor, bFactor = pFactor; } 1536 1549 a = p_Copy(a, r); b = p_Copy(b, r); 1537 return p_ExtGcdHelper( &a, aFactor, &b, bFactor, r);1550 return p_ExtGcdHelper(a, aFactor, b, bFactor, r); 1538 1551 } 1539 1552 -
libpolys/polys/monomials/p_polys.h
rc54848 rf0b01f 1824 1824 int p_Weight(int c, const ring r); 1825 1825 1826 /* assumes that *p and divisor are univariate polynomials in r,1826 /* assumes that p and divisor are univariate polynomials in r, 1827 1827 mentioning the same variable; 1828 1828 assumes divisor != NULL; 1829 *p may be NULL;1829 p may be NULL; 1830 1830 assumes a global monomial ordering in r; 1831 performs polynomial division of *p by divisor:1832 - afterwards *p contains the remainder of the division, i.e.,1833 *p_before = result * divisor + *p_afterwards;1831 performs polynomial division of p by divisor: 1832 - afterwards p contains the remainder of the division, i.e., 1833 p_before = result * divisor + p_afterwards; 1834 1834 - if needResult == TRUE, then the method computes and returns 'result', 1835 1835 otherwise NULL is returned (This parametrization can be used when 1836 1836 one is only interested in the remainder of the division. In this 1837 case, the method will be faster.) */ 1838 poly p_PolyDiv(poly *p, poly divisor, BOOLEAN needResult, ring r); 1839 1840 /* assumes that p and q are univariate polynomials in r, 1841 mentioning the same variable; 1842 assumes a global monomial ordering in r; 1843 assumes that not both p and q are NULL; 1844 returns the gcd of p and q */ 1845 poly p_Gcd(poly p, poly q, ring r); 1837 case, the method will be slightly faster.) 1838 leaves divisor unmodified */ 1839 poly p_PolyDiv(poly &p, poly divisor, BOOLEAN needResult, ring r); 1846 1840 1847 1841 /* assumes that p and q are univariate polynomials in r, … … 1850 1844 assumes that not both p and q are NULL; 1851 1845 returns the gcd of p and q; 1852 moreover, afterwards *pFactor and *qFactor contain appropriate 1853 factors such that gcd(p, q) = p * (*pFactor) + q * (*qFactor) */ 1854 poly p_ExtGcd(poly p, poly *pFactor, poly q, poly *qFactor, ring r); 1846 leaves p and q unmodified */ 1847 poly p_Gcd(poly p, poly q, ring r); 1848 1849 /* assumes that p and q are univariate polynomials in r, 1850 mentioning the same variable; 1851 assumes a global monomial ordering in r; 1852 assumes that not both p and q are NULL; 1853 returns the gcd of p and q; 1854 moreover, afterwards pFactor and qFactor contain appropriate 1855 factors such that gcd(p, q) = p * pFactor + q * qFactor; 1856 leaves p and q unmodified */ 1857 poly p_ExtGcd(poly p, poly &pFactor, poly q, poly &qFactor, ring r); 1855 1858 1856 1859 /* syszygy stuff */
Note: See TracChangeset
for help on using the changeset viewer.