- Timestamp:
- Jan 12, 2011, 7:17:19 PM (13 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'fc741b6502fd8a97288eaa3eba6e5220f3c3df87')
- Children:
- 56790491568061b8fda62ac136d56bb3bca12583
- Parents:
- ce2120e7219cf5bd8e6ce5db355bc0cd410f02f6
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-01-12 19:17:19+01:00
- git-committer:
- Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:59:24+01:00
- Location:
- libpolys
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/coeffs.h
rce2120e r8a8c9e 159 159 (*cfIsMOne)(number a, const coeffs r), 160 160 (*cfGreaterZero)(number a, const coeffs r); 161 161 162 162 void (*cfPower)(number a, int i, number * result, const coeffs r); 163 163 number (*cfGetDenom)(number &n, const coeffs r); … … 219 219 short float_len2; /* additional char-flags, rInit */ 220 220 221 BOOLEAN ShortOut; /// ffields need this. 221 BOOLEAN ShortOut; /// ffields need this. 222 222 223 223 // --------------------------------------------------- … … 265 265 266 266 /// return a copy of a 267 static inline number n_Copy(number n, const coeffs r){ return (r)->cfCopy(n, r); } 268 static inline void n_Delete(number* p, const coeffs r){ return (r)->cfDelete(p, r); } 269 270 static inline BOOLEAN n_Equal(number a, number b, const coeffs r){ return (r)->cfEqual(a, b, r); } 271 static inline BOOLEAN n_IsZero(number n, const coeffs r){ return (r)->cfIsZero(n,r); } 272 static inline BOOLEAN n_IsOne(number n, const coeffs r){ return (r)->cfIsOne(n,r); } 273 static inline BOOLEAN n_IsMOne(number n, const coeffs r){ return (r)->cfIsMOne(n,r); } 274 static inline BOOLEAN n_GreaterZero(number n, const coeffs r){ return (r)->cfGreaterZero(n,r); } 267 static inline number n_Copy(number n, const coeffs r) 268 { return (r)->cfCopy(n, r); } 269 static inline void n_Delete(number* p, const coeffs r) 270 { return (r)->cfDelete(p, r); } 271 272 static inline BOOLEAN n_Equal(number a, number b, const coeffs r) 273 { return (r)->cfEqual(a, b, r); } 274 static inline BOOLEAN n_IsZero(number n, const coeffs r) 275 { return (r)->cfIsZero(n,r); } 276 static inline BOOLEAN n_IsOne(number n, const coeffs r) 277 { return (r)->cfIsOne(n,r); } 278 static inline BOOLEAN n_IsMOne(number n, const coeffs r) 279 { return (r)->cfIsMOne(n,r); } 280 static inline BOOLEAN n_GreaterZero(number n, const coeffs r) 281 { return (r)->cfGreaterZero(n,r); } 275 282 // cfGreater? 276 283 #ifdef HAVE_RINGS 277 static inline BOOLEAN n_IsUnit(number n, const coeffs r) { return r->cfIsUnit(n,r); } 284 static inline BOOLEAN n_IsUnit(number n, const coeffs r) 285 { return r->cfIsUnit(n,r); } 286 static inline BOOLEAN n_DivBy(number a, number b, const coeffs r) 287 { return r->cfDivBy(a,b,r); } 278 288 #endif 279 289 280 290 /// init with an integer 281 static inline number n_Init(int i, const coeffs r){ return (r)->cfInit(i,r); } 291 static inline number n_Init(int i, const coeffs r) 292 { return (r)->cfInit(i,r); } 282 293 283 294 /// changes argument inline: a:= -a 284 static inline number n_Neg(number n, const coeffs r){ return (r)->cfNeg(n,r); } 295 static inline number n_Neg(number n, const coeffs r) 296 { return (r)->cfNeg(n,r); } 285 297 286 298 /// return 1/a 287 static inline number n_Invers(number a, const coeffs r){ return (r)->cfInvers(a,r); } 299 static inline number n_Invers(number a, const coeffs r) 300 { return (r)->cfInvers(a,r); } 288 301 289 302 /// use for pivot strategies, (0) => 0, otherwise positive 290 static inline int n_Size(number n, const coeffs r){ return (r)->cfSize(n,r); } 303 static inline int n_Size(number n, const coeffs r) 304 { return (r)->cfSize(n,r); } 291 305 292 306 /// normalize the number. i.e. go to some canonnical representation (inplace) 293 static inline void n_Normalize(number& n, const coeffs r){ return (r)->cfNormalize(n,r); } 307 static inline void n_Normalize(number& n, const coeffs r) 308 { return (r)->cfNormalize(n,r); } 294 309 295 310 /// Normalize and Write to the output buffer of reporter 296 static inline void n_Write(number& n, const coeffs r){ return (r)->cfWrite(n,r); } 311 static inline void n_Write(number& n, const coeffs r) 312 { return (r)->cfWrite(n,r); } 297 313 298 314 /// Normalize and get denomerator 299 static inline number n_GetDenom(number& n, const coeffs r){ return (r)->cfGetDenom(n, r); } 315 static inline number n_GetDenom(number& n, const coeffs r) 316 { return (r)->cfGetDenom(n, r); } 300 317 301 318 /// Normalize and get numerator 302 static inline number n_GetNumerator(number& n, const coeffs r){ return (r)->cfGetNumerator(n, r); } 303 304 static inline void n_Power(number a, int b, number *res, const coeffs r){ return (r)->cfPower(a,b,res,r); } 305 306 307 static inline number n_Mult(number a, number b, const coeffs r){ return (r)->cfMult(a, b, r); } 319 static inline number n_GetNumerator(number& n, const coeffs r) 320 { return (r)->cfGetNumerator(n, r); } 321 322 static inline void n_Power(number a, int b, number *res, const coeffs r) 323 { return (r)->cfPower(a,b,res,r); } 324 325 static inline number n_Mult(number a, number b, const coeffs r) 326 { return (r)->cfMult(a, b, r); } 308 327 309 328 /// Inplace multiplication: a := a * b 310 static inline void n_InpMult(number &a, number b, const coeffs r){ return (r)->cfInpMult(a,b,r); } 311 312 static inline number n_Sub(number a, number b, const coeffs r){ return (r)->cfSub(a, b, r); } 313 static inline number n_Add(number a, number b, const coeffs r){ return (r)->cfAdd(a, b, r); } 314 315 static inline number n_Div(number a, number b, const coeffs r){ return (r)->cfDiv(a,b,r); } 316 static inline number n_IntDiv(number a, number b, const coeffs r){ return (r)->cfIntDiv(a,b,r); } 317 static inline number n_ExactDiv(number a, number b, const coeffs r){ return (r)->cfExactDiv(a,b,r); } 318 319 static inline number n_Gcd(number a, number b, const coeffs r){ return (r)->cfGcd(a,b,r); } 329 static inline void n_InpMult(number &a, number b, const coeffs r) 330 { return (r)->cfInpMult(a,b,r); } 331 332 static inline number n_Sub(number a, number b, const coeffs r) 333 { return (r)->cfSub(a, b, r); } 334 335 static inline number n_Add(number a, number b, const coeffs r) 336 { return (r)->cfAdd(a, b, r); } 337 338 static inline number n_Div(number a, number b, const coeffs r) 339 { return (r)->cfDiv(a,b,r); } 340 341 static inline number n_IntDiv(number a, number b, const coeffs r) 342 { return (r)->cfIntDiv(a,b,r); } 343 344 static inline number n_ExactDiv(number a, number b, const coeffs r) 345 { return (r)->cfExactDiv(a,b,r); } 346 347 static inline number n_Gcd(number a, number b, const coeffs r) 348 { return (r)->cfGcd(a,b,r); } 320 349 321 350 /// Tests whether n is a correct number: only used if LDEBUG is defined 322 351 static inline BOOLEAN n_DBTest(number n, const char *filename, const int linenumber, const coeffs r) 323 352 { 324 #ifdef LDEBUG 353 #ifdef LDEBUG 325 354 return (r)->cfDBTest(n, filename, linenumber, r); 326 355 #else 327 356 return TRUE; 328 357 #endif 329 330 358 } 331 359 … … 339 367 340 368 // Deprecated: 341 static inline int n_GetChar(const coeffs r){ return nInternalChar(r); } 342 343 #endif 344 369 static inline int n_GetChar(const coeffs r) 370 { return nInternalChar(r); } 371 372 #endif 373 -
libpolys/polys/Makefile.am
rce2120e r8a8c9e 13 13 operations/pShallowCopyDelete.cc operations/p_Mult_q.cc \ 14 14 p_Procs_Lib.cc polys-impl.cc polys.cc \ 15 polys0.cc polys1.cc prCopy.cc prCopyTemplate.cc 15 polys0.cc polys1.cc prCopy.cc prCopyTemplate.cc \ 16 sbucktes.cc 16 17 17 18 noinst_HEADERS = … … 22 23 p_MemAdd.h p_MemCmp.h p_MemCopy.h operations/p_Mult_q.h p_Numbers.h p_Procs.h \ 23 24 p_Procs_Dynamic.h p_Procs_Impl.h p_Procs_Set.h p_Procs_Static.h \ 24 monomials/p_polys.h monomials/polys-impl.h monomials/polys.h prCopy.h prCopyMacros.h 25 monomials/p_polys.h monomials/polys-impl.h monomials/polys.h prCopy.h prCopyMacros.h \ 26 sbuckets.h 25 27 26 28 lib_LIBRARIES=libpolys.a libpolys_g.a -
libpolys/polys/monomials/monomials.cc
rce2120e r8a8c9e 31 31 #include <reporter/reporter.h> 32 32 #include <coeffs/numbers.h> 33 #include <polys/polys.h>34 33 #include <polys/monomials/ring.h> 34 #include <polys/monomials/p_polys.h> 35 35 #include <polys/templates/p_Procs.h> 36 36 #include <reporter/reporter.h> -
libpolys/polys/monomials/p_polys.cc
rce2120e r8a8c9e 10 10 *******************************************************************/ 11 11 12 #include <ctype.h> 12 13 13 14 #include <misc/auxiliary.h> … … 16 17 #include <polys/monomials/p_polys.h> 17 18 #include <polys/monomials/ring.h> 19 #include <coeffs/longrat.h> 18 20 // #include <???/ideals.h> 19 21 // #include <???/int64vec.h> … … 536 538 537 539 for (;i<=r->N;i++) 538 j+=p_GetExp(p,i, r)*p Weight(i, r);540 j+=p_GetExp(p,i, r)*p_Weight(i, r); 539 541 540 542 return j; … … 1117 1119 { 1118 1120 rc = p_Init(r); 1119 pSetCoeff0(rc,n_Init(i,r ));1120 if ( r->cf->nIsZero(p_GetCoeff(rc,r)))1121 pSetCoeff0(rc,n_Init(i,r->cf)); 1122 if (n_IsZero(pGetCoeff(rc),r->cf)) 1121 1123 p_LmDelete(&rc,r); 1122 1124 } … … 1130 1132 { 1131 1133 poly rc = p_Init(r); 1132 pSetCoeff0(rc,n_Init(1,r ));1134 pSetCoeff0(rc,n_Init(1,r->cf)); 1133 1135 return rc; 1134 1136 } … … 1167 1169 int i,j; 1168 1170 rc = p_Init(r); 1169 const char *s = r->cf-> nRead(st,&(rc->coef));1171 const char *s = r->cf->cfRead(st,&(rc->coef),r->cf); 1170 1172 if (s==st) 1171 1173 /* i.e. it does not start with a coeff: test if it is a ringvar*/ … … 1206 1208 } 1207 1209 done: 1208 if ( r->cf->nIsZero(pGetCoeff(rc))) p_LmDelete(&rc,r);1210 if (n_IsZero(pGetCoeff(rc),r->cf)) p_LmDelete(&rc,r); 1209 1211 else 1210 1212 { … … 1260 1262 poly p_NSet(number n, const ring r) 1261 1263 { 1262 if ( r->cf->nIsZero(n))1263 { 1264 r->cf->cfDelete(&n, r);1264 if (n_IsZero(n,r->cf)) 1265 { 1266 n_Delete(&n, r->cf); 1265 1267 return NULL; 1266 1268 } … … 1283 1285 assume((p_GetComp(a,r)==p_GetComp(b,r)) || (p_GetComp(b,r)==0)); 1284 1286 int i; 1285 poly result = p Init();1287 poly result = p_Init(r); 1286 1288 1287 1289 for(i=(int)r->N; i; i--) … … 1291 1293 return result; 1292 1294 } 1295 1296 #ifdef HAVE_RINGS //TODO Oliver 1297 1298 poly p_Div_nn(poly p, const number n, const ring r) 1299 { 1300 pAssume(!n_IsZero(n,r)); 1301 p_Test(p, r); 1302 1303 poly q = p; 1304 while (p != NULL) 1305 { 1306 number nc = pGetCoeff(p); 1307 pSetCoeff0(p, n_Div(nc, n, r->cf)); 1308 n_Delete(&nc, r->cf); 1309 pIter(p); 1310 } 1311 p_Test(q, r); 1312 return q; 1313 } 1314 #endif 1293 1315 1294 1316 /*2 … … 1323 1345 if (prev==NULL) 1324 1346 { 1325 p_ DeleteLm(&result,r);1347 p_LmDelete(&result,r); 1326 1348 a=result; 1327 1349 } 1328 1350 else 1329 1351 { 1330 p_ DeleteLm(&pNext(prev),r);1352 p_LmDelete(&pNext(prev),r); 1331 1353 a=pNext(prev); 1332 1354 } … … 1406 1428 } 1407 1429 1408 static poly p DiffOpM(poly a, poly b,BOOLEAN multiply, const ring r)1430 static poly p_DiffOpM(poly a, poly b,BOOLEAN multiply, const ring r) 1409 1431 { 1410 1432 int i,j,s; … … 1476 1498 int i; 1477 1499 1478 if(!n_IsOne(pGetCoeff(p),r ))1500 if(!n_IsOne(pGetCoeff(p),r->cf)) 1479 1501 { 1480 1502 number x, y; 1481 1503 y = pGetCoeff(p); 1482 n_Power(y,exp,&x,r );1483 n_Delete(&y,r );1504 n_Power(y,exp,&x,r->cf); 1505 n_Delete(&y,r->cf); 1484 1506 pSetCoeff0(p,x); 1485 1507 } … … 1502 1524 1503 1525 y = pGetCoeff(p); 1504 x = n_Mult(y,pGetCoeff(q),r );1505 n_Delete(&y,r );1526 x = n_Mult(y,pGetCoeff(q),r->cf); 1527 n_Delete(&y,r->cf); 1506 1528 pSetCoeff0(p,x); 1507 1529 //for (i=pVariables; i!=0; i--) … … 1523 1545 poly r = p_Init(rr); 1524 1546 1525 x = n_Mult(pGetCoeff(p),pGetCoeff(q),rr );1547 x = n_Mult(pGetCoeff(p),pGetCoeff(q),rr->cf); 1526 1548 pSetCoeff0(r,x); 1527 1549 p_ExpVectorSum(r,p, q, rr); … … 1566 1588 { 1567 1589 h = a[e]; 1568 x = n_Mult(bin[exp-e],pGetCoeff(h),r );1590 x = n_Mult(bin[exp-e],pGetCoeff(h),r->cf); 1569 1591 p_SetCoeff(h,x,r); 1570 1592 p_MonMult(h,b,r); … … 1575 1597 { 1576 1598 h = a[e]; 1577 x = n_Mult(bin[e],pGetCoeff(h),r );1599 x = n_Mult(bin[e],pGetCoeff(h),r->cf); 1578 1600 p_SetCoeff(h,x,r); 1579 1601 p_MonMult(h,b,r); … … 1710 1732 if ((ph!=NULL) && rField_has_Units(r)) 1711 1733 { 1712 number k = n GetUnit(pGetCoeff(ph));1734 number k = n_GetUnit(pGetCoeff(ph),r->cf); 1713 1735 if (!n_IsOne(k,r->cf)) 1714 1736 { … … 1735 1757 if(pNext(ph)==NULL) 1736 1758 { 1737 p_SetCoeff(ph,n_Init(1,r ),r->cf);1759 p_SetCoeff(ph,n_Init(1,r->cf),r); 1738 1760 } 1739 1761 else … … 1741 1763 n_Normalize(pGetCoeff(ph),r->cf); 1742 1764 if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r); 1743 if (rField_is_Q( ))1765 if (rField_is_Q(r)) 1744 1766 { 1745 1767 h=p_InitContent(ph,r); … … 1805 1827 { // each monom: coeff in Q_a 1806 1828 lnumber c_n_n=(lnumber)pGetCoeff(p); 1807 napoly c_n=c_n_n->z;1829 poly c_n=c_n_n->z; 1808 1830 while (c_n!=NULL) 1809 1831 { // each monom: coeff in Q … … 1843 1865 { // each monom: coeff in Q_a 1844 1866 lnumber c_n_n=(lnumber)pGetCoeff(p); 1845 napoly c_n=c_n_n->z;1867 poly c_n=c_n_n->z; 1846 1868 while (c_n!=NULL) 1847 1869 { // each monom: coeff in Q … … 2201 2223 while (p!=NULL) 2202 2224 { 2203 n_Normalize(pGetCoeff(p ,r->cf));2225 n_Normalize(pGetCoeff(p),r->cf); 2204 2226 d=n_Lcm(h,pGetCoeff(p),r->cf); 2205 2227 n_Delete(&h,r->cf); … … 2480 2502 else 2481 2503 d=pFDeg; 2482 o = d(p, currRing);2504 o = d(p,r); 2483 2505 do 2484 2506 { … … 2783 2805 static BOOLEAN pOldLexOrder; 2784 2806 2785 static long pModDeg(poly p, ring r = currRing)2807 static long pModDeg(poly p, ring r) 2786 2808 { 2787 2809 long d=pOldFDeg(p, r); … … 2881 2903 number c=pGetCoeff(qq); 2882 2904 number ee=nfPar(1); 2883 number eee;nfPower(ee,e,&eee); //nfDelete(ee, currRing);2905 number eee;nfPower(ee,e,&eee); //nfDelete(ee,dst); 2884 2906 ee=nfMult(c,eee); 2885 //nfDelete(c, currRing);nfDelete(eee,currRing);2907 //nfDelete(c,dst);nfDelete(eee,dst); 2886 2908 pSetCoeff0(qq,ee); 2887 2909 } … … 2893 2915 else /* more difficult: we have really to multiply: */ 2894 2916 { 2895 lnumber mmc=(lnumber)naInit(1, currRing);2917 lnumber mmc=(lnumber)naInit(1,dst); 2896 2918 napSetExp(mmc->z,-perm[i],e/*p_GetExp( p,i,oldRing)*/); 2897 2919 napSetm(mmc->z); -
libpolys/polys/monomials/p_polys.h
rce2120e r8a8c9e 14 14 15 15 #include <polys/monomials/ring.h> 16 #include <polys/monomials/monomials.h> 16 17 #include <polys/monomials/polys-impl.h> 18 #include <polys/templates/p_Procs.h> 19 #include <polys/templates/p_Procs.h> 20 #include <polys/sbuckets.h> 17 21 18 22 /*************************************************************** … … 39 43 40 44 // Component 41 #define p_GetComp(p, r) _p_GetComp(p, r)42 45 static inline unsigned long p_SetComp(poly p, unsigned long c, ring r); 43 46 static inline unsigned long p_AddComp(poly p, unsigned long v, ring r); … … 181 184 static inline BOOLEAN p_IsConstantComp(const poly p, const ring r); 182 185 static inline BOOLEAN p_IsConstant(const poly p, const ring r); 183 PINLINE0BOOLEAN p_IsConstantPoly(const poly p, const ring r);186 static inline BOOLEAN p_IsConstantPoly(const poly p, const ring r); 184 187 185 188 // return TRUE if all monoms have the same component … … 320 323 321 324 // sets component of poly a to i, returns length of a 322 PINLINE0void p_SetCompP(poly a, int i, ring r);323 PINLINE0void p_SetCompP(poly a, int i, ring lmRing, ring tailRing);324 PINLINE0long p_MaxComp(poly p, ring lmRing, ring tailRing);325 static inline void p_SetCompP(poly a, int i, ring r); 326 static inline void p_SetCompP(poly a, int i, ring lmRing, ring tailRing); 327 static inline long p_MaxComp(poly p, ring lmRing, ring tailRing); 325 328 inline long p_MaxComp(poly p,ring lmRing) {return p_MaxComp(p,lmRing,lmRing);} 326 PINLINE0long p_MinComp(poly p, ring lmRing, ring tailRing);329 static inline long p_MinComp(poly p, ring lmRing, ring tailRing); 327 330 inline long p_MinComp(poly p,ring lmRing) {return p_MinComp(p,lmRing,lmRing);} 328 331 … … 332 335 * 333 336 ***************************************************************/ 334 PINLINE0int pLength(poly a);335 PINLINE0poly pLast(poly a, int &length);337 static inline int pLength(poly a); 338 static inline poly pLast(poly a, int &length); 336 339 inline poly pLast(poly a) { int l; return pLast(a, l);} 337 PINLINE0poly pReverse(poly p);340 static inline poly pReverse(poly p); 338 341 339 342 … … 441 444 { 442 445 p_LmCheckPolyRing2(p, r); 443 n_Delete(&(p->coef), r );446 n_Delete(&(p->coef), r->cf); 444 447 (p)->coef=n; 445 448 return n; … … 496 499 p_LmCheckPolyRing2(p, r); 497 500 pAssume2(rRing_has_Comp(r)); 498 pPolyAssume2(__p_GetComp(p,r) >= v,p,r);501 _pPolyAssume2(__p_GetComp(p,r) >= v,p,r); 499 502 return __p_GetComp(p,r) -= v; 500 503 } … … 737 740 return pnext; 738 741 } 739 static inline void p_LmDelete(poly p, ring r)742 static inline void p_LmDelete(poly p, const ring r) 740 743 { 741 744 p_LmCheckPolyRing2(p, r); 742 n_Delete(&pGetCoeff(p), r );745 n_Delete(&pGetCoeff(p), r->cf); 743 746 omFreeBinAddr(p); 744 747 } 745 static inline void p_LmDelete(poly *p, ring r)748 static inline void p_LmDelete(poly *p, const ring r) 746 749 { 747 750 p_LmCheckPolyRing2(*p, r); 748 751 poly h = *p; 749 752 *p = pNext(h); 750 n_Delete(&pGetCoeff(h), r );753 n_Delete(&pGetCoeff(h), r->cf); 751 754 omFreeBinAddr(h); 752 755 } 753 static inline poly p_LmDeleteAndNext(poly p, ring r)756 static inline poly p_LmDeleteAndNext(poly p, const ring r) 754 757 { 755 758 p_LmCheckPolyRing2(p, r); 756 759 poly pnext = pNext(p); 757 n_Delete(&pGetCoeff(p), r );760 n_Delete(&pGetCoeff(p), r->cf); 758 761 omFreeBinAddr(p); 759 762 return pnext; … … 910 913 static inline poly p_Mult_nn(poly p, number n, const ring r) 911 914 { 912 if (n_IsOne(n, r ))915 if (n_IsOne(n, r->cf)) 913 916 return p; 914 917 else … … 935 938 static inline poly pp_Mult_nn(poly p, number n, const ring r) 936 939 { 937 if (n_IsOne(n, r ))940 if (n_IsOne(n, r->cf)) 938 941 return p_Copy(p, r); 939 942 else … … 1114 1117 int shorter; 1115 1118 number n_old = pGetCoeff(m); 1116 number n_neg = n_Copy(n_old, r );1117 n_neg = n_Neg(n_neg, r );1119 number n_neg = n_Copy(n_old, r->cf); 1120 n_neg = n_Neg(n_neg, r->cf); 1118 1121 pSetCoeff0(m, n_neg); 1119 1122 res = r->p_Procs->p_Minus_mm_Mult_qq(p, m, q, shorter, NULL, r, last); 1120 1123 lp = (lp + lq) - shorter; 1121 1124 pSetCoeff0(m, n_old); 1122 n_Delete(&n_neg, r );1125 n_Delete(&n_neg, r->cf); 1123 1126 return res; 1124 1127 } … … 1304 1307 p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size); 1305 1308 pNext(np) = NULL; 1306 pSetCoeff0(np, n_Copy(pGetCoeff(p), r ));1309 pSetCoeff0(np, n_Copy(pGetCoeff(p), r->cf)); 1307 1310 return np; 1308 1311 } … … 1319 1322 p_MemCopy_LengthGeneral(np->exp, p->exp, r->ExpL_Size); 1320 1323 pNext(np) = NULL; 1321 pSetCoeff0(np, n_Init(1, r ));1324 pSetCoeff0(np, n_Init(1, r->cf)); 1322 1325 int i; 1323 1326 for(i=l;i<=k;i++) … … 1544 1547 #ifdef HAVE_RINGS 1545 1548 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == nDivBy(p_GetCoeff(b, r), p_GetCoeff(a, r))); 1546 return (!rField_is_Ring(r)) || n DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));1549 return (!rField_is_Ring(r)) || n_DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r), r->cf); 1547 1550 #else 1548 1551 pDivAssume(p_DebugLmDivisibleByNoComp(a, b, r) == TRUE); … … 1564 1567 while (i); 1565 1568 #ifdef HAVE_RINGS 1566 return n DivBy(p_GetCoeff(b, r), p_GetCoeff(a, r));1569 return n_DivBy(p_GetCoeff(b, r_b), p_GetCoeff(a, r_a), r_a->cf); 1567 1570 #else 1568 1571 return TRUE; … … 1661 1664 p_LmCheckPolyRing1(b, r); 1662 1665 #ifndef PDIV_DEBUG 1663 pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r);1664 pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r);1666 _pPolyAssume2(p_GetShortExpVector(a, r) == sev_a, a, r); 1667 _pPolyAssume2(p_GetShortExpVector(b, r) == ~ not_sev_b, b, r); 1665 1668 1666 1669 if (sev_a & not_sev_b) … … 1681 1684 p_LmCheckPolyRing1(b, r_b); 1682 1685 #ifndef PDIV_DEBUG 1683 pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a);1684 pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b);1686 _pPolyAssume2(p_GetShortExpVector(a, r_a) == sev_a, a, r_a); 1687 _pPolyAssume2(p_GetShortExpVector(b, r_b) == ~ not_sev_b, b, r_b); 1685 1688 1686 1689 if (sev_a & not_sev_b) … … 1777 1780 poly p_DiffOp(poly a, poly b,BOOLEAN multiply, const ring r); 1778 1781 int p_Weight(int c, const ring r); 1779 static inline long pTotaldegree(poly p) { return p_Totaldegree(p,currRing); }1780 1782 1781 1783 /* syszygy stuff */ … … 1802 1804 // on ordering and/or OrdIndex -- otherwise they might return wrong results 1803 1805 // on strat->tailRing 1804 void pSetDegProcs(ring r .pFDegProc new_FDeg, pLDegProc new_lDeg = NULL);1806 void pSetDegProcs(ring r, pFDegProc new_FDeg, pLDegProc new_lDeg = NULL); 1805 1807 // restores pFDeg and pLDeg: 1806 void pRestoreDegProcs(ring r .pFDegProc old_FDeg, pLDegProc old_lDeg);1808 void pRestoreDegProcs(ring r, pFDegProc old_FDeg, pLDegProc old_lDeg); 1807 1809 1808 1810 /*-------------pComp for syzygies:-------------------*/ -
libpolys/polys/monomials/ring.h
rce2120e r8a8c9e 11 11 /* includes */ 12 12 #include <coeffs/coeffs.h> 13 #include <omalloc/omalloc.h> 13 14 //#include <polys/monomials/polys-impl.h> 15 // 16 17 /* constants */ 18 #define SHORT_REAL_LENGTH 6 // use short reals for real <= 6 digits 19 20 /* forward declaration of types */ 21 class idrec; 22 typedef idrec * idhdl; 23 struct sip_sideal; 24 typedef struct sip_sideal * ideal; 25 struct ip_sring; 26 typedef struct ip_sring * ring; 27 struct spolyrec; 28 typedef struct spolyrec polyrec; 29 typedef polyrec * poly; 30 class intvec; 31 struct p_Procs_s; 32 typedef struct p_Procs_s p_Procs_s; 33 class slists; 34 typedef slists * lists; 35 class kBucket; 36 typedef kBucket* kBucket_pt; 37 38 #if SIZEOF_LONG == 4 39 typedef long long int64; 40 #elif SIZEOF_LONG == 8 41 typedef long int64; 42 #else 43 #error int64 undefined 44 #endif 45 46 /* the function pointer types */ 47 48 typedef long (*pLDegProc)(poly p, int *length, ring r); 49 typedef long (*pFDegProc)(poly p, ring r); 50 typedef void (*p_SetmProc)(poly p, const ring r); 51 52 typedef enum 53 { 54 ro_dp, // ordering is a degree ordering 55 ro_wp, // ordering is a weighted degree ordering 56 ro_wp64, // ordering is a weighted64 degree ordering 57 ro_wp_neg, // ordering is a weighted degree ordering 58 // with possibly negative weights 59 ro_cp, // ordering duplicates variables 60 ro_syzcomp, // ordering indicates "subset" of component number (ringorder_S) 61 ro_syz, // ordering with component number >syzcomp is lower (ringorder_s) 62 ro_isTemp, ro_is, // Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS) 63 ro_none 64 } 65 ro_typ; 66 67 // ordering is a degree ordering 68 struct sro_dp 69 { 70 short place; // where degree is stored (in L): 71 short start; // bounds of ordering (in E): 72 short end; 73 }; 74 typedef struct sro_dp sro_dp; 75 76 // ordering is a weighted degree ordering 77 struct sro_wp 78 { 79 short place; // where weighted degree is stored (in L) 80 short start; // bounds of ordering (in E) 81 short end; 82 int *weights; // pointers into wvhdl field 83 }; 84 typedef struct sro_wp sro_wp; 85 86 // ordering is a weighted degree ordering 87 struct sro_wp64 88 { 89 short place; // where weighted degree is stored (in L) 90 short start; // bounds of ordering (in E) 91 short end; 92 int64 *weights64; // pointers into wvhdl field 93 }; 94 typedef struct sro_wp64 sro_wp64; 95 96 // ordering duplicates variables 97 struct sro_cp 98 { 99 short place; // where start is copied to (in E) 100 short start; // bounds of sources of copied variables (in E) 101 short end; 102 }; 103 typedef struct sro_cp sro_cp; 104 105 // ordering indicates "subset" of component number 106 struct sro_syzcomp 107 { 108 short place; // where the index is stored (in L) 109 long *ShiftedComponents; // pointer into index field 110 int* Components; 111 #ifdef PDEBUG 112 long length; 113 #endif 114 }; 115 typedef struct sro_syzcomp sro_syzcomp; 116 117 // ordering with component number >syzcomp is lower 118 struct sro_syz 119 { 120 short place; // where the index is stored (in L) 121 int limit; // syzcomp 122 int* syz_index; // mapping Component -> SyzIndex for Comp <= limit 123 int curr_index; // SyzIndex for Component > limit 124 }; 125 126 typedef struct sro_syz sro_syz; 127 // Induced Syzygy (Schreyer) ordering is built inductively as follows: 128 // we look for changes made by ordering blocks which are between prefix/suffix markers: 129 // that is: which variables where placed by them and where (judging by v) 130 131 // due to prefix/suffix nature we need some placeholder: 132 // prefix stores here initial state 133 // suffix cleares this up 134 struct sro_ISTemp 135 { 136 short start; // 1st member SHOULD be short "place" 137 int suffixpos; 138 int* pVarOffset; // copy! 139 }; 140 141 // So this is the actuall thing! 142 // suffix uses last sro_ISTemp (cleares it up afterwards) and 143 // creates this block 144 struct sro_IS 145 { 146 short start, end; // which part of L we want to want to update... 147 int* pVarOffset; // same as prefix! 148 149 int limit; // first referenced component 150 151 // reference poly set?? // Should it be owned by ring?!!! 152 ideal F; // reference leading (module)-monomials set. owned by ring... 153 const intvec* componentWeights; // component weights! owned by ring... 154 }; 155 156 typedef struct sro_IS sro_IS; 157 typedef struct sro_ISTemp sro_ISTemp; 158 159 struct sro_ord 160 { 161 ro_typ ord_typ; 162 int order_index; // comes from r->order[order_index] 163 union 164 { 165 sro_dp dp; 166 sro_wp wp; 167 sro_wp64 wp64; 168 sro_cp cp; 169 sro_syzcomp syzcomp; 170 sro_syz syz; 171 sro_IS is; 172 sro_ISTemp isTemp; 173 } data; 174 }; 175 struct ip_sring 176 { 177 // each entry must have a description and a procedure defining it, 178 // general ordering: pointer/structs, long, int, short, BOOLEAN/char/enum 179 // general defining procedures: rInit, rComplete, interpreter, ?? 180 idhdl idroot; /* local objects , interpreter*/ 181 int* order; /* array of orderings, rInit/rSleftvOrdering2Ordering */ 182 int* block0; /* starting pos., rInit/rSleftvOrdering2Ordering*/ 183 int* block1; /* ending pos., rInit/rSleftvOrdering2Ordering*/ 184 char** parameter; /* names of parameters, rInit */ 185 number minpoly; /* for Q_a/Zp_a, rInit */ 186 ideal minideal; 187 int** wvhdl; /* array of weight vectors, rInit/rSleftvOrdering2Ordering */ 188 char ** names; /* array of variable names, rInit */ 189 190 // what follows below here should be set by rComplete, _only_ 191 long *ordsgn; /* array of +/- 1 (or 0) for comparing monomials */ 192 /* ExpL_Size entries*/ 193 194 // is NULL for lp or N == 1, otherwise non-NULL (with OrdSize > 0 entries) */ 195 sro_ord* typ; /* array of orderings + sizes, OrdSize entries */ 196 /* if NegWeightL_Size > 0, then NegWeightL_Offset[0..size_1] is index of longs 197 in ExpVector whose values need an offset due to negative weights */ 198 /* array of NegWeigtL_Size indicies */ 199 int* NegWeightL_Offset; 200 201 int* VarOffset; 202 203 ideal qideal; /* extension to the ring structure: qring, rInit */ 204 205 int* firstwv; 206 207 omBin PolyBin; /* Bin from where monoms are allocated */ 208 #ifdef HAVE_RINGS 209 unsigned int ringtype; /* cring = 0 => coefficient field, cring = 1 => coeffs from Z/2^m */ 210 int_number ringflaga; /* Z/(ringflag^ringflagb)=Z/nrnModul*/ 211 unsigned long ringflagb; 212 unsigned long nr2mModul; /* Z/nr2mModul */ 213 int_number nrnModul; 214 #endif 215 unsigned long options; /* ring dependent options */ 216 217 int ch; /* characteristic, rInit */ 218 int ref; /* reference counter to the ring, interpreter */ 219 220 short float_len; /* additional char-flags, rInit */ 221 short float_len2; /* additional char-flags, rInit */ 222 223 short N; /* number of vars, rInit */ 224 225 short P; /* number of pars, rInit */ 226 short OrdSgn; /* 1 for polynomial rings, -1 otherwise, rInit */ 227 228 short firstBlockEnds; 229 #ifdef HAVE_PLURAL 230 short real_var_start, real_var_end; 231 #endif 232 233 #ifdef HAVE_SHIFTBBA 234 short isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */ 235 #endif 236 237 BOOLEAN VectorOut; 238 BOOLEAN ShortOut; 239 BOOLEAN CanShortOut; 240 BOOLEAN LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks 241 BOOLEAN MixedOrder; // TRUE for global/local mixed orderings, FALSE otherwise 242 243 BOOLEAN ComponentOrder; // ??? 244 245 // what follows below here should be set by rComplete, _only_ 246 // contains component, but no weight fields in E */ 247 short ExpL_Size; // size of exponent vector in long 248 short CmpL_Size; // portions which need to be compared 249 /* number of long vars in exp vector: 250 long vars are those longs in the exponent vector which are 251 occupied by variables, only */ 252 short VarL_Size; 253 short BitsPerExp; /* number of bits per exponent */ 254 short ExpPerLong; /* maximal number of Exponents per long */ 255 short pCompIndex; /* p->exp.e[pCompIndex] is the component */ 256 short pOrdIndex; /* p->exp[pOrdIndex] is pGetOrd(p) */ 257 short OrdSize; /* size of ord vector (in sro_ord) */ 258 259 /* if >= 0, long vars in exp vector are consecutive and start there 260 if < 0, long vars in exp vector are not consecutive */ 261 short VarL_LowIndex; 262 // number of exponents in r->VarL_Offset[0] 263 // is minimal number of exponents in a long var 264 short MinExpPerLong; 265 266 short NegWeightL_Size; 267 /* array of size VarL_Size, 268 VarL_Offset[i] gets i-th long var in exp vector */ 269 int* VarL_Offset; 270 271 /* mask for getting single exponents */ 272 unsigned long bitmask; 273 /* mask used for divisiblity tests */ 274 unsigned long divmask; // rComplete 275 276 p_Procs_s* p_Procs; // rComplete/p_ProcsSet 277 278 /* FDeg and LDeg */ 279 pFDegProc pFDeg; // rComplete/rSetDegStuff 280 pLDegProc pLDeg; // rComplete/rSetDegStuff 281 282 /* as it was determined by rComplete */ 283 pFDegProc pFDegOrig; 284 /* and as it was determined before rOptimizeLDeg */ 285 pLDegProc pLDegOrig; 286 287 p_SetmProc p_Setm; 288 n_Procs_s* cf; 289 ring algring; 290 #ifdef HAVE_PLURAL 291 private: 292 nc_struct* _nc; // private 293 public: 294 inline const nc_struct* GetNC() const { return _nc; }; // public!!! 295 inline nc_struct*& GetNC() { return _nc; }; // public!!! 296 #endif 297 }; 14 298 15 299 enum tHomog … … 42 326 #ifdef HAVE_PLURAL 43 327 nc_struct *n; 44 return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/; 328 return (r != NULL) && ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/; 45 329 #else 46 330 return false; … … 53 337 /* nc_struct *n; */ 54 338 return (r != NULL) /* && ((n=r->GetNC()) != NULL) */ 55 339 && (r->real_var_start>1); 56 340 #else 57 341 return false; … … 69 353 long* currShiftedComponents, 70 354 int length, 71 ring r = currRing);355 ring r); 72 356 void rDBGetSComps(int** currComponents, 73 357 long** currShiftedComponents, 74 358 int *length, 75 ring r = currRing);359 ring r); 76 360 #else 77 361 #define rChangeSComps(c,s,l) rNChangeSComps(c,s) … … 79 363 #endif 80 364 81 void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r = currRing);82 void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r = currRing);365 void rNChangeSComps(int* currComponents, long* currShiftedComponents, ring r); 366 void rNGetSComps(int** currComponents, long** currShiftedComponents, ring r); 83 367 84 368 //idhdl rFindHdl(ring r, idhdl n, idhdl w); … … 94 378 #define rVar(r) (r->N) 95 379 char * rParStr(ring r); 96 int rIsExtension(const ring r =currRing);380 int rIsExtension(const ring r); 97 381 int rSum(ring r1, ring r2, ring &sum); 98 382 int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp); … … 271 555 272 556 // misc things 273 static inline char* rRingVar(short i) 274 { 275 return currRing->names[i]; 276 } 277 static inline char* rRingVar(short i, ring r) 557 static inline char* rRingVar(short i, const ring r) 278 558 { 279 559 return r->names[i]; 280 560 } 281 static inline BOOLEAN rShortOut( ring r)561 static inline BOOLEAN rShortOut(const ring r) 282 562 { 283 563 return (r->ShortOut); … … 332 612 { return r->order[0] == ringorder_s;} 333 613 334 static inline int rGetCurrSyzLimit(const ring r = currRing)614 static inline int rGetCurrSyzLimit(const ring r) 335 615 { return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);} 336 616 … … 375 655 376 656 /// returns TRUE if var(i) belongs to p-block 377 BOOLEAN rIsPolyVar(int i, ring r = currRing);657 BOOLEAN rIsPolyVar(int i, ring r); 378 658 379 659 static inline BOOLEAN rOrd_is_Comp_dp(ring r) -
libpolys/polys/polys.cc
rce2120e r8a8c9e 35 35 poly ppNoether = NULL; 36 36 37 #ifdef HAVE_RINGS //TODO Oliver38 #define pDiv_nn(p, n) p_Div_nn(p, n, currRing)39 40 poly p_Div_nn(poly p, const number n, const ring r)41 {42 pAssume(!n_IsZero(n,r));43 p_Test(p, r);44 45 poly q = p;46 while (p != NULL)47 {48 number nc = pGetCoeff(p);49 pSetCoeff0(p, n_Div(nc, n, r));50 n_Delete(&nc, r);51 pIter(p);52 }53 p_Test(q, r);54 return q;55 }56 #endif57 58 37 #ifdef HAVE_RINGS 59 38 /* TRUE iff LT(f) | LT(g) */ -
libpolys/polys/sbuckets.h
rce2120e r8a8c9e 15 15 #define S_BUCKETS_H 16 16 17 #include <kernel/structs.h> 18 #include <kernel/ring.h> 17 #include <polys/monomials/ring.h> 19 18 20 19 21 20 class sBucket; 21 typedef sBucket* sBucket_pt; 22 22 ////////////////////////////////////////////////////////////////////////// 23 23 // Creation/Destruction of buckets 24 24 // 25 sBucket_pt sBucketCreate(ring r = currRing);25 sBucket_pt sBucketCreate(ring r); 26 26 void sBucketDestroy(sBucket_pt *bucket); 27 27
Note: See TracChangeset
for help on using the changeset viewer.