Changeset 109e13a in git
- Timestamp:
- Aug 11, 2016, 4:41:59 PM (8 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 75b12a8379e8fdc352f1ced846ad6cb2ee44ec22
- Parents:
- bb3cb8b3f5a0460e54db71baaf57c4d2aa2fd75c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/table.h
rbb3cb8b r109e13a 918 918 { "close", 0, CLOSE_CMD , CMD_1}, 919 919 #ifdef SINGULAR_4_1 920 { " cmatrix", 0, CMATRIX_CMD , ROOT_DECL_LIST},921 { " cnumber", 0, CNUMBER_CMD , ROOT_DECL_LIST},920 { "Matrix", 0, CMATRIX_CMD , ROOT_DECL_LIST}, 921 { "Number", 0, CNUMBER_CMD , ROOT_DECL_LIST}, 922 922 #endif 923 923 { "coef", 0, COEF_CMD , CMD_M}, -
libpolys/coeffs/coeffs.h
rbb3cb8b r109e13a 33 33 n_GF, /**< \GF{p^n < 2^16} */ 34 34 n_long_R, /**< real floating point (GMP) numbers */ 35 n_polyExt, /**< used to represent polys as coeffcients */ 35 36 n_algExt, /**< used for all algebraic extensions, i.e., 36 37 the top-most extension in an extension tower -
libpolys/polys/ext_fields/algext.cc
rbb3cb8b r109e13a 65 65 #endif 66 66 67 /// Our own type!68 static const n_coeffType ID = n_algExt;69 70 67 /* polynomial ring in which our numbers live */ 71 68 #define naRing cf->extRing … … 86 83 BOOLEAN naIsOne(number a, const coeffs cf); 87 84 BOOLEAN naIsMOne(number a, const coeffs cf); 88 BOOLEAN naIsZero(number a, const coeffs cf);89 85 number naInit(long i, const coeffs cf); 90 long naInt(number &a, const coeffs cf);91 86 number naNeg(number a, const coeffs cf); 92 87 number naInvers(number a, const coeffs cf); … … 102 97 number naGetNumerator(number &a, const coeffs cf); 103 98 number naGcd(number a, number b, const coeffs cf); 104 int naSize(number a, const coeffs cf);105 99 void naDelete(number *a, const coeffs cf); 106 100 void naCoeffWrite(const coeffs cf, BOOLEAN details); … … 1037 1031 { 1038 1032 /* dst is expected to be an algebraic field extension */ 1039 assume(getCoeffType(dst) == ID);1033 assume(getCoeffType(dst) == n_algExt); 1040 1034 1041 1035 if( src == dst ) return ndCopyMap; … … 1087 1081 } 1088 1082 1089 staticint naParDeg(number a, const coeffs cf)1083 int naParDeg(number a, const coeffs cf) 1090 1084 { 1091 1085 if (a == NULL) return -1; … … 1095 1089 1096 1090 /// return the specified parameter as a number in the given alg. field 1097 staticnumber naParameter(const int iParameter, const coeffs cf)1098 { 1099 assume(getCoeffType(cf) == ID);1091 number naParameter(const int iParameter, const coeffs cf) 1092 { 1093 assume(getCoeffType(cf) == n_algExt); 1100 1094 1101 1095 const ring R = cf->extRing; … … 1112 1106 int naIsParam(number m, const coeffs cf) 1113 1107 { 1114 assume( getCoeffType(cf) == ID);1108 assume((getCoeffType(cf) == n_algExt)||(getCoeffType(cf) == n_polyExt)); 1115 1109 1116 1110 const ring R = cf->extRing; … … 1121 1115 1122 1116 1123 staticvoid naClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)1117 void naClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 1124 1118 { 1125 1119 assume(cf != NULL); 1126 assume(getCoeffType(cf) == ID);1120 assume(getCoeffType(cf) == n_algExt); 1127 1121 assume(nCoeff_is_Q_algext(cf)); // only over (Q[a]/m(a)), while the default impl. is used over Zp[a]/m(a) ! 1128 1122 … … 1322 1316 1323 1317 1324 staticvoid naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf)1318 void naClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs cf) 1325 1319 { 1326 1320 assume(cf != NULL); 1327 assume( getCoeffType(cf) == ID);1321 assume((getCoeffType(cf) == n_algExt)||(getCoeffType(cf) == n_polyExt)); 1328 1322 assume(nCoeff_is_Q_algext(cf)); // only over (Q[a]/m(a)), while the default impl. is used over Zp[a]/m(a) ! 1329 1323 … … 1402 1396 1403 1397 assume( cf != NULL ); 1404 assume(getCoeffType(cf) == ID); // coeff type;1398 assume(getCoeffType(cf) == n_algExt); // coeff type; 1405 1399 1406 1400 e->r->ref ++; // increase the ref.counter for the ground poly. ring! … … 1488 1482 template class IAccessor<snumber*>; 1489 1483 1484 #ifdef SINGULAR_4_1 1490 1485 /* --------------------------------------------------------------------*/ 1491 #if 0 1492 void npolyCoeffWrite(const coeffs cf, BOOLEAN details) 1486 /**************************************** 1487 * Computer Algebra System SINGULAR * 1488 ****************************************/ 1489 /** 1490 * ABSTRACT: numbers as polys in the ring K[a] 1491 * Assuming that we have a coeffs object cf, then these numbers 1492 * are polynomials in the polynomial ring K[a] represented by 1493 * cf->extRing. 1494 * IMPORTANT ASSUMPTIONS: 1495 * 1.) So far we assume that cf->extRing is a valid polynomial 1496 * ring 1497 **/ 1498 1499 #ifdef LDEBUG 1500 #define n2pTest(a) n2pDBTest(a,__FILE__,__LINE__,cf) 1501 BOOLEAN n2pDBTest(number a, const char *f, const int l, const coeffs r); 1502 #else 1503 #define n2pTest(a) do {} while (0) 1504 #endif 1505 1506 /* polynomial ring in which our numbers live */ 1507 #define n2pRing cf->extRing 1508 1509 /* coeffs object in which the coefficients of our numbers live; 1510 * methods attached to n2pCoeffs may be used to compute with the 1511 * coefficients of our numbers, e.g., use n2pCoeffs->nAdd to add 1512 * coefficients of our numbers */ 1513 #define n2pCoeffs cf->extRing->cf 1514 1515 #ifdef LDEBUG 1516 BOOLEAN n2pDBTest(number a, const char *f, const int l, const coeffs cf) 1517 { 1518 if (a == NULL) return TRUE; 1519 return p_DBTest((poly)a, n2pRing,f,l); 1520 } 1521 #endif 1522 1523 void n2pNormalize(number &a, const coeffs cf) 1524 { 1525 poly aa=(poly)a; 1526 p_Normalize(aa,n2pRing); 1527 } 1528 1529 /* TRUE iff (a != 0 and (b == 0 or deg(a) > deg(b) or (deg(a)==deg(b) && lc(a)>lc(b))) */ 1530 number n2pMult(number a, number b, const coeffs cf) 1531 { 1532 n2pTest(a); n2pTest(b); 1533 if ((a == NULL)||(b == NULL)) return NULL; 1534 poly aTimesB = p_Mult_q(p_Copy((poly)a, n2pRing), 1535 p_Copy((poly)b, n2pRing), n2pRing); 1536 return (number)aTimesB; 1537 } 1538 1539 number n2pDiv(number a, number b, const coeffs cf) 1540 { 1541 n2pTest(a); n2pTest(b); 1542 if (b == NULL) WerrorS(nDivBy0); 1543 if (a == NULL) return NULL; 1544 poly p=singclap_pdivide((poly)a,(poly)b,n2pRing); 1545 return (number)p; 1546 } 1547 1548 void n2pPower(number a, int exp, number *b, const coeffs cf) 1549 { 1550 n2pTest(a); 1551 1552 *b= (number)p_Power((poly)a,exp,n2pRing); 1553 } 1554 1555 const char * n2pRead(const char *s, number *a, const coeffs cf) 1556 { 1557 poly aAsPoly; 1558 const char * result = p_Read(s, aAsPoly, n2pRing); 1559 *a = (number)aAsPoly; 1560 return result; 1561 } 1562 1563 /* expects *param to be castable to AlgExtInfo */ 1564 static BOOLEAN n2pCoeffIsEqual(const coeffs cf, n_coeffType n, void * param) 1565 { 1566 if (n_polyExt != n) return FALSE; 1567 AlgExtInfo *e = (AlgExtInfo *)param; 1568 /* for extension coefficient fields we expect the underlying 1569 polynomial rings to be IDENTICAL, i.e. the SAME OBJECT; 1570 this expectation is based on the assumption that we have properly 1571 registered cf and perform reference counting rather than creating 1572 multiple copies of the same coefficient field/domain/ring */ 1573 if (n2pRing == e->r) 1574 return TRUE; 1575 // NOTE: Q(a)[x] && Q(a)[y] should better share the _same_ Q(a)... 1576 if( rEqual(n2pRing, e->r, TRUE) ) // also checks the equality of qideals 1577 { 1578 rDelete(e->r); 1579 return TRUE; 1580 } 1581 return FALSE; 1582 } 1583 1584 void n2pKillChar(coeffs cf) 1585 { 1586 if ((--cf->extRing->ref) == 0) 1587 rDelete(cf->extRing); 1588 } 1589 1590 char* n2pCoeffString(const coeffs r) // currently also for tranext. 1591 { 1592 const char* const* p=n_ParameterNames(r); 1593 int l=0; 1594 int i; 1595 for(i=0; i<n_NumberOfParameters(r);i++) 1596 { 1597 l+=(strlen(p[i])+1); 1598 } 1599 char *s=(char *)omAlloc(l+10+1); 1600 s[0]='\0'; 1601 snprintf(s,10+1,"%d",r->ch); /* Fp(a) or Q(a) */ 1602 char tt[2]; 1603 tt[0]=','; 1604 tt[1]='\0'; 1605 for(i=0; i<n_NumberOfParameters(r);i++) 1606 { 1607 strcat(s,tt); 1608 strcat(s,p[i]); 1609 } 1610 return s; 1611 } 1612 1613 void n2pCoeffWrite(const coeffs cf, BOOLEAN details) 1493 1614 { 1494 1615 assume( cf != NULL ); … … 1501 1622 PrintLn(); 1502 1623 } 1503 number npolyMult(number a, number b, const coeffs cf) 1504 { 1505 naTest(a); naTest(b); 1506 if ((a == NULL)||(b == NULL)) return NULL; 1507 poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing), 1508 p_Copy((poly)b, naRing), naRing); 1509 return (number)aTimesB; 1510 } 1511 1512 void npolyPower(number a, int exp, number *b, const coeffs cf) 1513 { 1514 naTest(a); 1515 1516 /* special cases first */ 1517 if (a == NULL) 1518 { 1519 if (exp >= 0) *b = NULL; 1520 else WerrorS(nDivBy0); 1521 return; 1522 } 1523 else if (exp == 0) { *b = naInit(1, cf); return; } 1524 else if (exp == 1) { *b = naCopy(a, cf); return; } 1525 else if (exp == -1) { *b = naInvers(a, cf); return; } 1526 1527 int expAbs = exp; if (expAbs < 0) expAbs = -expAbs; 1528 1529 /* now compute a^expAbs */ 1530 poly pow; poly aAsPoly = (poly)a; 1531 if (expAbs <= 7) 1532 { 1533 pow = p_Copy(aAsPoly, naRing); 1534 for (int i = 2; i <= expAbs; i++) 1535 { 1536 pow = p_Mult_q(pow, p_Copy(aAsPoly, naRing), naRing); 1537 } 1624 1625 number n2pInvers(number a, const coeffs cf) 1626 { 1627 poly aa=(poly)a; 1628 if(p_IsConstant(aa, n2pRing)) 1629 { 1630 poly p=p_Init(n2pRing); 1631 p_SetCoeff0(p,n_Invers(pGetCoeff(aa),n2pCoeffs),n2pRing); 1632 return (number)p; 1538 1633 } 1539 1634 else 1540 1635 { 1541 pow = p_ISet(1, naRing); 1542 poly factor = p_Copy(aAsPoly, naRing); 1543 while (expAbs != 0) 1544 { 1545 if (expAbs & 1) 1546 { 1547 pow = p_Mult_q(pow, p_Copy(factor, naRing), naRing); 1548 } 1549 expAbs = expAbs / 2; 1550 if (expAbs != 0) 1551 { 1552 factor = p_Mult_q(factor, p_Copy(factor, naRing), naRing); 1553 } 1554 } 1555 p_Delete(&factor, naRing); 1556 } 1557 1558 /* invert if original exponent was negative */ 1559 number n = (number)pow; 1560 if (exp < 0) 1561 { 1562 number m = npolyInvers(n, cf); 1563 naDelete(&n, cf); 1564 n = m; 1565 } 1566 *b = n; 1567 } 1568 1569 number npolyDiv(number a, number b, const coeffs cf) 1570 { 1571 naTest(a); naTest(b); 1572 if (b == NULL) WerrorS(nDivBy0); 1573 if (a == NULL) return NULL; 1574 poly p=singclap_pdivide((poly)a,(poly)b,naRing); 1575 return (number)p; 1576 } 1577 1578 1579 BOOLEAN npolyInitChar(coeffs cf, void * infoStruct) 1636 WerrorS("not invertible"); 1637 return NULL; 1638 } 1639 } 1640 1641 BOOLEAN n2pInitChar(coeffs cf, void * infoStruct) 1580 1642 { 1581 1643 assume( infoStruct != NULL ); … … 1599 1661 cf->is_domain=TRUE; 1600 1662 1601 cf->cfCoeffString = n aCoeffString;1663 cf->cfCoeffString = n2pCoeffString; 1602 1664 1603 1665 cf->cfGreaterZero = naGreaterZero; … … 1609 1671 cf->cfInit = naInit; 1610 1672 cf->cfFarey = naFarey; 1611 cf->cfChineseRemainder Sym= naChineseRemainder;1673 cf->cfChineseRemainder= naChineseRemainder; 1612 1674 cf->cfInt = naInt; 1613 1675 cf->cfInpNeg = naNeg; 1614 1676 cf->cfAdd = naAdd; 1615 1677 cf->cfSub = naSub; 1616 cf->cfMult = n polyMult;1617 cf->cfDiv = n polyDiv;1618 cf->cfPower = n aPower;1678 cf->cfMult = n2pMult; 1679 cf->cfDiv = n2pDiv; 1680 cf->cfPower = n2pPower; 1619 1681 cf->cfCopy = naCopy; 1620 1682 1621 1683 cf->cfWriteLong = naWriteLong; 1622 1684 1623 if( rCanShortOut(n aRing) )1685 if( rCanShortOut(n2pRing) ) 1624 1686 cf->cfWriteShort = naWriteShort; 1625 1687 else 1626 1688 cf->cfWriteShort = naWriteLong; 1627 1689 1628 cf->cfRead = n aRead;1690 cf->cfRead = n2pRead; 1629 1691 cf->cfDelete = naDelete; 1630 1692 cf->cfSetMap = naSetMap; … … 1632 1694 cf->cfGetNumerator = naGetNumerator; 1633 1695 cf->cfRePart = naCopy; 1634 cf->cfCoeffWrite = n polyCoeffWrite;1635 cf->cfNormalize = n polyNormalize;1696 cf->cfCoeffWrite = n2pCoeffWrite; 1697 cf->cfNormalize = n2pNormalize; 1636 1698 cf->cfKillChar = naKillChar; 1637 1699 #ifdef LDEBUG … … 1641 1703 cf->cfNormalizeHelper = naLcmContent; 1642 1704 cf->cfSize = naSize; 1643 cf->nCoeffIsEqual = n aCoeffIsEqual;1644 cf->cfInvers = n polyInvers;1705 cf->nCoeffIsEqual = n2pCoeffIsEqual; 1706 cf->cfInvers = n2pInvers; 1645 1707 cf->convFactoryNSingN=naConvFactoryNSingN; 1646 1708 cf->convSingNFactoryN=naConvSingNFactoryN; -
libpolys/polys/ext_fields/algext.h
rbb3cb8b r109e13a 45 45 /// Initialize the coeffs object 46 46 BOOLEAN naInitChar(coeffs cf, void* infoStruct); 47 BOOLEAN n2pInitChar(coeffs cf, void * infoStruct); 47 48 48 49 /// if m == var(i)/1 => return i, -
libpolys/polys/monomials/ring.cc
rbb3cb8b r109e13a 5646 5646 const n_coeffType _filed_type = getCoeffType(C); 5647 5647 5648 if( _filed_type == n_algExt)5648 if(( _filed_type == n_algExt )||( _filed_type == n_polyExt )) 5649 5649 return naIsParam(m, C); 5650 5650
Note: See TracChangeset
for help on using the changeset viewer.