Changeset c5f63ab in git
- Timestamp:
- Mar 18, 1998, 3:28:54 PM (25 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 7f1b912b1613387b9ef8e0f2a053a2c335b9b5da
- Parents:
- e0fb8d31ff69374db7f865baedfda3e614804382
- Location:
- Singular
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ChangeLog
re0fb8d3 rc5f63ab 1 1998-03-18 Olaf Bachmann <obachman@mathematik.uni-kl.de> 2 3 * polys-impl.h: Cleaned up COMP_FAST and related #defines 4 1 5 1998-03-16 Olaf Bachmann <obachman@mathematik.uni-kl.de> 2 6 -
Singular/polys-impl.cc
re0fb8d3 rc5f63ab 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys-impl.cc,v 1. 9 1998-01-27 18:51:20 SingularExp $ */4 /* $Id: polys-impl.cc,v 1.10 1998-03-18 14:28:48 obachman Exp $ */ 5 5 6 6 /*************************************************************** … … 56 56 #ifdef COMP_FAST 57 57 // gets var indicies w.r.t. the ring r 58 void pGetVarIndicies(ring r, 59 int &VarOffset, int &VarCompIndex, 58 void pGetVarIndicies(ring r, int &VarOffset, 60 59 int &VarLowIndex, int &VarHighIndex) 61 60 { … … 78 77 case ringorder_ws: 79 78 case ringorder_unspec: 80 pGetVarIndicies_RevLex(r->N, VarOffset, VarCompIndex, 81 VarLowIndex, VarHighIndex); 79 pGetVarIndicies_RevLex(r->N, VarOffset, VarLowIndex, VarHighIndex); 82 80 break; 83 81 … … 92 90 default: 93 91 #endif 94 pGetVarIndicies_Lex(r->N, VarOffset, VarCompIndex, 95 VarLowIndex, VarHighIndex); 92 pGetVarIndicies_Lex(r->N, VarOffset, VarLowIndex, VarHighIndex); 96 93 #ifdef PDEBUG 97 94 break; … … 104 101 else 105 102 // default var indicies are used 106 pGetVarIndicies(r->N, VarOffset, Var CompIndex, VarLowIndex, VarHighIndex);103 pGetVarIndicies(r->N, VarOffset, VarLowIndex, VarHighIndex); 107 104 } 108 105 -
Singular/polys-impl.h
re0fb8d3 rc5f63ab 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys-impl.h,v 1. 19 1998-03-17 10:59:57obachman Exp $ */6 /* $Id: polys-impl.h,v 1.20 1998-03-18 14:28:49 obachman Exp $ */ 7 7 8 8 /*************************************************************** … … 16 16 * 17 17 ***************************************************************/ 18 #include "tok.h"19 18 #include "structs.h" 20 19 #include "mmemory.h" … … 29 28 typedef EXPONENT_TYPE Exponent_t; 30 29 31 #define VARS (10 0) /*max. number of variables as constant*/30 #define VARS (10) /*max. number of variables as constant*/ 32 31 33 32 typedef Exponent_t monomial[VARS + 1]; … … 42 41 monomial exp; // make sure that exp is aligned 43 42 }; 44 45 43 46 44 /*************************************************************** … … 79 77 // pVarLowIndex = 0, 80 78 // pVarHighIndex = pVariables-1 81 // P_COMP_INDEX= pVariables79 // _pCompIndex = pVariables 82 80 // BIGENDIAN -- rev lex order 83 81 // e_n, ... , e_2, e_1,comp,.. : pVarOffset = pVariables, 84 82 // pVarLowIndex = 0, 85 83 // pVarHighIndex = pVariables-1 86 // P_COMP_INDEX= pVariables84 // _pCompIndex = pVariables 87 85 // LITTLEENDIAN -- rev lex order 88 86 // comp,.., e_1, e_2, ... , e_n : pVarOffset = #(..), 89 87 // pVarLowIndex = 1 + #(..), 90 88 // pVarHighIndex = #(..) + pVariables 91 // P_COMP_INDEX = pVariables89 // _pCompIndex = 0 92 90 // LITTLEENDIAN -- lex order 93 91 // comp,..,e_n, .... , e_2, e_1 : pVarOffset = pVariables + 1 + #(..) 94 92 // pVarLowIndex = 1 + #(..) 95 93 // pVarHighIndex = #(..) + pVariables 96 // P_COMP_INDEX = pVariables94 // _pCompIndex = 0 97 95 // 98 96 // Furthermore, the size of the exponent vector is always a multiple … … 103 101 #ifdef WORDS_BIGENDIAN 104 102 105 #define _pHasReverseExp (pVarOffset != -1) 103 #define _pHasReverseExp (pVarOffset != -1) 104 106 105 #define _pExpIndex(i) \ 107 106 (pVarOffset == -1 ? (i) - 1 : pVarOffset - (i)) … … 109 108 ((r)->VarOffset == -1 ? (i) - 1 : (r)->VarOffset - (i)) 110 109 110 #define _pCompIndex pVariables 111 #define _pRingCompIndex(r) ((r)->N) 112 111 113 #else // ! WORDS_BIGENDIAN 112 114 113 115 #define _pHasReverseExp (pVarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1) 116 114 117 #define _pExpIndex(i) \ 115 118 (pVarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1 ? \ … … 118 121 ((r)->VarOffset > (SIZEOF_LONG / SIZEOF_EXPONENT) - 1 ? \ 119 122 (r)->VarOffset - (i) : (r)->VarOffset + (i)) 123 124 #define _pCompIndex 0 125 #define _pRingCompIndex(r) 0 120 126 121 127 #endif // WORDS_BIGENDIAN … … 133 139 temp = temp / sizeof(long); 134 140 else 135 temp = (temp / sizeof(long)) + 1; // now temp == nvars1W 136 VarHighIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1; 137 VarLowIndex = VarHighIndex - nvars + 1; 138 VarOffset = VarHighIndex + 1; 141 temp = (temp / sizeof(long)) + 1; // temp == pVariables1W 142 temp *= sizeof(long)/sizeof(Exponent_t); 143 VarHighIndex = temp -1; 144 VarLowIndex = temp - nvars; 145 VarOffset = temp; 139 146 #endif // WORDS_BIGENDIAN 140 147 } … … 156 163 temp = temp / sizeof(long); 157 164 else 158 temp = (temp / sizeof(long)) + 1; 159 VarHighIndex = temp * sizeof(long)/sizeof(Exponent_t) - 1; 160 VarLowIndex = VarHighIndex - nvars + 1; 161 VarOffset = VarLowIndex - 1; 165 temp = (temp / sizeof(long)) + 1; // temp == pVariables1W 166 temp *= sizeof(long)/sizeof(Exponent_t); 167 VarHighIndex = temp -1; 168 VarLowIndex = temp - nvars; 169 VarOffset = temp - nvars -1; 162 170 #endif // WORDS_BIGENDIAN 163 171 } 164 #ifdef WORDS_BIGENDIAN165 172 #define pSetVarIndicies_RevLex(nvars) \ 166 pGetVarIndicies_RevLex(nvars,pVarOffset,pCompIndex,pVarLowIndex,pVarHighIndex) 167 #else 168 #define pSetVarIndicies_RevLex(nvars) \ 169 pGetVarIndicies_RevLex(nvars,pVarOffset,pVarLowIndex, pVarLowIndex,pVarHighIndex) 170 #endif 173 pGetVarIndicies_RevLex(nvars,pVarOffset,pVarLowIndex,pVarHighIndex) 171 174 172 175 // The default settings: 173 inline void pGetVarIndicies(int nvars, 174 int &VarOffset, int &VarCompIndex, 176 inline void pGetVarIndicies(int nvars, int &VarOffset, 175 177 int &VarLowIndex, int &VarHighIndex) 176 178 { 177 pGetVarIndicies_Lex(nvars,VarOffset,VarCompIndex,VarLowIndex,VarHighIndex); 178 } 179 179 pGetVarIndicies_Lex(nvars,VarOffset,VarLowIndex,VarHighIndex); 180 } 180 181 // gets var indicies w.r.t. the ring r 181 extern void pGetVarIndicies(ring r, 182 int &VarOffset, int &VarCompIndex, 182 extern void pGetVarIndicies(ring r, int &VarOffset, 183 183 int &VarLowIndex, int &VarHighIndex); 184 184 185 185 #define pSetVarIndicies(nvars) \ 186 pGetVarIndicies(nvars, pVarOffset, pCompIndex, pVarLowIndex, pVarHighIndex) 187 188 189 #else // ! COMP_FAST 190 #define _pExpIndex(i) (i) 191 #define _pRingExpIndex(r,i) (i) 192 #endif // COMP_FAST 193 194 /*************************************************************** 195 * 196 * Primitives for accessing and seeting fields of a poly 186 pGetVarIndicies(nvars, pVarOffset, pVarLowIndex, pVarHighIndex) 187 188 189 /*************************************************************** 190 * 191 * Primitives for accessing and setting fields of a poly 197 192 * 198 193 ***************************************************************/ … … 204 199 #define _pSetCoeff0(p,n) (p)->coef=n 205 200 206 #ifndef TEST_MAC_DEBUG207 201 #define _pGetOrder(p) ((p)->Order) 208 #else209 #define _pGetOrder(p) ((p)->MOrder)210 #endif211 202 212 203 #if defined(PDEBUG) && PDEBUG != 0 … … 259 250 } 260 251 261 #define _pSetComp(p,k) (p)->exp[pCompIndex] = (k) 262 #define _pGetComp(p) (p)->exp[pCompIndex] 263 #define _pIncrComp(p) (p)->exp[pCompIndex]++ 264 #define _pDecrComp(p) (p)->exp[pCompIndex]-- 265 #define _pAddComp(p,v) (p)->exp[pCompIndex] += (v) 266 #define _pSubComp(p,v) (p)->exp[pCompIndex] -= (v) 267 268 #ifdef COMP_FAST 269 #define _pRingSetComp(r,p,k) (p)->exp[(r)->CompIndex] = (k) 270 #define _pRingGetComp(r,p) (p)->exp[(r)->CompIndex] 271 #else 272 #define _pRingSetComp(r,p,k) _pSetComp(p,k) 273 #define _pRingGetComp(r,p) _pGetComp(p) 274 #endif 275 252 #define _pSetComp(p,k) (p)->exp[_pCompIndex] = (k) 253 #define _pGetComp(p) (p)->exp[_pCompIndex] 254 #define _pIncrComp(p) (p)->exp[_pCompIndex]++ 255 #define _pDecrComp(p) (p)->exp[_pCompIndex]-- 256 #define _pAddComp(p,v) (p)->exp[_pCompIndex] += (v) 257 #define _pSubComp(p,v) (p)->exp[_pCompIndex] -= (v) 258 259 #define _pRingSetComp(r,p,k) (p)->exp[_pRingCompIndex(r)] = (k) 260 #define _pRingGetComp(r,p) (p)->exp[_pRingCompIndex(r)] 261 262 inline void _pGetExpV(poly p, Exponent_t *ev) 263 { 264 if (_pHasReverseExp) 265 { 266 for (int i = pVarLowIndex, j = pVariables; j; i++, j--) 267 ev[j] = p->exp[i]; 268 } 269 else 270 memcpy(&ev[1], &(p->exp[pVarLowIndex]), pVariables*sizeof(Exponent_t)); 271 ev[0] = _pGetComp(p); 272 } 273 274 extern pSetmProc pSetm; 275 inline void _pSetExpV(poly p, Exponent_t *ev) 276 { 277 if (_pHasReverseExp) 278 { 279 for (int i = pVarLowIndex, j = pVariables; j; i++, j--) 280 p->exp[i] = ev[j]; 281 } 282 else 283 memcpy(&(p->exp[pVarLowIndex]), &ev[1], pVariables*sizeof(Exponent_t)); 284 _pSetComp(p, ev[0]); 285 pSetm(p); 286 } 276 287 277 288 /*************************************************************** … … 316 327 #define _pHead(A) pDBHead(A,__FILE__,__LINE__) 317 328 #define _pHead0(A) pDBHead0(A, __FILE__,__LINE__) 318 #ifdef COMP_FAST319 329 #define _pFetchCopy(r,A) pDBFetchCopy(r, A,__FILE__,__LINE__) 320 #else321 #define _pFetchCopy(r,p) pOrdPolyInsertSetm(pCopy(p))322 #endif323 330 324 331 #else // ! PDEBUG … … 328 335 #else 329 336 #define _pNew() (poly) mmAllocSpecialized() 330 // #define _pNew() _pInit()331 337 #endif 332 338 333 339 #include <string.h> 334 335 340 inline poly _pInit(void) 336 341 { … … 356 361 extern poly _pHead(poly a); 357 362 extern poly _pHead0(poly a); 358 #ifdef COMP_FAST359 363 extern poly _pFetchCopy(ring r,poly a); 360 #else361 #define _pFetchCopy(r,p) pOrdPolyInsertSetm(pCopy(p))362 #endif363 364 364 #endif // PDEBUG 365 365 366 366 #define _pCopy2(p1, p2) memcpyW(p1, p2, pMonomSizeW) 367 367 368 /*************************************************************** 369 * 370 * Routines which work on vectors instead of single exponents 371 * 372 ***************************************************************/ 368 373 // Here is a handy Macro which disables inlining when run with 369 374 // profiling and enables it otherwise 370 375 371 #ifdef DO_ PROFILE376 #ifdef DO_DEEP_PROFILE 372 377 373 378 #ifndef POLYS_IMPL_CC 379 374 380 #define DECLARE(type, arglist) type arglist; \ 375 381 static type dummy_##arglist … … 378 384 #endif // POLYS_IMPL_CC 379 385 380 #else //! DO_ PROFILE386 #else //! DO_DEEP_PROFILE 381 387 382 388 #define DECLARE(type, arglist ) inline type arglist 383 389 384 #endif // DO_PROFILE 385 386 387 /*************************************************************** 388 * 389 * Routines which work on vectors instead of single exponents 390 * 391 ***************************************************************/ 392 393 #ifdef COMP_FAST 394 395 // nice declaration isn't it ?? 390 #endif // DO_DEEP_PROFILE 391 392 396 393 #if defined(PDEBUG) && PDEBUG == 1 397 #define pMonAddFast(p1, p2) pDBMonAddFast(p1, p2, __FILE__, __LINE__)394 #define _pMonAddFast(p1, p2) pDBMonAddFast(p1, p2, __FILE__, __LINE__) 398 395 extern void pDBMonAddFast(poly p1, poly p2, char* f, int l); 399 inline void _ pMonAddFast(poly p1, poly p2)400 #else 401 DECLARE(void, pMonAddFast(poly p1, poly p2))396 inline void __pMonAddFast(poly p1, poly p2) 397 #else 398 DECLARE(void, _pMonAddFast(poly p1, poly p2)) 402 399 #endif // defined(PDEBUG) && PDEBUG == 1 403 400 { … … 406 403 // positive and the sum of two exponents does not exceed 407 404 // EXPONENT_MAX 408 #ifndef COMP_NO_EXP_VECTOR_OPS409 405 Exponent_t c2 = _pGetComp(p2); 410 406 int i = pVariables1W; … … 413 409 // set comp of p2 temporarily to 0, so that nothing is added to comp of p1 414 410 _pSetComp(p2, 0); 415 #else416 int i = pVariables;417 Exponent_pt s1 = &(p1->exp[pVarLowIndex]);418 Exponent_pt s2 = &(p2->exp[pVarLowIndex]);419 #endif420 411 421 412 for (;;) … … 427 418 s2++; 428 419 } 429 #ifndef COMP_NO_EXP_VECTOR_OPS430 420 // reset comp of p2 431 421 _pSetComp(p2, c2); 432 #endif433 #ifdef TEST_MAC_ORDER434 if (bNoAdd) bSetm(p1);else435 #endif436 422 _pGetOrder(p1) += _pGetOrder(p2); 437 423 } … … 446 432 #endif // defined(PDEBUG) && PDEBUG == 1 447 433 { 448 p1->next = p2->next;449 p1->coef = p2->coef;450 // memset(p1, 0, pMonomSize);451 452 //memset(p1,0,pMonomSize);453 #ifndef COMP_NO_EXP_VECTOR_OPS454 434 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 455 435 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 456 436 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]); 457 437 const unsigned long* const ub = s3 + pVariables1W; 458 #else 459 Exponent_t* s1 = (Exponent_t*) &(p1->exp[pVarLowIndex]); 460 const Exponent_t* s2 = (Exponent_t*) &(p2->exp[pVarLowIndex]); 461 const Exponent_t* s3 = (Exponent_t*) &(p3->exp[pVarLowIndex]); 462 const Exponent_t* const ub = s3 + pVariables; 463 // need to zero the "fill in" slots (i.e., empty exponents) 464 #ifdef WORDS_BIGENDIAN 465 *((unsigned long *) ((unsigned long*) p1) + pMonomSizeW -1) = 0; 466 #else 467 *((unsigned long *) p1->exp) = 0; 468 #endif 469 #endif 438 439 p1->next = p2->next; 440 p1->coef = p2->coef; 470 441 471 442 for (;;) … … 480 451 // component of p1 is set to comp of p2 481 452 _pSetComp(p1, _pGetComp(p2)); 482 #ifdef TEST_MAC_ORDER483 if (bNoAdd) bSetm(p1);else484 #endif485 453 _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3); 486 454 } 487 455 488 // Similar to pCopyAddFast, except that we assume that the component 489 // of p2 and p3 is zero component 456 // Similar to pCopyAddFast, except that we do not care about the "next" field 490 457 #if defined(PDEBUG) && PDEBUG == 1 491 #define _pCopyAddFast 1(p1, p2, p3) pDBCopyAddFast(p1, p2, p3, __FILE__, __LINE__)458 #define _pCopyAddFast0(p1, p2, p3) pDBCopyAddFast(p1, p2, p3, __FILE__, __LINE__) 492 459 extern void pDBCopyAddFast(poly p1, poly p2, poly p3, char* f, int l); 493 inline void __pCopyAddFast 1(poly p1, poly p2, poly p3)494 #else 495 DECLARE(void, _pCopyAddFast 1(poly p1, poly p2, poly p3))460 inline void __pCopyAddFast0(poly p1, poly p2, poly p3) 461 #else 462 DECLARE(void, _pCopyAddFast0(poly p1, poly p2, poly p3)) 496 463 #endif // defined(PDEBUG) && PDEBUG == 1 497 464 { 498 #ifndef COMP_NO_EXP_VECTOR_OPS499 465 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 500 466 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 501 467 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]); 502 468 const unsigned long* const ub = s3 + pVariables1W; 503 #else 504 Exponent_t* s1 = (Exponent_t*) &(p1->exp[pVarLowIndex]); 505 const Exponent_t* s2 = (Exponent_t*) &(p2->exp[pVarLowIndex]); 506 const Exponent_t* s3 = (Exponent_t*) &(p3->exp[pVarLowIndex]); 507 const Exponent_t* const ub = s3 + pVariables; 508 #ifdef WORDS_BIGENDIAN 509 *((unsigned long *) ((unsigned long*) p1) + pMonomSizeW -1) = 0; 510 #else 511 *((unsigned long *) p1->exp) = 0; 512 #endif 513 #endif 469 470 p1->coef = p2->coef; 514 471 515 472 for (;;) … … 521 478 s2++; 522 479 } 523 #ifdef TEST_MAC_ORDER 524 if (bNoAdd) bSetm(p1);else 525 #endif 480 _pSetComp(p1, _pGetComp(p2)); 526 481 _pGetOrder(p1) = _pGetOrder(p2) + _pGetOrder(p3); 527 482 } 528 529 530 #ifndef COMP_NO_EXP_VECTOR_OPS531 483 532 484 #if SIZEOF_LONG == 4 … … 579 531 } 580 532 581 #else // ! COMP_NO_EXP_VECTOR_OPS582 583 DECLARE(BOOLEAN, __pDivisibleBy(poly a, poly b))584 {585 #ifdef WORDS_BIGENDIAN586 const Exponent_t* s1 = &(a->exp[pVarHighIndex]);587 const Exponent_t* s2 = &(b->exp[pVarHighIndex]);588 const Exponent_t* lb = s1 - pVariables;589 590 for (;;)591 {592 if (*s1 > *s2) return FALSE;593 s1--;594 if (s1 == lb) return TRUE;595 s2--;596 }597 598 #else // !WORDS_BIGENDIAN599 const Exponent_t* s1 = &(a->exp[pVarLowIndex]);600 const Exponent_t* s2 = &(b->exp[pVarLowIndex]);601 const Exponent_t* lb = s1 + pVariables;602 603 for (;;)604 {605 if (*s1 > *s2) return FALSE;606 s1++;607 if (s1 == lb) return TRUE;608 s2++;609 }610 #endif // WORDS_BIGENDIAN611 }612 613 #endif // COMP_NO_EXP_VECTOR_OPS614 615 533 #if defined(PDEBUG) && PDEBUG == 1 616 534 #define _pDivisibleBy(a,b) pDBDivisibleBy(a, b, __FILE__, __LINE__) … … 651 569 DECLARE(BOOLEAN, _pEqual(poly p1, poly p2)) 652 570 { 653 #ifndef COMP_NO_EXP_VECTOR_OPS654 571 const long *s1 = (long*) &(p1->exp[0]); 655 572 const long *s2 = (long*) &(p2->exp[0]); 656 573 const long* const lb = s1 + pVariables1W; 657 #else658 const Exponent_t *s1 = (Exponent_t*) &(p1->exp[pVarLowIndex]);659 const Exponent_t *s2 = (Exponent_t*) &(p2->exp[pVarLowIndex]);660 const Exponent_t* const lb = s1 + pVariables;661 if (_pGetComp(p1) != _pGetComp(p2)) return FALSE;662 #endif663 574 664 575 for(;;) … … 671 582 } 672 583 673 inline void _pGetExpV(poly p, Exponent_t *ev) 674 { 675 if (_pHasReverseExp) 676 { 677 for (int i = pVarLowIndex, j = pVariables; j; i++, j--) 678 ev[j] = p->exp[i]; 679 } 680 else 681 memcpy(&ev[1], &(p->exp[pVarLowIndex]), pVariables*sizeof(Exponent_t)); 682 ev[0] = _pGetComp(p); 683 } 684 685 extern pSetmProc pSetm; 686 inline void _pSetExpV(poly p, Exponent_t *ev) 687 { 688 if (_pHasReverseExp) 689 { 690 for (int i = pVarLowIndex, j = pVariables; j; i++, j--) 691 p->exp[i] = ev[j]; 692 } 693 else 694 memcpy(&(p->exp[pVarLowIndex]), &ev[1], pVariables*sizeof(Exponent_t)); 695 _pSetComp(p, ev[0]); 696 pSetm(p); 697 } 698 699 #else // ! COMP_FAST 700 701 DECLARE(BOOLEAN, _pDivisibleBy(poly a, poly b)) 702 { 703 if ((a!=NULL)&&((a->exp[0]==0) || (a->exp[0] == b->exp[0]))) 704 { 705 int i=pVariables; 706 short *e1=&(a->exp[1]); 707 short *e2=&(b->exp[1]); 708 if ((*e1) > (*e2)) return FALSE; 709 do 710 { 711 i--; 712 if (i == 0) return TRUE; 713 e1++; 714 e2++; 715 } while ((*e1) <= (*e2)); 716 } 717 return FALSE; 718 } 719 720 #define _pDivisibleBy1(a,b) _pDivisibleBy(a,b) 721 #define _pDivisibleBy2(a,b) _pDivisibleBy(a,b) 722 723 #ifdef TEST_MAC_ORDER 724 DECLARE(void, pMonAddFast(poly a, poly m)) 725 { 726 for(int ii =pVariables; ii; ii--) (a)->exp[ii] += (m)->exp[ii];\ 727 if (bNoAdd) bSetm(a); else 728 _pGetOrder(a) += _pGetOrder(m); 729 } 730 #else 731 DECLARE(void, pMonAddFast(poly a, poly m)) 732 { 733 for(int ii =pVariables; ii; ii--) (a)->exp[ii] += (m)->exp[ii];\ 734 _pGetOrder(a) += _pGetOrder(m); 735 } 736 #endif 737 738 DECLARE(BOOLEAN, _pEqual(poly p1, poly p2)) 739 { 740 int i; 741 short *e1=p1->exp; 742 short *e2=p2->exp; 743 744 if (p1->Order != p2->Order) return FALSE; 745 for (i=pVariables; i>=0; i--,e1++,e2++) 746 if (*e1 != *e2) return FALSE; 747 return TRUE; 748 } 749 750 #define _pGetExpV(p,e) memcpy((e),(p)->exp,(pVariables+1)*sizeof(short)); 751 //void pSetExpV(poly p, short * exp); 752 #define _pSetExpV(p,e) {memcpy((p)->exp,(e),(pVariables+1)*sizeof(short));pSetm(p);} 753 754 #endif // COMP_FAST 755 756 /*************************************************************** 757 * 758 * Routines which implement low-level manipulations/operations on exponents 584 /*************************************************************** 585 * 586 * Routines which implement low-level manipulations/operations 587 * on exponents and "are allowed" to access single exponetns 759 588 * 760 589 ***************************************************************/ … … 773 602 } 774 603 775 #ifdef COMP_FAST776 604 #define _pExpQuerSum(p) __pExpQuerSum2(p, pVarLowIndex, pVarHighIndex) 777 605 778 #define _pExpQuerSum1(p,to) \779 (_pHasReverseExp ? \780 __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(1)) : \606 #define _pExpQuerSum1(p,to) \ 607 (_pHasReverseExp ? \ 608 __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(1)) : \ 781 609 __pExpQuerSum2(p, _pExpIndex(1), _pExpIndex(to))) 782 610 783 #define _pExpQuerSum2(p,from,to) \784 (_pHasReverseExp ? \785 __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(from)) : \611 #define _pExpQuerSum2(p,from,to) \ 612 (_pHasReverseExp ? \ 613 __pExpQuerSum2(p, _pExpIndex(to), _pExpIndex(from)) : \ 786 614 __pExpQuerSum2(p, _pExpIndex(from), _pExpIndex(to))) 787 #else 788 789 #define _pExpQuerSum(p) __pExpQuerSum2(p, 1, pVariables) 790 #define _pExpQuerSum1(p, to) __pExpQuerSum2(p, 1, to) 791 #define _pExpQuerSum2(p, from, to) __pExpQuerSum2(p, from, to) 792 793 #endif 794 795 /*************************************************************** 796 * 797 * Routines which implement macaulay ordering routines 798 * 799 ***************************************************************/ 800 #ifdef TEST_MAC_ORDER 801 802 DECLARE(void, _bSetm0(poly p)) 803 { 804 805 int i=1; 806 int ord = -INT_MAX; 807 Exponent_t *ep; 808 809 #ifdef COMP_FAST 810 if(_pHasReverseExp) 811 { 812 ep=&(p->exp[pVarHighIndex]); 813 int *ip=bBinomials+(*ep); /*_pGetExp(p,1);*/ 814 loop 815 { 816 ord += (*ip); 817 if (i==pVariables) break; 818 i++; 819 //ip+=bHighdeg_1+_pGetExp(p,i); 820 ep--; 821 ip+=bHighdeg_1+(*ep); 822 } 823 } 824 else 825 { 826 ep=&(p->exp[pVarLowIndex]); 827 int *ip=bBinomials+(*ep); /*_pGetExp(p,1);*/ 828 loop 829 { 830 ord += (*ip); 831 if (i==pVariables) break; 832 i++; 833 //ip+=bHighdeg_1+_pGetExp(p,i); 834 ep++; 835 ip+=bHighdeg_1+(*ep); 836 } 837 } 838 #ifdef TEST_MAC_DEBUG 839 p->Order=_pExpQuerSum(p); 840 p->MOrder=ord; 841 #else 842 p->Order=ord; 843 #endif 844 #else 845 int *ip=bBinomials+_pGetExp(p,1); 846 loop 847 { 848 ord += (*ip); 849 if (i==pVariables) break; 850 i++; 851 ip+=bHighdeg_1+_pGetExp(p,i); 852 } 853 #ifdef TEST_MAC_DEBUG 854 p->Order=pTotaldegree(p); 855 p->MOrder=ord; 856 #else 857 p->Order=ord; 858 #endif 859 #endif 860 } 861 862 DECLARE(void, _bSetm(poly p)) 863 { 864 int ord = _pExpQuerSum(p); 865 866 if (ord<bHighdeg) 867 _bSetm0(p); 868 else 869 { 870 #ifdef TEST_MAC_DEBUG 871 p->MOrder=ord; 872 #endif 873 p->Order=ord; 874 } 875 } 876 877 #ifdef COMP_FAST 878 // ordering dp,c or c,dp, general case 879 #if defined(PDEBUG) && PDEBUG == 1 880 #define pbMonAddFast(p1, p2) pDBMonAddFast(p1, p2, __FILE__, __LINE__) 881 extern void pbDBMonAddFast(poly p1, poly p2, char* f, int l); 882 inline void _pbMonAddFast(poly p1, poly p2) 883 #else 884 #define pbMonAddFast(p1, p2) _pbMonAddFast(p1, p2) 885 DECLARE(void, _pbMonAddFast(poly p1, poly p2)) 886 #endif // defined(PDEBUG) && PDEBUG == 1 887 { 888 // OK -- this might be the only place where we are kind of quick and 889 // dirty: the following only works correctly if all exponents are 890 // positive and the sum of two exponents does not exceed 891 // EXPONENT_MAX 892 #ifndef COMP_NO_EXP_VECTOR_OPS 893 Exponent_t c2 = _pGetComp(p2); 894 int i = pVariables1W; 895 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 896 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 897 // set comp of p2 temporarily to 0, so that nothing is added to comp of p1 898 _pSetComp(p2, 0); 899 #else 900 int i = pVariables; 901 Exponent_pt s1 = &(p1->exp[pVarLowIndex]); 902 Exponent_pt s2 = &(p2->exp[pVarLowIndex]); 903 #endif 904 905 for (;;) 906 { 907 *s1 += *s2; 908 i--; 909 if (i==0) break; 910 s1++; 911 s2++; 912 } 913 #ifndef COMP_NO_EXP_VECTOR_OPS 914 // reset comp of p2 915 _pSetComp(p2, c2); 916 #endif 917 if ((_pGetOrder(p1)|_pGetOrder(p2))>0) // i.e. overflow of mac order 918 _pGetOrder(p1) += _pGetOrder(p2); 919 else 920 _bSetm(p1); 921 } 922 923 // ordering dp,c or c,dp, below degree limit 924 #if defined(PDEBUG) && PDEBUG == 1 925 #define pbMonAddFast0(p1, p2) pbDBMonAddFast0(p1, p2, __FILE__, __LINE__) 926 extern void pbDBMonAddFast0(poly p1, poly p2, char* f, int l); 927 inline void _pbMonAddFast0(poly p1, poly p2) 928 #else 929 DECLARE(void, pbMonAddFast0(poly p1, poly p2)) 930 #endif // defined(PDEBUG) && PDEBUG == 1 931 { 932 // OK -- this might be the only place where we are kind of quick and 933 // dirty: the following only works correctly if all exponents are 934 // positive and the sum of two exponents does not exceed 935 // EXPONENT_MAX 936 #ifndef COMP_NO_EXP_VECTOR_OPS 937 Exponent_t c2 = _pGetComp(p2); 938 int i = pVariables1W; 939 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 940 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 941 // set comp of p2 temporarily to 0, so that nothing is added to comp of p1 942 _pSetComp(p2, 0); 943 #else 944 int i = pVariables; 945 Exponent_pt s1 = &(p1->exp[pVarLowIndex]); 946 Exponent_pt s2 = &(p2->exp[pVarLowIndex]); 947 #endif 948 949 for (;;) 950 { 951 *s1 += *s2; 952 i--; 953 if (i==0) break; 954 s1++; 955 s2++; 956 } 957 #ifndef COMP_NO_EXP_VECTOR_OPS 958 // reset comp of p2 959 _pSetComp(p2, c2); 960 #endif 961 _bSetm0(p1); 962 } 963 964 // ordering dp,c or c,dp, below degree limit 965 // Makes p1 a copy of p2 and adds on exponets of p3 966 #if defined(PDEBUG) && PDEBUG == 1 967 #define _pbCopyAddFast0(p1, p2, p3) pDBCopyAddFast(p1, p2, p3, __FILE__, __LINE__) 968 inline void __pbCopyAddFast0(poly p1, poly p2, poly p3) 969 #else 970 DECLARE(void, _pbCopyAddFast0(poly p1, poly p2, poly p3)) 971 #endif // defined(PDEBUG) && PDEBUG == 1 972 { 973 p1->next = p2->next; 974 p1->coef = p2->coef; 975 976 #ifndef COMP_NO_EXP_VECTOR_OPS 977 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 978 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 979 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]); 980 const unsigned long* const ub = s3 + pVariables1W; 981 #else 982 Exponent_t* s1 = (Exponent_t*) &(p1->exp[pVarLowIndex]); 983 const Exponent_t* s2 = (Exponent_t*) &(p2->exp[pVarLowIndex]); 984 const Exponent_t* s3 = (Exponent_t*) &(p3->exp[pVarLowIndex]); 985 const Exponent_t* const ub = s3 + pVariables; 986 // need to zero the "fill in" slots (i.e., empty exponents) 987 #ifdef WORDS_BIGENDIAN 988 *((unsigned long*) p1 + pMonomSizeW -1) = 0; 989 #else 990 *((unsigned long *) p1->exp) = 0; 991 #endif 992 #endif 993 994 for (;;) 995 { 996 *s1 = *s2 + *s3; 997 s3++; 998 if (s3 == ub) break; 999 s1++; 1000 s2++; 1001 } 1002 // we first are supposed to do a copy from p2 to p1 -- therefore, 1003 // component of p1 is set to comp of p2 1004 _pSetComp(p1, _pGetComp(p2)); 1005 _bSetm0(p1); 1006 } 1007 1008 // Similar to pCopyAddFast, except that we assume that the component 1009 // of p2 and p3 is zero component 1010 #if defined(PDEBUG) && PDEBUG == 1 1011 #define _pbCopyAddFast10(p1, p2, p3) pbDBCopyAddFast0(p1, p2, p3, __FILE__, __LINE__) 1012 extern void pbDBCopyAddFast0(poly p1, poly p2, poly p3, char* f, int l); 1013 inline void __pbCopyAddFast10(poly p1, poly p2, poly p3) 1014 #else 1015 DECLARE(void, _pbCopyAddFast10(poly p1, poly p2, poly p3)) 1016 #endif // defined(PDEBUG) && PDEBUG == 1 1017 { 1018 p1->next = p2->next; 1019 p1->coef = p2->coef; 1020 1021 #ifndef COMP_NO_EXP_VECTOR_OPS 1022 unsigned long* s1 = (unsigned long*) &(p1->exp[0]); 1023 const unsigned long* s2 = (unsigned long*) &(p2->exp[0]); 1024 const unsigned long* s3 = (unsigned long*) &(p3->exp[0]); 1025 const unsigned long* const ub = s3 + pVariables1W; 1026 #else 1027 Exponent_t* s1 = (Exponent_t*) &(p1->exp[pVarLowIndex]); 1028 const Exponent_t* s2 = (Exponent_t*) &(p2->exp[pVarLowIndex]); 1029 const Exponent_t* s3 = (Exponent_t*) &(p3->exp[pVarLowIndex]); 1030 const Exponent_t* const ub = s3 + pVariables; 1031 #ifdef WORDS_BIGENDIAN 1032 *((unsigned long*) p1 + pMonomSizeW -1) = 0; 1033 #else 1034 *((unsigned long *) p1->exp) = 0; 1035 #endif 1036 #endif 1037 1038 for (;;) 1039 { 1040 *s1 = *s2 + *s3; 1041 s3++; 1042 if (s3 == ub) break; 1043 s1++; 1044 s2++; 1045 } 1046 _bSetm0(p1); 1047 } 1048 1049 #endif 1050 #endif 1051 615 616 #define COMP_FAST 1052 617 #endif // POLYS_IMPL_H 1053 -
Singular/polys.cc
re0fb8d3 rc5f63ab 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: polys.cc,v 1.1 6 1998-03-16 14:56:39obachman Exp $ */4 /* $Id: polys.cc,v 1.17 1998-03-18 14:28:50 obachman Exp $ */ 5 5 6 6 /* … … 415 415 #ifdef COMP_TRADITIONAL 416 416 417 pCompProc t_pComp0;418 419 417 static int t_comp_otCOMPEXP_nwONE(poly p1, poly p2); 420 418 static int t_comp_otEXPCOMP_nwONE(poly p1, poly p2); … … 999 997 for (i=indexShift;i<maxSchreyer;i++) 1000 998 SchreyerOrd[i] = pGetComp(nextOrder[i-indexShift]); 1001 #ifdef COMP_DEBUG1002 pCompOld = t_pComp0;1003 #else1004 999 pCompOld = pComp0; 1005 #endif1006 1000 pComp0 = mcompSchrM; 1007 t_pComp0 = mcompSchrM;1008 1001 pLDegOld = pLDeg; 1009 1002 pLDeg = ldegSchrM; … … 1017 1010 maxSchreyer = 0; 1018 1011 indexShift = 0; 1019 #ifdef COMP_DEBUG1020 pComp0 = debug_comp;1021 #else1022 1012 pComp0 = pCompOld; 1023 #endif1024 t_pComp0 = pCompOld;1025 1013 pLDeg = pLDegOld; 1026 1014 } … … 1052 1040 if (maxBound==0) 1053 1041 { 1054 #ifdef COMP_DEBUG1055 pCompOld = t_pComp0;1056 pComp0 = mcompSyz;1057 t_pComp0 = mcompSyz;1058 #else1059 1042 pCompOld = pComp0; 1060 1043 pComp0 = mcompSyz; 1061 t_pComp0 = mcompSyz;1062 #endif1063 1044 } 1064 1045 maxBound = k; … … 1068 1049 if (maxBound!=0) 1069 1050 { 1070 #ifdef COMP_DEBUG1071 pComp0 = debug_comp;1072 #else1073 1051 pComp0 = pCompOld; 1074 #endif1075 t_pComp0 = pCompOld;1076 1052 maxBound = 0; 1077 1053 } … … 1294 1270 #endif 1295 1271 { 1296 #ifdef COMP_TRADITIONAL1297 if (pVariables <= 1)1298 {1299 t_pComp0 = t_comp_otEXPCOMP_nwONE;1300 }1301 else1302 {1303 switch(o_r)1304 {1305 case ringorder_lp:1306 case ringorder_Dp:1307 case ringorder_Wp:1308 case ringorder_Ds:1309 case ringorder_Ws:1310 case ringorder_ls:1311 t_pComp0 = t_comp_otEXPCOMP_lex_i;1312 pLexSgn = 1;1313 break;1314 1315 #ifdef PDEBUG1316 case ringorder_unspec:1317 case ringorder_dp:1318 case ringorder_wp:1319 case ringorder_ds:1320 case ringorder_ws:1321 #else1322 default:1323 #endif1324 t_pComp0 = t_comp_otEXPCOMP_revlex_i;1325 pLexSgn = -1;1326 break;1327 #ifdef PDEBUG1328 default:1329 Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);1330 #endif1331 }1332 }1333 if (o_r == ringorder_lp || o_r == ringorder_ls)1334 {1335 pLexOrder=TRUE;1336 pFDeg = pTotaldegree;1337 pLDeg = ldeg1c;1338 if (o_r == ringorder_ls) pLexSgn = -1;1339 }1340 1341 *p = t_pComp0;1342 #endif1343 1272 #ifdef COMP_FAST 1344 1273 switch(o_r) … … 1427 1356 #endif // COMP_FAST 1428 1357 1429 #ifdef COMP_DEBUG1430 *p = debug_comp;1431 #endif1432 1358 } 1433 1359 … … 1485 1411 #endif 1486 1412 { 1487 #ifdef COMP_TRADITIONAL1488 if (pVariables <= 1)1489 {1490 t_pComp0 = t_comp_otCOMPEXP_nwONE;1491 }1492 else1493 {1494 switch(o_r)1495 {1496 case ringorder_lp:1497 case ringorder_Dp:1498 case ringorder_Wp:1499 case ringorder_Ds:1500 case ringorder_Ws:1501 case ringorder_ls:1502 t_pComp0 = t_comp_lex_otCOMPEXP_i;1503 pLexSgn = 1;1504 break;1505 1506 #ifdef PDEBUG1507 case ringorder_unspec:1508 case ringorder_dp:1509 case ringorder_wp:1510 case ringorder_ds:1511 case ringorder_ws:1512 #else1513 default:1514 #endif1515 t_pComp0 = t_comp_revlex_otCOMPEXP_i;1516 pLexSgn = -1;1517 break;1518 #ifdef PDEBUG1519 default:1520 Werror("wrong internal ordering:%d at %s, l:%d\n",o_r,__FILE__,__LINE__);1521 #endif1522 }1523 }1524 if (o_r == ringorder_lp || o_r == ringorder_ls)1525 {1526 pLexOrder=TRUE;1527 pFDeg = pTotaldegree;1528 pLDeg = ldeg1c;1529 if (o_r == ringorder_ls) pLexSgn = -1;1530 }1531 1532 *p = t_pComp0;1533 #endif1534 1413 #ifdef COMP_FAST 1535 1414 switch(o_r) … … 1950 1829 pAltVars=r->N+1; 1951 1830 #endif 1952 t_pComp0 = NULL;1953 1831 #ifdef COMP_FAST 1954 1832 f_pComp0 = NULL; … … 2077 1955 test &= ~Sy_bit(OPT_REDTAIL); /* noredTail */ 2078 1956 } 2079 #ifdef COMP_TRADITIONAL2080 if (t_pComp0 == NULL)2081 t_pComp0 = pComp0;2082 #endif2083 1957 2084 1958 #ifdef COMP_FAST … … 3124 2998 } 3125 2999 3126 #ifdef COMP_DEBUG3127 static int debug_comp(poly p1, poly p2)3128 {3129 int t_d = t_pComp0(p1, p2);3130 int f_d = f_pComp0(p1, p2);3131 3132 if (t_d != f_d)3133 {3134 fprintf(stderr, "Error in comp1lpc\n");3135 t_pComp0(p1, p2);3136 f_pComp0(p1, p2);3137 }3138 return t_d;3139 }3140 #endif3141 3000 3142 3001 #ifdef COMP_STATISTICS -
Singular/polys.h
re0fb8d3 rc5f63ab 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys.h,v 1. 9 1998-01-17 18:08:00 SingularExp $ */6 /* $Id: polys.h,v 1.10 1998-03-18 14:28:52 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT - all basic methods to manipulate polynomials … … 186 186 187 187 188 // Adds exponents of p2 to exponents of p1; updates Order field 189 // assumes that exponents > 0 and < MAX_EXPONENT / 2 190 #define pMonAddFast(p1, p2) _pMonAddFast(p1, p2) 188 191 // Is equivalent to pCopy2(p1, p2);pMonAddFast(p1, p3); 189 192 #define pCopyAddFast(p1, p2, p3) _pCopyAddFast(p1, p2, p3) 190 #define pbCopyAddFast(p1, p2, p3) _pbCopyAddFast(p1, p2, p3) 191 #define pbCopyAddFast0(p1, p2, p3) _pbCopyAddFast0(p1, p2, p3) 192 // Similar to pCopyAddFast, except that components of p2, and p3 must be 0 193 #define pCopyAddFast1(p1, p2, p3) _pCopyAddFast1(p1, p2, p3) 193 // Similar to pCopyAddFast, except that we do not care about the next field 194 #define pCopyAddFast0(p1, p2, p3) _pCopyAddFast0(p1, p2, p3) 194 195 195 196 poly pmInit(char *s, BOOLEAN &ok); /* monom -> poly */ … … 209 210 #define pEqual(p1, p2) _pEqual(p1, p2) 210 211 211 // returns TRUE, if leading monom of a is dividble be leading monom of b 212 #if defined(macintosh) || defined(DIV_COUNT) 212 // returns TRUE, if leading monom of a divides leading monom of b 213 // i.e., if there exists a expvector c > 0, s.t. b = a + c 214 #if defined(macintosh) 213 215 BOOLEAN pDivisibleBy(poly a, poly b); 214 216 #else … … 217 219 // like pDivisibleBy, except that it is assumed that a!=NULL 218 220 #define pDivisibleBy1(a,b) _pDivisibleBy1(a,b) 219 // returns TRUE, if leading monom of a is dividble be leading monom of b 220 // assumes a != NULL, b != NULL, and does not check components 221 // like pDivisibleBy, assumes a != NULL, does not check components 221 222 #define pDivisibleBy2(a, b) _pDivisibleBy2(a,b) 222 223 -
Singular/ring.cc
re0fb8d3 rc5f63ab 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: ring.cc,v 1.1 6 1998-03-16 14:56:40obachman Exp $ */4 /* $Id: ring.cc,v 1.17 1998-03-18 14:28:52 obachman Exp $ */ 5 5 6 6 /* … … 665 665 #ifdef COMP_FAST 666 666 // set those fields of the ring, which can be computed from other fields: 667 // More particularly, set: 668 // r->VarOffset, r->CompIndex 667 // More particularly, sets r->VarOffset 669 668 670 669 void rComplete(ring r) 671 670 { 672 int dummy, VarOffset , CompIndex;673 pGetVarIndicies(r, VarOffset, CompIndex,dummy, dummy);671 int dummy, VarOffset; 672 pGetVarIndicies(r, VarOffset, dummy, dummy); 674 673 r->VarOffset = (short) VarOffset; 675 r->CompIndex = (short) CompIndex;676 674 } 677 675 #endif -
Singular/spolys.cc
re0fb8d3 rc5f63ab 614 614 pSetm(m1); 615 615 pSetm(m2); 616 cm = t_pComp0(m1, m2);616 cm = pComp0(m1, m2); 617 617 if (cm!=0) 618 618 { -
Singular/spolys0.cc
re0fb8d3 rc5f63ab 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: spolys0.cc,v 1. 9 1998-03-16 14:56:46obachman Exp $ */4 /* $Id: spolys0.cc,v 1.10 1998-03-18 14:28:54 obachman Exp $ */ 5 5 6 6 /* … … 797 797 pSetm(m1); 798 798 pSetm(m2); 799 cm = t_pComp0(m1, m2);799 cm = pComp0(m1, m2); 800 800 if (cm!=0) 801 801 {
Note: See TracChangeset
for help on using the changeset viewer.