Changeset 416465 in git for Singular/syz.cc
- Timestamp:
- Nov 15, 1999, 6:20:58 PM (25 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- 721650e849298f036e56d58feb3f554f1bd4d84b
- Parents:
- 57e94c4a2330bb253fb2189a2502d15dabe880e9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/syz.cc
r57e94c4 r416465 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: syz.cc,v 1.2 7 1999-10-22 11:14:18obachman Exp $ */4 /* $Id: syz.cc,v 1.28 1999-11-15 17:20:52 obachman Exp $ */ 5 5 6 6 /* … … 26 26 #include "ring.h" 27 27 #include "syz.h" 28 #include "prCopy.h" 29 28 30 29 31 void syDeleteRes(resolvente * res,int length) … … 131 133 * in the module below--*/ 132 134 searchUnit = TRUE; 135 int curr_syz_limit = rGetCurrSyzLimit(); 133 136 while (searchUnit) 134 137 { … … 211 214 pDelete(&Unit1); 212 215 //--deletes superfluous elements from the module below--- 213 pDelete(&(mod->m[ModComp-1 ]));214 for (k=ModComp-1 ;k<IDELEMS(mod)-1;k++)216 pDelete(&(mod->m[ModComp-1 - curr_syz_limit])); 217 for (k=ModComp-1 - curr_syz_limit;k<IDELEMS(mod)-1;k++) 215 218 mod->m[k] = mod->m[k+1]; 216 219 mod->m[IDELEMS(mod)-1] = NULL; … … 229 232 * make Gauss for one element 230 233 */ 231 static void syGaussForOne(ideal syz, int elnum, int ModComp)234 void syGaussForOne(ideal syz, int elnum, int ModComp,int from,int till) 232 235 { 233 236 int k,j,i,lu; … … 235 238 poly actWith=syz->m[elnum]; 236 239 240 if (from<0) from = 0; 241 if ((till<=0) || (till>IDELEMS(syz))) till = IDELEMS(syz); 237 242 syz->m[elnum] = NULL; 238 243 if (!rField_has_simple_inverse()) pCleardenom(actWith); 239 244 /*--makes Gauss alg. for the column ModComp--*/ 240 //unit1 = pTakeOutComp1(&(actWith), ModComp);241 245 pTakeOutComp(&(actWith), ModComp, &unit1, &lu); 242 k=0; 243 while (k<IDELEMS(syz)) 244 { 245 if (syz->m[k]!=NULL) 246 { 247 //unit2 = pTakeOutComp1(&(syz->m[k]), ModComp); 248 pTakeOutComp(&(syz->m[k]), ModComp, &unit2, &lu); 249 syz->m[k] = pMult(syz->m[k],pCopy(unit1)); 250 syz->m[k] = pSub(syz->m[k], 246 while (from<till) 247 { 248 if (syz->m[from]!=NULL) 249 { 250 pTakeOutComp(&(syz->m[from]), ModComp, &unit2, &lu); 251 syz->m[from] = pMult(syz->m[from],pCopy(unit1)); 252 syz->m[from] = pSub(syz->m[from], 251 253 pMult(pCopy(actWith),unit2)); 252 if (syz->m[k]==NULL) 253 { 254 PrintS("Hier muss noch was gemacht werden\n"); 255 } 256 } 257 k++; 254 } 255 from++; 258 256 } 259 257 pDelete(&actWith); … … 383 381 if (res[syzIndex]!=NULL) 384 382 syMinStep(res[syzIndex-1],res[syzIndex]); 383 if (!idIs0(res[0])) 384 idMinEmbedding(res[0]); 385 385 } 386 386 … … 403 403 tHomog hom=isNotHomog; 404 404 ideal temp=NULL; 405 intvec *w ,*w1=NULL,**tempW;406 int i,k,syzIndex = 0,j ;405 intvec *w = NULL,**tempW; 406 int i,k,syzIndex = 0,j,rk_arg=max(1,idRankFreeModule(arg)); 407 407 int Kstd1_OldDeg=Kstd1_deg; 408 408 BOOLEAN completeMinim; … … 420 420 } 421 421 res = (resolvente)Alloc0((*length)*sizeof(ideal)); 422 res[0] = idCopy(arg); 422 423 /*--- initialize the syzygy-ring -----------------------------*/ 424 ring origR = currRing; 425 ring syz_ring = rCurrRingAssureSyzComp(); 426 rSetSyzComp(rk_arg); 427 428 if (syz_ring != origR) 429 { 430 res[0] = idrCopyR_NoSort(arg, origR); 431 } 432 else 433 { 434 res[0] = idCopy(arg); 435 } 436 437 /*--- creating weights for the module components ---------------*/ 423 438 if ((weights==NULL) || (*weights==NULL) || ((*weights)[0]==NULL)) 424 439 { … … 440 455 if (hom==isHomog) 441 456 { 442 w1 = syPrepareModComp(res[0],&w);457 intvec *w1 = syPrepareModComp(res[0],&w); 443 458 if (w!=NULL) { delete w;w=NULL; } 444 } 459 w = w1; 460 } 461 462 /*--- the main loop --------------------------------------*/ 445 463 while ((!idIs0(res[syzIndex])) && 446 464 ((maxlength==-1) || (syzIndex<=maxlength))) 447 465 // (syzIndex<maxlength+(int)minim))) 448 /*compute one step more for minimizing*/466 /*--- compute one step more for minimizing-----------------*/ 449 467 { 450 468 if (Kstd1_deg!=0) Kstd1_deg++; … … 465 483 *weights = tempW; 466 484 } 485 /*--- interreducing first -----------------------------------*/ 467 486 if (minim || (syzIndex!=0)) 468 487 { 488 if (syzIndex>0) 489 { 490 int rkI=idRankFreeModule(res[syzIndex]); 491 rSetSyzComp(rkI); 492 } 469 493 temp = kInterRed(res[syzIndex],currQuotient); 470 494 idDelete(&res[syzIndex]); … … 473 497 } 474 498 temp = NULL; 499 /*--- computing the syzygy modules --------------------------------*/ 475 500 if ((currQuotient==NULL)&&(syzIndex==0)&& (!TEST_OPT_DEGBOUND)) 476 501 { 477 res[/*syzIndex+*/1] = idSyzygies(res[0/*syzIndex*/], 478 NULL/*currQuotient*/,hom,&w1,TRUE,Kstd1_deg); 502 res[/*syzIndex+*/1] = idSyzygies(res[0/*syzIndex*/],hom,&w,FALSE,TRUE,Kstd1_deg); 479 503 if ((!TEST_OPT_NOTREGULARITY) && (Kstd1_deg>0)) test |= Sy_bit(OPT_DEGBOUND); 480 504 } 481 505 else 482 res[syzIndex+1] = idSyzygies(res[syzIndex],currQuotient,hom,&w1); 506 { 507 res[syzIndex+1] = idSyzygies(res[syzIndex],hom,&w,FALSE); 508 } 483 509 completeMinim=(syzIndex!=maxlength) || (maxlength ==-1) || (hom!=isHomog); 484 510 syzIndex++; … … 491 517 idDelete(&res[syzIndex]); 492 518 } 519 /*---creating the iterated weights for module components ---------*/ 493 520 if ((hom == isHomog) && (!idIs0(res[syzIndex]))) 494 521 { … … 496 523 //w1->show(); 497 524 //PrintLn(); 498 k = idRankFreeModule(res[syzIndex]); 499 w = NewIntvec1(k+IDELEMS(res[syzIndex])); 525 int max_comp = idRankFreeModule(res[syzIndex]); 526 k = max_comp - rGetCurrSyzLimit(); 527 assume(w != NULL); 528 if (w != NULL) 529 w->resize(max_comp+IDELEMS(res[syzIndex])); 530 else 531 w = NewIntvec1(max_comp+IDELEMS(res[syzIndex])); 500 532 (*weights)[syzIndex] = NewIntvec1(k); 501 533 for (i=0;i<k;i++) … … 503 535 if (res[syzIndex-1]->m[i]!=NULL) // hs 504 536 { 505 (*w)[i ] = pFDeg(res[syzIndex-1]->m[i]);537 (*w)[i + rGetCurrSyzLimit()] = pFDeg(res[syzIndex-1]->m[i]); 506 538 if (pGetComp(res[syzIndex-1]->m[i])>0) 507 (*w)[i] += (*w1)[pGetComp(res[syzIndex-1]->m[i])-1]; 508 (*((*weights)[syzIndex]))[i] = (*w)[i]; 539 (*w)[i + rGetCurrSyzLimit()] 540 += (*w)[pGetComp(res[syzIndex-1]->m[i])-1]; 541 (*((*weights)[syzIndex]))[i] = (*w)[i+rGetCurrSyzLimit()]; 509 542 } 510 543 } … … 512 545 { 513 546 if (res[syzIndex]->m[i-k]!=NULL) 514 (*w)[i ] = pFDeg(res[syzIndex]->m[i-k])547 (*w)[i+rGetCurrSyzLimit()] = pFDeg(res[syzIndex]->m[i-k]) 515 548 +(*w)[pGetComp(res[syzIndex]->m[i-k])-1]; 516 549 } 517 delete w1; 518 w1 = w; 519 w = NULL; 520 } 521 } 550 } 551 } 552 /*--- end of the main loop --------------------------------------*/ 553 /*--- deleting the temporare data structures --------------------*/ 522 554 if ((syzIndex!=0) && (res[syzIndex]!=NULL) && (idIs0(res[syzIndex]))) 523 555 idDelete(&res[syzIndex]); 524 if (w1!=NULL) delete w1; 525 //if ((maxlength!=-1) && (!minim)) 526 //{ 527 // while (syzIndex<=maxlength) 528 // { 529 // res[syzIndex]=idInit(1,1); 530 // syzIndex++; 531 // if (syzIndex<=maxlength) 532 // { 533 // res[syzIndex]=idFreeModule(1); 534 // syzIndex++; 535 // } 536 // } 537 //} 556 if (w !=NULL) delete w; 557 538 558 Kstd1_deg=Kstd1_OldDeg; 539 559 if (!oldDegBound) 540 560 test &= ~Sy_bit(OPT_DEGBOUND); 561 562 for (i=1; i<=syzIndex; i++) 563 { 564 if (! idIs0(res[i])) 565 { 566 for (j=0; j<IDELEMS(res[i]); j++) 567 { 568 pShift(&res[i]->m[j], -rGetMaxSyzComp(i)); 569 } 570 } 571 } 572 /*--- going back to the original ring -------------------------*/ 573 if (origR != syz_ring) 574 { 575 rChangeCurrRing(origR, TRUE); 576 for (i=0; i<=syzIndex; i++) 577 { 578 res[i] = idrMoveR_NoSort(res[i], syz_ring); 579 } 580 } 541 581 return res; 542 582 } … … 574 614 } 575 615 616 static poly sypCopyConstant(poly inp) 617 { 618 poly outp=NULL,q; 619 620 while (inp!=NULL) 621 { 622 if (pIsConstantComp(inp)) 623 { 624 if (outp==NULL) 625 { 626 q = outp = pHead(inp); 627 } 628 else 629 { 630 pNext(q) = pHead(inp); 631 pIter(q); 632 } 633 } 634 pIter(inp); 635 } 636 return outp; 637 } 576 638 int syDetect(ideal id,int index,BOOLEAN homog,int * degrees,int * tocancel) 577 639 { … … 584 646 for (i=0;i<IDELEMS(id);i++) 585 647 { 586 p = id->m[i]; 587 while (p!=NULL) 588 { 589 if (pIsConstantComp(p)) 590 { 591 if (temp->m[i]==NULL) 592 { 593 temp->m[i] = pHead(p); 594 q = temp->m[i]; 595 } 596 else 597 { 598 pNext(q) = pHead(p); 599 pIter(q); 600 } 601 } 602 pIter(p); 603 } 648 temp->m[i] = sypCopyConstant(id->m[i]); 604 649 } 605 650 i = IDELEMS(id); … … 611 656 } 612 657 j = 0; 658 p = NULL; 613 659 while ((j<i) && (temp->m[j]==NULL)) j++; 614 if (j<i) 615 { 616 p = temp->m[j]; 617 temp->m[j] = NULL; 618 } 619 else 620 { 621 p = NULL; 622 } 623 while (p!=NULL) 660 while (j<i) 624 661 { 625 662 if (homog) … … 633 670 tocancel[0]--; 634 671 } 635 ModComp = pGetComp(p); 636 //Print("Element %d: ",j);pWrite(p); 637 //Unit1 = pTakeOutComp1(&p,ModComp); 638 pTakeOutComp(&p,ModComp, &Unit1, &lu); 639 pSetComp(Unit1,0); 640 for (k=j+1;k<i;k++) 641 { 642 if (temp->m[k]!=NULL) 643 { 644 //Print("erst %d: ",k);pWrite(temp->m[k]); 645 //Unit2 = pTakeOutComp1(&(temp->m[k]),ModComp); 646 pTakeOutComp(&(temp->m[k]),ModComp,&Unit2,&lu); 647 if (Unit2!=NULL) 648 { 649 number tmp=nCopy(pGetCoeff(Unit2)); 650 tmp=nNeg(tmp); 651 qq = pCopy(p); 652 pMultN(qq,tmp); 653 nDelete(&tmp); 654 pMultN(temp->m[k],pGetCoeff(Unit1)); 655 temp->m[k] = pAdd(temp->m[k],qq); 656 //Print("dann %d: ",k);pWrite(temp->m[k]); 657 pDelete(&Unit2); 658 } 659 } 660 } 661 //PrintLn(); 662 pDelete(&Unit1); 663 pDelete(&p); 672 syGaussForOne(temp,j,pGetComp(temp->m[j]),j+1,i); 664 673 j++; 665 674 while ((j<i) && (temp->m[j]==NULL)) j++; 666 if (j>=i)667 {668 idDelete(&temp);669 return subFromRank;670 }671 p = temp->m[j];672 temp->m[j] = NULL;673 675 } 674 676 idDelete(&temp);
Note: See TracChangeset
for help on using the changeset viewer.