Changeset 512a2b in git for Singular/polys.h
- Timestamp:
- Sep 18, 2000, 11:19:39 AM (24 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- d1655e92ca71fb37d1b57af88efdff5b65b8988b
- Parents:
- f3398d316400fe1ee1677fc397cacb80566ac664
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/polys.h
rf3398d r512a2b 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1.3 7 2000-09-14 13:04:40 obachman Exp $ */6 /* $Id: polys.h,v 1.38 2000-09-18 09:19:30 obachman Exp $ */ 7 7 /* 8 * ABSTRACT - all basic methods to manipulate polynomials 8 * ABSTRACT - all basic methods to manipulate polynomials of the 9 currRing 9 10 */ 10 11 11 #include "structs.h" 12 #include "polys-impl.h" 13 /*************************************************************** 12 #include "p_polys.h" 13 /* 14 14 Some general remarks: 15 15 We divide poly operations into roughly 4 categories: … … 37 37 - debugging if PDEBUG >= 0 38 38 39 You can set PDEBUG on a per-file basis, before including "mod2.h" 39 You can set PDEBUG on a per-file basis, before including "mod2.h" like 40 #define PDEBUG 2 41 #include "mod2.h" 40 42 However, PDEBUG will only be in effect, if !NDEBUG. 41 43 … … 44 46 just macros to the respective p_*(..,currRing). 45 47 46 ***************************************************************/48 */ 47 49 48 50 /*************************************************************** … … 52 54 * 53 55 ***************************************************************/ 54 // next55 #define pNext(p) _pNext(p)56 #define pIter(p) _pIter(p)57 58 // coeff59 #define pGetCoeff(p) _pGetCoeff(p)60 56 // deletes old coeff before setting the new one 61 57 #define pSetCoeff(p,n) p_SetCoeff(p,n,currRing) 62 #define pSetCoeff0(p,n) _pSetCoeff0(p,n)63 #define p_GetCoeff(p,r) _pGetCoeff(p)64 #define p_SetCoeff0(p,n,r) _pSetCoeff0(p,n)65 PINLINE2 number p_SetCoeff(poly p, number n, ring r);66 58 67 59 // Order 68 60 #define pGetOrder(p) p_GetOrder(p, currRing) 69 PINLINE2 Order_t p_GetOrder(poly p, ring r);70 61 // don't use this 71 62 #define pSetOrder(p, o) p_SetOrder(p, o, currRing) 72 PINLINE2 Order_t p_SetOrder(poly p, long order, ring r);73 63 74 64 // Component … … 79 69 #define pAddComp(p,v) p_AddComp(p,v,currRing) 80 70 #define pSubComp(p,v) p_SubComp(p,v,currRing) 81 #define p_GetComp(p, r) _p_GetComp(p, r)82 PINLINE2 unsigned long p_SetComp(poly p, unsigned long c, ring r);83 PINLINE2 unsigned long p_IncrComp(poly p, ring r);84 PINLINE2 unsigned long p_DecrComp(poly p, ring r);85 PINLINE2 unsigned long p_AddComp(poly p, unsigned long v, ring r);86 PINLINE2 unsigned long p_SubComp(poly p, unsigned long v, ring r);87 71 88 72 // Exponent … … 94 78 #define pSubExp(p,i,v) p_SubExp(p,i,v, currRing) 95 79 #define pMultExp(p,i,v) p_MultExp(p,i,v, currRing) 96 PINLINE2 Exponent_t p_GetExp(poly p, int v, ring r); 97 PINLINE2 Exponent_t p_SetExp(poly p, int v, int e, ring r); 98 PINLINE2 Exponent_t p_IncrExp(poly p, int v, ring r); 99 PINLINE2 Exponent_t p_DecrExp(poly p, int v, ring r); 100 PINLINE2 Exponent_t p_AddExp(poly p, int v, Exponent_t ee, ring r); 101 PINLINE2 Exponent_t p_SubExp(poly p, int v, Exponent_t ee, ring r); 102 PINLINE2 Exponent_t p_MultExp(poly p, int v, Exponent_t ee, ring r); 103 104 // Gets Difference and sum of ith Exponent of m1, m2 105 #define pGetExpSum(m1, m2, i) p_GetExpSum(p1, p2, i, currRing) 106 #define pGetExpDiff(p1, p2, i) p_GetExpDiff(p1, p2, i, currRing) 80 #define pGetExpSum(p1, p2, i) p_GetExpSum(p1, p2, i, currRing) 81 #define pGetExpDiff(p1, p2, i) p_GetExpDiff(p1, p2, i, currRing) 107 82 108 83 /*************************************************************** 109 84 * 110 85 * Allocation/Initalization/Deletion 111 * except for pDelete1 and pHead, all polys must be != NULL 86 * except for pDeleteLm and pHead, all polys must be != NULL 87 * 112 88 ***************************************************************/ 113 89 // allocates the space for a new monomial -- no initialization !!! 114 90 #define pNew() p_New(currRing) 115 91 // allocates a new monomial and initializes everything to 0 116 PINLINE1 poly pInit(); 117 // like pInit, except that expvector is initialized to that of p, p must be != NULL 118 PINLINE1 poly pInit(poly p); 119 // returns newly allocated copy of Lm(p), coef is copied, next=NULL, p might be NULL 92 #define pInit() p_Init(currRing) 93 // like pInit, except that expvector is initialized to that of p, 94 // p must be != NULL 95 #define pLmInit(p) p_LmInit(p, currRing) 96 // returns newly allocated copy of Lm(p), coef is copied, next=NULL, 97 // p might be NULL 120 98 #define pHead(p) p_Head(p, currRing) 121 // if *p_ptr != NULL, delete *p_ptr->coef, *p_ptr, and set *p_ptr to pNext(*p_ptr) 122 #define pDelete1(p_ptr) p_Delete1(p_ptr, currRing) 99 // if *p_ptr != NULL, delete p_ptr->coef, *p_ptr, and set *p_ptr to 100 // pNext(*p_ptr) 101 static inline void pDeleteLm(poly *p) {p_DeleteLm(p, currRing);} 102 // if (p!=NULL) delete p-coef and p 103 static inline void pDeleteLm(poly p) {p_DeleteLm(p, currRing);} 123 104 // frees the space of the monomial m, assumes m != NULL 124 105 // coef is not freed, m is not advanced 125 #define pFree(m) p_Free(m, currRing) 106 static inline void pLmFree(poly p) {p_LmFree(p, currRing);} 107 // like pLmFree, but advances p 108 static inline void pLmFree(poly *p) {p_LmFree(p, currRing);} 126 109 // assumes p != NULL, deletes p, returns pNext(p) 127 #define p FreeAndNext(p) p_FreeAndNext(p, currRing)110 #define pLmFreeAndNext(p) p_LmFreeAndNext(p, currRing) 128 111 // assume p != NULL, deletes Lm(p)->coef and Lm(p) 129 112 #define pLmDelete(p) p_LmDelete(p, currRing) 130 113 // like pLmDelete, returns pNext(p) 131 114 #define pLmDeleteAndNext(p) p_LmDeleteAndNext(p, currRing) 132 133 PINLINE2 poly p_New(ring r);134 PINLINE1 poly p_Init(ring r);135 PINLINE1 poly p_Init(poly p, ring r);136 PINLINE1 poly p_Head(poly p, ring r);137 PINLINE2 void p_Delete1(poly *p, ring r);138 PINLINE2 void p_Free(poly p, ring r);139 PINLINE2 poly p_LmFreeAndNext(poly p, ring r);140 PINLINE2 void p_LmDelete(poly p, ring r);141 PINLINE2 poly p_LmDeleteAndNext(poly p, ring r);142 115 // used by iparith.cc 143 116 extern poly pHeadProc(poly p); … … 148 121 * 149 122 ***************************************************************/ 150 // ExpVextor(d_p) = ExpVector(s_p)151 PINLINE1 void p_ExpVectorCopy(poly d_p, poly s_p, ring r);152 // ExpVector(p1) += ExpVector(p2)153 PINLINE1 void p_ExpVectorAdd(poly p1, poly p2, ring r);154 // ExpVector(p1) -= ExpVector(p2)155 PINLINE1 void p_ExpVectorSub(poly p1, poly p2, ring r);156 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2)157 PINLINE1 void p_ExpVectorSum(poly pr, poly p1, poly p2, ring r);158 // ExpVector(pr) = ExpVector(p1) + ExpVector(p2)159 PINLINE1 void p_ExpVectorDiff(poly pr, poly p1, poly p2, ring r);160 // returns TRUE if ExpVector(p1) == ExpVector(p2), FALSE, otherwise161 PINLINE1 BOOLEAN p_ExpVectorEqual(poly p1, poly p2, ring r);162 // returns sum of all exponents163 PINLINE1 unsigned long p_ExpVectorQuerSum(poly p, ring r);164 123 165 124 #define pExpVectorCopy(d_p, s_p) p_ExpVectorCopy(d_p, s_p, currRing) … … 170 129 #define pExpVectorEqual(p1, p2) p_ExpVectorEqual(p1, p2, currRing) 171 130 #define pExpVectorQuerSum(p) p_ExpVectorQuerSum(p, currRing) 172 #define pEqual(p1, p2) pExpVectorEqual(p1, p2) 173 174 // Gets a copy of (resp. sets) the exponent vector, where e is assumed 175 // to point to (pVariables+1)*sizeof(Exponent_t) memory. Exponents are 131 132 // Gets a copy of (resp. set) the exponent vector, where e is assumed 133 // to point to (r->N +1)*sizeof(Exponent_t) memory. Exponents are 176 134 // filled in as follows: comp, e_1, .., e_n 177 135 #define pGetExpV(p, e) p_GetExpV(p, e, currRing) 178 136 #define pSetExpV(p, e) p_SetExpV(p, e, currRing) 179 PINLINE1 void p_GetExpV(poly p, Exponent_t *ev, ring r); 180 PINLINE1 void p_SetExpV(poly p, Exponent_t *ev, ring r); 181 182 183 184 /*************************************************************** 185 * 186 * Operations on Lm: assumes polys != NULL 137 138 /*************************************************************** 139 * 140 * Comparisons: they are all done without regarding coeffs 187 141 * 188 142 ***************************************************************/ … … 193 147 #define pLmCmpAction(p,q, actionE, actionG, actionS) \ 194 148 _p_LmCmpAction(p,q,currRing, actionE, actionG,actionS) 195 PINLINE1 int p_LmCmp(poly p, poly q, ring r); 196 #define p_LmCmpAction(p, q, r, actionE, actionG, actionS) \ 197 _p_LmCmpAction(p, q, r, actionE, actionG, actionS) 198 199 // returns 1 if Lm(p)=Lm(q) -- including comparison of coeff 200 PINLINE1 BOOLEAN p_LmEqual(poly p, poly q, ring r); 201 #define pLmEqual(p,q) p_LmEqual(p,q,currRing) 149 150 #define pLmEqual(p1, p2) pExpVectorEqual(p1, p2) 202 151 203 152 // pCmp: args may be NULL 204 153 // returns: (p2==NULL ? 1 : (p1 == NULL ? -1 : p_LmCmp(p1, p2))) 205 154 #define pCmp(p1, p2) p_Cmp(p1, p2, currRing) 206 PINLINE2 int p_Cmp(poly p1, poly p2, ring r);207 155 208 156 … … 214 162 ***************************************************************/ 215 163 // returns TRUE, if leading monom of a divides leading monom of b 216 // i.e., if there exists a expvector c > 0, s.t. b = a + c; assumes b != NULL164 // i.e., if there exists a expvector c > 0, s.t. b = a + c; 217 165 #define pDivisibleBy(a, b) p_DivisibleBy(a,b,currRing) 218 // like pDivisibleBy, except that it is assumed that a!=NULL 219 #define p DivisibleBy1(a,b) p_DivisibleBy1(a,b,currRing)220 // like p DivisibleBy1, does not check components221 #define p DivisibleBy2(a, b) p_DivisibleBy2(a,b,currRing)166 // like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL 167 #define pLmDivisibleBy(a,b) p_LmDivisibleBy(a,b,currRing) 168 // like pLmDivisibleBy, does not check components 169 #define pLmDivisibleByNoComp(a, b) p_LmDivisibleByNoComp(a,b,currRing) 222 170 // Divisibility tests based on Short Exponent vectors 223 171 // sev_a == pGetShortExpVector(a) 224 172 // not_sev_b == ~ pGetShortExpVector(b) 225 PINLINE1 BOOLEAN p_DivisibleBy(poly a, poly b, ring r); 226 PINLINE1 BOOLEAN p_DivisibleBy1(poly a, poly b, ring r); 227 PINLINE1 BOOLEAN p_DivisibleBy2(poly a, poly b, ring r); 173 #define pLmShortDivisibleBy(a, sev_a, b, not_sev_b) \ 174 p_LmShortDivisibleBy(a, sev_a, b, not_sev_b, currRing) 228 175 // returns the "Short Exponent Vector" -- used to speed up divisibility 229 176 // tests (see polys-impl.cc ) 230 177 #define pGetShortExpVector(a) p_GetShortExpVector(a, currRing) 231 #define pShortDivisibleBy(a, sev_a, b, not_sev_b) \232 p_ShortDivisibleBy(a, sev_a, b, not_sev_b, currRing)233 unsigned long p_GetShortExpVector(poly a, ring r);234 PINLINE1 BOOLEAN p_ShortDivisibleBy(poly a, unsigned long sev_a,235 poly b, unsigned long not_sev_b, ring r);236 178 237 179 /*************************************************************** … … 242 184 // return a copy of the poly 243 185 #define pCopy(p) p_Copy(p, currRing) 244 // returns a copy of p245 PINLINE2 poly p_Copy(poly p, const ring r);246 // returns a copy of p with Lm(p) from lmRing and Tail(p) from tailRing247 PINLINE2 poly p_Copy(poly p, const ring lmRing, const ring tailRing);248 // deletes *p, and sets *p to NULL249 PINLINE2 void p_Delete(poly *p, const ring r);250 186 #define pDelete(p_ptr) p_Delete(p_ptr, currRing) 251 252 187 253 188 /*************************************************************** … … 261 196 * 262 197 ***************************************************************/ 263 // returns -p, p is destroyed264 PINLINE2 poly p_Neg(poly p, const ring r);265 266 // returns p*n, p is const (i.e. copied)267 PINLINE2 poly pp_Mult_nn(poly p, number n, const ring r);268 // returns p*n, destroys p269 PINLINE2 poly p_Mult_nn(poly p, number n, const ring r);270 271 // returns p*m, does neither destroy p nor m272 PINLINE2 poly pp_Mult_mm(poly p, poly m, const ring r);273 // returns p*m, destroys p, const: m274 PINLINE2 poly p_Mult_mm(poly p, poly m, const ring r);275 276 // returns p+q, destroys p and q277 PINLINE2 poly p_Add_q(poly p, poly q, const ring r);278 // like p_Add_q, except that if lp == pLength(lp) lq == pLength(lq)279 // then lp == pLength(p+q)280 PINLINE2 poly p_Add_q(poly p, poly q, int &lp, int lq, const ring r);281 282 // return p - m*q, destroys p; const: q,m283 PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, const ring r);284 // like p_Minus_mm_Mult_qq, except that if lp == pLength(lp) lq == pLength(lq)285 // then lp == pLength(p -m*q)286 PINLINE2 poly p_Minus_mm_Mult_qq(poly p, poly m, poly q, int &lp, int lq,287 poly spNoether, const ring r);288 // returns p + m*q destroys p, const: q, m289 PINLINE2 poly p_Plus_mm_Mult_qq(poly p, poly m, poly q, const ring r);290 291 // returns p*q, destroys p and q292 PINLINE2 poly p_Mult_q(poly p, poly q, const ring r);293 // returns p*q, does neither destroy p nor q294 PINLINE2 poly pp_Mult_qq(poly p, poly q, const ring r);295 296 198 #define pNeg(p) p_Neg(p, currRing) 297 199 #define ppMult_nn(p, n) pp_Mult_nn(p, n, currRing) … … 342 244 /*-----------the ordering of monomials:-------------*/ 343 245 #define pSetm(p) p_Setm(p, currRing) 344 extern void p_Setm(poly p, ring r);345 246 // TODO: 346 247 #define pSetmComp pSetm 347 #define p_SetmComp p_Setm348 248 349 249 extern pLDegProc pLDeg; … … 379 279 poly pDiffOp(poly a, poly b,BOOLEAN multiply); 380 280 381 int pLength(poly a);382 281 int pMaxComp(poly p); 383 282 int pMinComp(poly p, ring r=currRing); … … 385 284 int pWeight(int c); 386 285 #define pSetCompP(a,i) p_SetCompP(a, i, currRing) 387 PINLINE0 void p_SetCompP(poly a, int i, ring r);388 PINLINE0 void p_SetCompP(poly a, int i, ring lmRing, ring tailRing);389 286 390 287 … … 463 360 464 361 /*-----------specials for spoly-computations--------------*/ 465 int pDivComp(poly p, poly q);466 362 BOOLEAN pCompareChain (poly p,poly p1,poly p2,poly lcm); 467 363 BOOLEAN pEqualPolys(poly p1,poly p2); 468 364 BOOLEAN pComparePolys(poly p1,poly p2); 469 365 470 /*-----------Misc stuff-----------------------------------*/471 // reverses the monomials of p472 PINLINE0 poly pReverse(poly p);473 366 474 367 … … 479 372 ***************************************************************/ 480 373 #ifdef PDEBUG 481 // Returns TRUE if m is monom of p, FALSE otherwise482 BOOLEAN pIsMonomOf(poly p, poly m);483 // Returns TRUE if p and q have common monoms484 BOOLEAN pHaveCommonMonoms(poly p, poly q);485 486 // p_Check* routines return TRUE if everything is ok,487 // else, they report error message and return false488 489 // check if poly p is from ring r490 BOOLEAN p_CheckIsFromRing(poly p, ring r);491 // check if p != NULL, r != NULL and initialized && p is from r492 BOOLEAN p_CheckPolyRing(poly p, ring r);493 // check if r != NULL and initialized494 BOOLEAN p_CheckRing(ring r);495 // only do check if cond496 #define pIfThen(cond, check) do {if (cond) {check;}} while (0)497 498 BOOLEAN _p_Test(poly p, ring r, int level);499 BOOLEAN _p_LmTest(poly p, ring r, int level);500 BOOLEAN _pp_Test(poly p, ring lmRing, ring tailRing, int level);501 502 374 #define pTest(p) _p_Test(p, currRing, PDEBUG) 503 #define p_Test(p,r) _p_Test(p, r, PDEBUG)504 375 #define pLmTest(p) _p_LmTest(p, currRing, PDEBUG) 505 #define p_LmTest(p,r) _p_LmTest(p, r, PDEBUG)506 #define pp_Test(p, lmRing, tailRing) _pp_Test(p, lmRing, tailRing, PDEBUG)507 376 508 377 #else // ! PDEBUG 509 378 510 511 #define pIsMonomOf(p, q) (TRUE)512 #define pHaveCommonMonoms(p, q) (TRUE)513 #define p_CheckIsFromRing(p,r) ((void)0)514 #define p_CheckPolyRing(p,r) ((void)0)515 #define p_CheckRing(r) ((void)0)516 #define P_CheckIf(cond, check) ((void)0)517 518 379 #define pTest(p) ((void)0) 519 #define p_Test(p,r) ((void)0)520 380 #define pLmTest(p) ((void)0) 521 #define p_LmTest(p,r) ((void)0)522 #define pp_Test(p, lmRing, tailRing) ((void)0)523 524 381 #endif 525 382 526 383 #endif // POLYS_H 527 384 528 #include "pInline2.h"529 #include "pInline1.h"
Note: See TracChangeset
for help on using the changeset viewer.