Changeset ad1c3b in git for kernel/shiftgb.cc
 Timestamp:
 Mar 13, 2008, 8:25:49 PM (15 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
 Children:
 ba49d9f52b36950f74de618b1a41a677fa14fa07
 Parents:
 411ea98eecab97fbeac7f8395433a159d6d03584
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

kernel/shiftgb.cc
r411ea98 rad1c3b 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: shiftgb.cc,v 1. 6 20080224 17:41:32levandov Exp $ */4 /* $Id: shiftgb.cc,v 1.7 20080313 19:25:49 levandov Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for shift GB and free GB … … 41 41 42 42 /* TODO: write p* stuff as instances of p_* for all the functions */ 43 /* p_* functions are new, p* are old */ 43 44 44 45 poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r) … … 52 53 assume(p_CheckIsFromRing(pNext(p),strat>tailRing)); 53 54 54 /* assume sh and uptodeg agree */55 /* assume sh and uptodeg agree TODO check */ 55 56 56 57 if (sh == 0) return(p); /* the zero shift */ … … 74 75 { 75 76 /* assume shift takes place */ 76 /* shifts the poly p by sh */ 77 /* deletes p */ 78 79 /* assume sh and uptodeg agree */ 77 /* shifts the poly p from the ring r by sh */ 78 79 /* assume sh and uptodeg agree TODO check */ 80 80 81 81 if (p==NULL) return(p); … … 83 83 84 84 poly q = NULL; 85 poly pp = p; // pCopy(p);85 poly pp = p; // do not take copies 86 86 while (pp!=NULL) 87 87 { … … 89 89 pIter(pp); 90 90 } 91 /* delete pp? */92 /* int version: returns TRUE if it was successful */93 91 return(q); 94 92 } … … 96 94 poly p_mLPshift(poly p, int sh, int uptodeg, int lV, const ring r) 97 95 { 98 /* p m is a monomial*/96 /* p is a monomial from the ring r */ 99 97 100 98 if (sh == 0) return(p); /* the zero shift */ … … 119 117 int *s=(int *)omAlloc0((r>N+1)*sizeof(int)); 120 118 p_GetExpV(p,e,r); 121 number c = pGetCoeff(p); 119 122 120 int j; 123 121 // for (j=1; j<=r>N; j++) … … 128 126 { 129 127 s[j + (sh*lV)] = e[j]; /* actually 1 */ 128 #ifdef PDEBUG 130 129 omCheckAddr(s); 130 #endif 131 131 } 132 #ifdef PDEBUG 132 133 else 133 134 { 134 135 if (e[j]!=0) 135 136 { 136 #ifdef PDEBUG 137 Print("p_mLPshift: ex[%d]=%d\n",j,e[j]); 138 #endif 137 // Print("p_mLPshift: ex[%d]=%d\n",j,e[j]); 139 138 } 140 139 } 140 #endif 141 141 } 142 142 poly m = p_ISet(1,r); 143 143 p_SetExpV(m,s,r); 144 /* pSetm(m); */ /* done in the pSetExpV */145 /* think on the component */146 pSetCoeff0(m,c);147 144 freeT(e, r>N); 148 145 freeT(s, r>N); 146 /* pSetm(m); */ /* done in the pSetExpV */ 147 /* think on the component and coefficient */ 148 // number c = pGetCoeff(p); 149 // p_SetCoeff0(m,p_GetCoeff(p,r),r); 150 p_SetComp(m,p_GetComp(p,r),r); // component is preserved 151 p_SetCoeff0(m,p_GetCoeff(p,r),r); // coeff is preserved 149 152 return(m); 150 153 } … … 202 205 for (j=1; j<=currRing>N; j++) 203 206 { 204 if (e[j] )207 if (e[j]==1) 205 208 { 206 209 s[j + (sh*lV)] = e[j]; /* actually 1 */ … … 371 374 372 375 /* there should be two routines: */ 373 /* 1. test s squarefreeness: in homog this suffices*/376 /* 1. test placesquarefreeness: in homog this suffices: isInV */ 374 377 /* 2. test the presence of a hole > in the tail??? */ 375 378 376 379 int isInV(poly p, int lV) 377 380 { 378 381 /* investigate only the leading monomial of p in currRing */ 379 382 if (lV <= 0) return(0); 380 383 /* returns 1 iff p is in V */ … … 382 385 /* lV = the length of V = the number of orig vars */ 383 386 int *e = (int *)omAlloc0((currRing>N+1)*sizeof(int)); 384 int b = (int)(currRing>N)/lV; /* the number of blocks */ 387 int b = (int)((currRing>N +lV1)/lV); /* the number of blocks */ 388 //int b = (int)(currRing>N)/lV; 385 389 int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */ 386 390 pGetExpV(p,e); … … 395 399 } 396 400 } 397 j = b;401 // j = b; 398 402 // while ( (!B[j]) && (j>=1)) j; 399 403 for (j=b; j>=1; j) … … 401 405 if (B[j]!=0) break; 402 406 } 403 404 if (j==0) 405 { 406 /* it is a zero exp vector, which is in V */ 407 return(1); 408 } 409 /* now B[j] != 0 */ 407 /* do not need e anymore */ 408 freeT(e, currRing>N); 409 410 if (j==0) goto ret_true; 411 // { 412 // /* it is a zero exp vector, which is in V */ 413 // freeT(B, b); 414 // return(1); 415 // } 416 /* now B[j] != 0 and we test placesquarefreeness */ 410 417 for (j; j>=1; j) 411 418 { 412 419 if (B[j]!=1) 413 420 { 421 freeT(B, b); 414 422 return(0); 415 423 } 416 424 } 425 ret_true: 426 freeT(B, b); 417 427 return(1); 418 428 } … … 421 431 { 422 432 /* for poly in lmCR/tailTR presentation */ 423 /* the below situation might happen! */433 /* the below situation (commented out) might happen! */ 424 434 // if (r == currRing) 425 435 // { … … 439 449 } 440 450 451 poly p_ShrinkT(poly p, int lV, kStrategy strat, const ring r) 452 //poly p_Shrink(poly p, int uptodeg, int lV, kStrategy strat, const ring r) 453 { 454 /* p is like TObject: lm in currRing = r, tail in tailRing */ 455 /* proc shrinks the poly p in ring r */ 456 /* lV = the length of V = the number of orig vars */ 457 /* check assumes/exceptions */ 458 /* r>N is a multiple of lV */ 459 460 if (p==NULL) return(p); 461 462 assume(p_LmCheckIsFromRing(p,r)); 463 assume(p_CheckIsFromRing(pNext(p),strat>tailRing)); 464 465 poly q = NULL; 466 poly s = p_mShrink(p, lV, r); // lm in currRing 467 poly pp = pNext(p); 468 469 while (pp != NULL) 470 { 471 // q = p_Add_q(q, p_mShrink(pp,uptodeg,lV,strat>tailRing),strat>tailRing); 472 q = p_Add_q(q, p_mShrink(pp,lV,strat>tailRing),strat>tailRing); 473 pIter(pp); 474 } 475 pNext(s) = q; 476 return(s); 477 } 478 479 poly p_Shrink(poly p, int lV, const ring r) 480 { 481 /* proc shrinks the poly p in ring r */ 482 /* lV = the length of V = the number of orig vars */ 483 /* check assumes/exceptions */ 484 /* r>N is a multiple of lV */ 485 486 if (p==NULL) return(p); 487 assume(p_CheckIsFromRing(p,r)); 488 poly q = NULL; 489 poly pp = p; 490 491 while (pp != NULL) 492 { 493 q = p_Add_q(q, p_mShrink(pp,lV,r),r); 494 pIter(pp); 495 } 496 return(q); 497 } 498 499 poly p_mShrink(poly p, int lV, const ring r) 500 { 501 /* shrinks the monomial p in ring r */ 502 /* lV = the length of V = the number of orig vars */ 503 504 /* check assumes/exceptions */ 505 /* r>N is a multiple of lV */ 506 507 int *e = (int *)omAlloc0((r>N+1)*sizeof(int)); 508 int b = (int)((r>N +lV1)/lV); /* the number of blocks */ 509 // int *B = (int *)omAlloc0((b+1)*sizeof(int)); /* the num of elements in a block */ 510 int *S = (int *)omAlloc0((r>N+1)*sizeof(int)); /* the shrinked exponent */ 511 p_GetExpV(p,e,r); 512 int i,j; int cnt = 1; //counter for blocks in S 513 for (j=1; j<=b; j++) 514 { 515 /* we go through all the vars */ 516 /* by blocks in lV vars */ 517 for (i=(j1)*lV + 1; i<= j*lV; i++) 518 { 519 if (e[i]==1) 520 { 521 // B[j] = B[j]+1; // for control in V? 522 S[(cnt1)*lV + (i  (j1)*lV)] = e[i]; 523 /* assuming we are in V, can interrupt here */ 524 cnt++; 525 // break; //results in incomplete shrink! 526 i = j*lV; // manual break under assumption p is in V 527 } 528 } 529 } 530 #ifdef PDEBUG 531 // Print("p_mShrink: cnt = [%d], b = %d\n",cnt,b); 532 #endif 533 // cnt 1 <= b must hold! 534 // freeT(B, b); 535 poly s = p_ISet(1,r); 536 p_SetExpV(s,S,r); 537 freeT(e, r>N); 538 freeT(S, r>N); 539 /* p_Setm(s,r); // done by p_SetExpV */ 540 p_SetComp(s,p_GetComp(p,r),r); // component is preserved 541 p_SetCoeff(s,p_GetCoeff(p,r),r); // coeff is preserved 542 #ifdef PDEBUG 543 // Print("p_mShrink: from "); p_wrp(p,r); Print(" to "); p_wrp(s,r); PrintLn(); 544 #endif 545 return(s); 546 } 441 547 442 548 /* shiftgb stuff */
Note: See TracChangeset
for help on using the changeset viewer.