Changeset a9a7be in git for Singular/polys-impl.h
- Timestamp:
- Sep 27, 1999, 5:05:35 PM (25 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 7c19609b3106a80912e66f6ac4fa0fa446532b1f
- Parents:
- 7d423ecfe560c226d3e99aed883841c463e884ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/polys-impl.h
r7d423e ra9a7be 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys-impl.h,v 1.3 1 1999-08-23 13:15:58 SingularExp $ */6 /* $Id: polys-impl.h,v 1.32 1999-09-27 15:05:29 obachman Exp $ */ 7 7 8 8 /*************************************************************** … … 31 31 #define VARS (0) 32 32 #endif 33 34 typedef Exponent_t monomial[VARS + 1]; 33 union s_exp 34 { 35 Exponent_t e[VARS +1]; 36 long l[(VARS +1)/2]; 37 }; 38 39 //typedef Exponent_t monomial[VARS + 1]; 40 typedef s_exp monomial; 35 41 typedef Exponent_t* Exponent_pt; 36 42 … … 40 46 poly next; // next needs to be the first field 41 47 number coef; // and coef the second --- do not change this !!! 42 Order_t Order;43 48 monomial exp; // make sure that exp is aligned 44 49 }; … … 50 55 ***************************************************************/ 51 56 52 #define POLYSIZE (sizeof(poly) + sizeof(number) + sizeof(Order_t))57 #define POLYSIZE (sizeof(poly) + sizeof(number)) 53 58 #define POLYSIZEW (POLYSIZE / sizeof(long)) 54 59 #define MAX_EXPONENT_NUMBER ((MAX_BLOCK_SIZE - POLYSIZE) / SIZEOF_EXPONENT) … … 61 66 extern int pMonomSizeW; 62 67 // Ceiling((pVariables+1) / sizeof(void*)) == length of exp-vector in words 63 extern int pVariables1W;68 // extern int pVariables1W; 64 69 // Ceiling((pVariables) / sizeof(void*)) 65 extern int pVariablesW;70 // extern int pVariablesW; 66 71 extern int *pVarOffset; 67 extern int pVarLowIndex;68 extern int pVarHighIndex;69 extern int pVarCompIndex;72 // extern int pVarLowIndex; 73 // extern int pVarHighIndex; 74 // extern int pVarCompIndex; 70 75 71 76 /*************************************************************** … … 74 79 * 75 80 ***************************************************************/ 76 #define _pExpIndex(i) pVarOffset[(i)]81 #define _pExpIndex(i) (currRing->VarOffset[(i)]) 77 82 #define _pRingExpIndex(r, i) (r)->VarOffset[(i)] 78 83 79 #define _pCompIndex pVarOffset[0] 80 #define _pRingCompIndex(r) ((r)->VarOffset[0]) 81 82 // for simple, lex orderings 83 extern void pGetVarIndicies_Lex(int nvars, int* VarOffset, int &VarCompIndex, 84 int &VarLowIndex, int &VarHighIndex); 85 // for simple, revlex orderings 86 extern void pGetVarIndicies_RevLex(int nvars,int *VarOffset,int &VarCompIndex, 87 int &VarLowIndex, int &VarHighIndex); 88 // for all non-simple orderings 89 extern void pGetVarIndicies(int nvars, int *VarOffset, int &VarCompIndex, 90 int &VarLowIndex, int &VarHighIndex); 91 // gets var indicies w.r.t. the ring r -- 92 // determines which one of three pGetVarIndicies((int nvars, ...) to use 93 // based on properties of r 94 extern void pGetVarIndicies(ring r, int *VarOffset, int &VarCompIndex, 95 int &VarLowIndex, int &VarHighIndex); 84 #define _pCompIndex (currRing->pCompIndex) 85 #define _pRingCompIndex(r) ((r)->pCompIndex) 96 86 97 87 /*************************************************************** … … 107 97 #define _pSetCoeff0(p,n) (p)->coef=n 108 98 109 #define _pGetOrder(p) ((p)-> Order)99 #define _pGetOrder(p) ((p)->exp.l[currRing->pOrdIndex]) 110 100 111 101 #if defined(PDEBUG) && PDEBUG != 0 … … 121 111 extern Exponent_t pPDRingGetExp(ring r,poly p, int v, char* f, int l); 122 112 113 extern Exponent_t pDBSetComp(poly p, Exponent_t k, int l, char* f, int l); 114 extern Exponent_t pDBDecrComp(poly p, char* f, int l); 115 extern Exponent_t pDBAddComp(poly p, Exponent_t k, int l, char* f, int l); 116 extern Exponent_t pDBSubComp(poly p, Exponent_t k, char* f, int l); 117 extern Exponent_t pDBRingSetComp(ring r, poly p, Exponent_t k, char* f, int l); 118 119 123 120 #define _pSetExp(p,v,e) pPDSetExp(p,v,e,__FILE__,__LINE__) 124 121 #define _pGetExp(p,v) pPDGetExp(p,v,__FILE__,__LINE__) … … 132 129 #define _pRingGetExp(r,p,v) pPDRingGetExp(r,p,v,__FILE__,__LINE__) 133 130 131 #define _pSetComp(p,k) pDBSetComp(p, k, 0, __FILE__, __LINE__) 132 #define _pDecrComp(p) pDBDecrComp(p, __FILE__, __LINE__) 133 #define _pAddComp(p,v) pDBAddComp(p,v, 0, __FILE__, __LINE__) 134 #define _pSubComp(p,v) pDBSubComp(p,v, __FILE__, __LINE__) 135 #define _pRingSetComp(r,p,k) pDBRingSetComp(r, p, k, __FILE__, __LINE__) 136 137 #define pSetCompS(p, k, l) pDBSetComp(p, k, l, __FILE__, __LINE__) 138 134 139 #else // ! (defined(PDEBUG) && PDEBUG != 0) 135 140 136 #define _pSetExp(p,v,e) (p)->exp[_pExpIndex(v)]=(e) 137 #define _pGetExp(p,v) (p)->exp[_pExpIndex(v)] 138 #define _pIncrExp(p,v) ((p)->exp[_pExpIndex(v)])++ 139 #define _pDecrExp(p,v) ((p)->exp[_pExpIndex(v)])-- 140 #define _pAddExp(p,i,v) ((p)->exp[_pExpIndex(i)]) += (v) 141 #define _pSubExp(p,i,v) ((p)->exp[_pExpIndex(i)]) -= (v) 142 #define _pMultExp(p,i,v) ((p)->exp[_pExpIndex(i)]) *= (v) 143 144 #define _pRingSetExp(r,p,v,e) (p)->exp[_pRingExpIndex(r,v)]=(e) 145 #define _pRingGetExp(r,p,v) (p)->exp[_pRingExpIndex(r,v)] 146 147 #endif // defined(PDEBUG) && PDEBUG != 0 148 149 inline Exponent_t _pGetExpSum(poly p1, poly p2, int i) 150 { 151 int index = _pExpIndex(i); 152 return p1->exp[index] + p2->exp[index]; 153 } 154 inline Exponent_t _pGetExpDiff(poly p1, poly p2, int i) 155 { 156 int index = _pExpIndex(i); 157 return p1->exp[index] - p2->exp[index]; 158 } 159 160 #define _pGetComp(p) ((p)->exp[_pCompIndex]) 141 #define _pSetExp(p,v,E) (p)->exp.e[_pExpIndex(v)]=(E) 142 #define _pGetExp(p,v) (p)->exp.e[_pExpIndex(v)] 143 #define _pIncrExp(p,v) ((p)->exp.e[_pExpIndex(v)])++ 144 #define _pDecrExp(p,v) ((p)->exp.e[_pExpIndex(v)])-- 145 #define _pAddExp(p,i,v) ((p)->exp.e[_pExpIndex(i)]) += (v) 146 #define _pSubExp(p,i,v) ((p)->exp.e[_pExpIndex(i)]) -= (v) 147 #define _pMultExp(p,i,v) ((p)->exp.e[_pExpIndex(i)]) *= (v) 148 149 #define _pRingSetExp(r,p,v,e) (p)->exp.e[_pRingExpIndex(r,v)]=(e) 150 #define _pRingGetExp(r,p,v) (p)->exp.e[_pRingExpIndex(r,v)] 151 161 152 #define _pSetComp(p,k) _pGetComp(p) = (k) 162 #define _pIncrComp(p) _pGetComp(p)++163 153 #define _pDecrComp(p) _pGetComp(p)-- 164 154 #define _pAddComp(p,v) _pGetComp(p) += (v) 165 155 #define _pSubComp(p,v) _pGetComp(p) -= (v) 166 167 #define _pRingGetComp(r,p) ((p)->exp[_pRingCompIndex(r)]) 168 #define _pRingSetComp(r,p,k) (_pRingGetComp(p) = (k)) 156 #define _pRingSetComp(r,p,k) (_pRingGetComp(r, p) = (k)) 157 #define pSetCompS(p, k,l) _pSetComp(p, k) 158 159 #endif // defined(PDEBUG) && PDEBUG != 0 160 161 #define _pGetComp(p) ((p)->exp.e[_pCompIndex]) 162 #define _pIncrComp(p) _pGetComp(p)++ 163 #define _pRingGetComp(r,p) ((p)->exp.e[_pRingCompIndex(r)]) 164 165 inline Exponent_t _pGetExpSum(poly p1, poly p2, int i) 166 { 167 int index = _pExpIndex(i); 168 return p1->exp.e[index] + p2->exp.e[index]; 169 } 170 inline Exponent_t _pGetExpDiff(poly p1, poly p2, int i) 171 { 172 int index = _pExpIndex(i); 173 return p1->exp.e[index] - p2->exp.e[index]; 174 } 175 169 176 170 177 inline void _pGetExpV(poly p, Exponent_t *ev) … … 193 200 #ifdef MDEBUG 194 201 195 poly pDBInit( char *f, int l);202 poly pDBInit(memHeap h, char *f, int l); 196 203 poly pDBCopy(poly a, char *f, int l); 204 poly pDBCopy(memHeap h, poly a, char *f, int l); 197 205 poly pDBCopy1(poly a, char *f, int l); 198 poly pDBHead( poly a, char *f, int l);206 poly pDBHead(memHeap h, poly a, char *f, int l); 199 207 poly pDBHead0(poly a, char *f, int l); 200 208 poly pDBFetchCopy(ring r, poly a, char *f, int l); 201 202 void pDBDelete(poly * a, char * f, int l); 203 void pDBDelete1(poly * a, char * f, int l); 204 205 #define pDBNew(f,l) (poly) mmDBAllocHeap(mm_specHeap, f,l) 206 #define _pNew() (poly) mmDBAllocHeap(mm_specHeap, __FILE__, __LINE__) 207 #define _pInit() (poly) pDBInit(__FILE__,__LINE__) 208 209 #define pDBFree1(a,f,l) mmDBFreeHeap((void*)a, mm_specHeap, f, l) 210 211 #define _pDelete(a) pDBDelete((a),__FILE__,__LINE__) 212 #define _pDelete1(a) pDBDelete1((a),__FILE__,__LINE__) 213 214 #define _pCopy(A) pDBCopy(A,__FILE__,__LINE__) 209 poly pDBFetchCopyDelete(ring r, poly a, char *f, int l); 210 poly pDBFetchHead(ring r, poly a, char *f, int l); 211 poly pDBFetchHeadDelete(ring r, poly a, char *f, int l); 212 poly pDBShallowCopyDeleteHead(memHeap d_h,poly *s_p,memHeap s_h, 213 char *f,int l); 214 poly pDBShallowCopyDelete(memHeap d_h,poly *s_p,memHeap s_h, char *f,int l); 215 216 217 void pDBDelete(poly * a, memHeap h, char * f, int l); 218 void pDBDelete1(poly * a, memHeap h, char * f, int l); 219 220 #define pDBNew(h, f,l) (poly) mmDBAllocHeap(h, f,l) 221 #define _pNew(h) (poly) mmDBAllocHeap(h, __FILE__, __LINE__) 222 #define _pInit(h) (poly) pDBInit(h, __FILE__,__LINE__) 223 224 #define pDBFree1(a,h,f,l) mmDBFreeHeap((void*)a, h, f, l) 225 #define _pFree1(a, h) mmDBFreeHeap((void*)a, h, __FILE__, __LINE__) 226 227 #define _pDelete(a, h) pDBDelete((a),h, __FILE__,__LINE__) 228 #define _pDelete1(a, h) pDBDelete1((a),h, __FILE__,__LINE__) 229 230 #define _pCopy(h, A) pDBCopy(h,A,__FILE__,__LINE__) 215 231 #define _pCopy1(A) pDBCopy1(A, __FILE__,__LINE__) 216 #define _pHead( A) pDBHead(A,__FILE__,__LINE__)232 #define _pHead(h, A) pDBHead(h, A,__FILE__,__LINE__) 217 233 #define _pHead0(A) pDBHead0(A, __FILE__,__LINE__) 218 #define _pFetchCopy(r,A) pDBFetchCopy(r, A,__FILE__,__LINE__) 234 235 #define _pShallowCopyDeleteHead(dest_heap, source_p, source_heap) \ 236 pDBShallowCopyDeleteHead(dest_heap, source_p, source_heap,__FILE__,__LINE__) 237 #define _pShallowCopyDelete(dest_heap, source_p, source_heap) \ 238 pDBShallowCopyDelete(dest_heap, source_p, source_heap,__FILE__,__LINE__) 239 240 #define _pFetchCopy(r,A) pDBFetchCopy(r, A,__FILE__,__LINE__) 241 #define _pFetchCopyDelete(r,A) pDBFetchCopyDelete(r, A,__FILE__,__LINE__) 242 #define _pFetchHead(r,A) pDBFetchHead(r, A,__FILE__,__LINE__) 243 #define _pFetchHeadDelete(r,A) pDBFetchHeadDelete(r, A,__FILE__,__LINE__) 244 245 #define _pRingFree1(r, A) pDBFreeHeap(A,r->mm_specHeap,__FILE__,__LINE__) 246 #define _pRingDelete1(r, A) pDBDelete1(A,r->mm_specHeap,__FILE__,__LINE__) 247 #define _pRingDelete(r, A) pDBDelete(A,r->mm_specHeap,__FILE__, __LINE__) 219 248 220 249 #else // ! MDEBUG 221 250 222 inline poly _pNew() 223 { 224 void * p; 225 AllocHeap(p, mm_specHeap); 226 return (poly)p; 227 } 228 229 inline poly _pInit(void) 230 { 231 poly p = _pNew(); 232 memsetW((long*)p,0, pMonomSizeW); 251 inline poly _pNew(memHeap h) 252 { 253 poly p; 254 AllocHeap(p, h); 233 255 return p; 234 256 } 235 257 236 extern void _pDelete(poly * a); 237 extern void _pDelete1(poly * a); 258 inline poly _pInit(memHeap h) 259 { 260 poly p; 261 AllocHeap(p, h); 262 memsetW((long *)p,0, pMonomSizeW); 263 return p; 264 } 265 266 #define _pFree1(a, h) FreeHeap(a, h) 267 #define _pRingFree1(r, a) FreeHeap(a, r->mm_specHeap) 268 #define _pRingDelete1(r, A) _pDelete1(A, r->mm_specHeap) 269 #define _pRingDelete(r, A) _pDelete(A, r->mm_specHeap) 270 271 extern void _pDelete(poly * a, memHeap h); 272 extern void _pDelete1(poly * a, memHeap h); 238 273 239 274 extern poly _pCopy(poly a); 275 extern poly _pCopy(memHeap h, poly a); 240 276 extern poly _pCopy1(poly a); 241 extern poly _pHead( poly a);277 extern poly _pHead(memHeap h, poly a); 242 278 extern poly _pHead0(poly a); 279 extern poly _pShallowCopyDeleteHead(memHeap d_h, poly *s_p, memHeap s_h); 280 extern poly _pShallowCopyDelete(memHeap d_h, poly *s_p, memHeap s_h); 281 243 282 extern poly _pFetchCopy(ring r,poly a); 283 extern poly _pFetchCopyDelete(ring r,poly a); 284 extern poly _pFetchHead(ring r,poly a); 285 extern poly _pFetchHeadDelete(ring r,poly a); 286 244 287 #endif // MDEBUG 245 288 246 289 #define _pCopy2(p1, p2) memcpyW(p1, p2, pMonomSizeW) 247 #define _pFree1(a) FreeHeap(a, mm_specHeap) 290 248 291 249 292 /*************************************************************** … … 280 323 #endif // defined(PDEBUG) && PDEBUG == 1 281 324 { 282 // OK -- this might be the only place where we are kind of quick and 283 // dirty: the following only works correctly if all exponents are 284 // positive and the sum of two exponents does not exceed 285 // EXPONENT_MAX 286 Exponent_t c2 = _pGetComp(p2); 287 int i = pVariables1W; 288 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 289 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 290 // set comp of p2 temporarily to 0, so that nothing is added to comp of p1 291 _pSetComp(p2, 0); 292 325 int i = currRing->ExpLSize; 326 long* s1 = &(p1->exp.l[0]); 327 const long* s2 = &(p2->exp.l[0]); 293 328 for (;;) 294 329 { … … 299 334 s2++; 300 335 } 301 // reset comp of p2 302 _pSetComp(p2, c2); 303 _pGetOrder(p1) += _pGetOrder(p2); 304 } 305 306 // Makes p1 a copy of p2 and adds on exponets of p3 336 } 337 338 #if defined(PDEBUG) && PDEBUG == 1 339 #define _pMonSubFast(p1, p2) pDBMonSubFast(p1, p2, __FILE__, __LINE__) 340 extern void pDBMonSubFast(poly p1, poly p2, char* f, int l); 341 inline void __pMonSubFast(poly p1, poly p2) 342 #else 343 DECLARE(void, _pMonSubFast(poly p1, poly p2)) 344 #endif // defined(PDEBUG) && PDEBUG == 1 345 { 346 int i = currRing->ExpLSize; 347 long* s1 = &(p1->exp.l[0]); 348 const long* s2 = &(p2->exp.l[0]); 349 350 for (;;) 351 { 352 *s1 -= *s2; 353 i--; 354 if (i==0) break; 355 s1++; 356 s2++; 357 } 358 } 359 360 // Makes p1 a copy of p2 and adds on exponents of p3 307 361 #if defined(PDEBUG) && PDEBUG == 1 308 362 #define _pCopyAddFast(p1, p2, p3) pDBCopyAddFast(p1, p2, p3, __FILE__, __LINE__) … … 313 367 #endif // defined(PDEBUG) && PDEBUG == 1 314 368 { 315 unsigned long* s1 = (unsigned long*) &(p1->exp[0]);316 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);317 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]);318 const unsigned long* const ub = s3 + pVariables1W;369 long* s1 = &(p1->exp.l[0]); 370 const long* s2 = &(p2->exp.l[0]); 371 const long* s3 = &(p3->exp.l[0]); 372 const long* const ub = s3 + currRing->ExpLSize; 319 373 320 374 p1->next = p2->next; … … 331 385 // we first are supposed to do a copy from p2 to p1 -- therefore, 332 386 // component of p1 is set to comp of p2 333 _pSetComp(p1, _pGetComp(p2)); 334 _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3); 387 // _pSetComp(p1, _pGetComp(p2)); 335 388 } 336 389 … … 344 397 #endif // defined(PDEBUG) && PDEBUG == 1 345 398 { 346 unsigned long* s1 = (unsigned long*) &(p1->exp[0]);347 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]);348 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]);349 const unsigned long* const ub = s3 + pVariables1W;399 long* s1 = &(p1->exp.l[0]); 400 const long* s2 = &(p2->exp.l[0]); 401 const long* s3 = &(p3->exp.l[0]); 402 const long* const ub = s3 + currRing->ExpLSize; 350 403 351 404 p1->coef = p2->coef; … … 359 412 s2++; 360 413 } 361 _pSetComp(p1, _pGetComp(p2)); 362 _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3); 363 } 364 365 // Similar to pCopyAddFast0, except that we do not recompute the Order, 366 // but assume that it is the sum of the Order of p2 and p3 367 #if defined(PDEBUG) && PDEBUG == 1 368 #define _pCopyAddFastHomog(p1, p2, p3, Order) \ 369 pDBCopyAddFastHomog(p1, p2, p3, Order, __FILE__, __LINE__) 370 extern void pDBCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order, 371 char* f, int l); 372 inline void __pCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order) 373 #else 374 DECLARE(void, _pCopyAddFastHomog(poly p1, poly p2, poly p3, Order_t Order)) 375 #endif // defined(PDEBUG) && PDEBUG == 1 376 { 377 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 378 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 379 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]); 380 const unsigned long* const ub = s3 + pVariables1W; 381 382 p1->coef = p2->coef; 383 p1->Order = Order; 384 385 for (;;) 386 { 387 *s1 = *s2 + *s3; 388 s3++; 389 if (s3 == ub) break; 390 s1++; 391 s2++; 392 } 393 _pSetComp(p1, _pGetComp(p2)); 414 // _pSetComp(p1, _pGetComp(p2)); 394 415 } 395 416 … … 419 440 #endif 420 441 442 // #define LONG_MONOMS 443 444 #ifdef LONG_MONOMS 421 445 DECLARE(BOOLEAN, __pDivisibleBy(poly a, poly b)) 422 446 { 423 #ifdef WORDS_BIGENDIAN 424 const unsigned long* const lb = (unsigned long*) &(a->exp[0]);; 425 const unsigned long* s1 = ((unsigned long*) a) + pMonomSizeW -1; 426 const unsigned long* s2 = ((unsigned long*) b) + pMonomSizeW -1; 427 #else 428 const unsigned long* const lb = ((unsigned long*) a) + pMonomSizeW; 429 const unsigned long* s1 = (unsigned long*) &(a->exp[0]); 430 const unsigned long* s2 = (unsigned long*) &(b->exp[0]); 431 #endif 447 const unsigned long* const lb = (unsigned long*) &(a->exp.l[currRing->pDivLow]); 448 const unsigned long* s1 = (unsigned long*) &(a->exp.l[currRing->pDivHigh]); 449 const unsigned long* s2 = (unsigned long*) &(b->exp.l[currRing->pDivHigh]); 432 450 433 451 for (;;) … … 436 454 // not have their first bit set 437 455 if ((*s2 - *s1) & P_DIV_MASK) return FALSE; 438 #ifdef WORDS_BIGENDIAN439 456 if (s1 == lb) return TRUE; 440 457 s1--; 441 458 s2--; 442 #else 443 s1++; 444 if (s1 == lb) return TRUE; 445 s2++; 446 #endif 447 } 448 } 459 } 460 } 461 #else 462 DECLARE(BOOLEAN, __pDivisibleBy(poly a, poly b)) 463 { 464 int i=pVariables; // assume i>0 465 466 for (;;) 467 { 468 if (_pGetExp(a,i) > _pGetExp(b,i)) 469 return FALSE; 470 i--; 471 if (i==0) 472 return TRUE; 473 } 474 } 475 #endif 449 476 450 477 #if defined(PDEBUG) && PDEBUG == 1 … … 486 513 DECLARE(BOOLEAN, _pEqual(poly p1, poly p2)) 487 514 { 488 const long *s1 = (long*) &(p1->exp [0]);489 const long *s2 = (long*) &(p2->exp [0]);490 const long* const lb = s1 + pVariables1W;515 const long *s1 = (long*) &(p1->exp.l[0]); 516 const long *s2 = (long*) &(p2->exp.l[0]); 517 const long* const lb = s1 + currRing->ExpLSize; 491 518 492 519 for(;;) … … 498 525 } 499 526 } 527 /*************************************************************** 528 * 529 * Misc. things 530 * 531 * 532 ***************************************************************/ 533 // Divisiblity tests based on Short Exponent Vectors 534 #ifdef PDEBUG 535 #define _pShortDivisibleBy(a, sev_a, b, not_sev_b) \ 536 pDBShortDivisibleBy(a, sev_a, b, not_sev_b, __FILE__, __LINE__) 537 BOOLEAN pDBShortDivisibleBy(poly p1, unsigned long sev_1, 538 poly p2, unsigned long not_sev_2, 539 char* f, int l); 540 #else 541 #define _pShortDivisibleBy(a, sev_a, b, not_sev_b) \ 542 ( ! (sev_a & not_sev_b) && pDivisibleBy(a, b)) 543 #endif 544 500 545 501 546 /*************************************************************** … … 506 551 ***************************************************************/ 507 552 553 #ifdef LONG_MONOMS 508 554 DECLARE(int, __pExpQuerSum2(poly p, int from, int to)) 509 555 { 510 int j = p->exp[from];511 int i = from + 1;556 int j = 0; 557 int i = from ; 512 558 513 559 for(;;) 514 560 { 515 if (i > to) return j;516 j += p->exp [i];561 if (i > to) break; 562 j += p->exp.e[i]; 517 563 i++; 518 564 } 519 } 520 521 #define _pExpQuerSum(p) __pExpQuerSum2(p, pVarLowIndex, pVarHighIndex) 522 523 inline int _pExpQuerSum1(poly p, int to) 524 { 525 int ei_to = _pExpIndex(to); 526 int ei_1 = _pExpIndex(1); 527 528 if (ei_1 > ei_to) 529 return __pExpQuerSum2(p, ei_to, ei_1); 530 else 531 return __pExpQuerSum2(p, ei_1, ei_to); 532 } 533 565 if (from <= _pCompIndex && to >= _pCompIndex) 566 return j - _pGetComp(p); 567 return j; 568 } 569 570 #define _pExpQuerSum(p) __pExpQuerSum2(p, currRing->pVarLowIndex, currRing->pVarHighIndex) 534 571 535 572 inline int _pExpQuerSum2(poly p,int from,int to) … … 544 581 } 545 582 583 #else 584 DECLARE(int, _pExpQuerSum(poly p)) 585 { 586 int s = 0; 587 int i = pVariables; 588 for (;;) 589 { 590 s += _pGetExp(p, i); 591 i--; 592 if (i==0) return s; 593 } 594 } 595 #endif 596 546 597 #endif // POLYS_IMPL_H
Note: See TracChangeset
for help on using the changeset viewer.