Changeset bb503c7 in git
- Timestamp:
- Oct 20, 2009, 5:14:02 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- a388ae5c0bb2238bcecc75e032fb91a5a79c3b00
- Parents:
- d2cd5158d8448e8c4da85855996e71834afaec9d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
rd2cd515 rbb503c7 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-10-20 1 0:39:18$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.9 8 2009-10-20 10:39:18monerjan Exp $6 $Id: gfan.cc,v 1.9 8 2009-10-20 10:39:18monerjan Exp $4 $Date: 2009-10-20 15:14:02 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.99 2009-10-20 15:14:02 monerjan Exp $ 6 $Id: gfan.cc,v 1.99 2009-10-20 15:14:02 monerjan Exp $ 7 7 */ 8 8 … … 75 75 */ 76 76 77 /** The default constructor. Do I need a constructor of type facet(intvec)? */ 77 /** \brief The default constructor for facets 78 * Do I need a constructor of type facet(intvec)? 79 */ 78 80 facet::facet() 79 81 { … … 266 268 cout << "Facet normal = ("; 267 269 fNormal->show(1,1); 268 cout << ")"<<endl; 269 /*for(int ii=0;ii<pVariables;ii++) 270 { 271 cout << (*fNormal)[ii] << ","; 272 } 273 if(this->isFlippable==TRUE) 274 cout << ")" << endl; 275 else 276 cout << ")*" << endl;*/ //This case should never happen in SLA! 270 cout << ")"<<endl; 277 271 cout << "-----------------------" << endl; 278 272 cout << "Codim2 facets:" << endl; … … 282 276 cout << "("; 283 277 f2Normal->show(1,0); 284 // for(int jj=0;jj<pVariables;jj++)285 // {286 // cout << (*f2Normal)[jj] << ",";287 // }288 278 cout << ")" << endl; 289 279 codim2Act = codim2Act->next; … … 444 434 facet *codim2Act; 445 435 codim2Act = fAct->codim2Ptr; 446 intvec *fNormal; // = new intvec(this->numVars);436 intvec *fNormal; 447 437 intvec *f2Normal; 448 438 cout << endl; … … 520 510 std::cout << "*** Computing Inequalities... ***" << std::endl; 521 511 #endif 522 512 //All variables go here - except ineq matrix and *v, see below 523 513 int lengthGB=IDELEMS(I); // # of polys in the groebner basis 524 514 int pCompCount; // # of terms in a poly … … 535 525 dd_NumberType ddnumb=dd_Integer; //Number type 536 526 dd_ErrorType dderr=dd_NoError; // 537 527 // End of var declaration 538 528 #ifdef gfan_DEBUG 539 529 // cout << "The Groebner basis has " << lengthGB << " elements" << endl; … … 560 550 ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there 561 551 562 552 // We loop through each g\in GB and compute the resulting inequalities 563 553 for (int i=0; i<IDELEMS(I); i++) 564 554 { … … 572 562 pGetExpV(aktpoly,v); //find the exp.vect in v[1],...,v[n], use pNext(p) 573 563 574 564 //Store leadexp for aktpoly 575 565 for (int kk=0;kk<numvar;kk++) 576 566 { 577 567 leadexp[kk]=v[kk+1]; 578 579 568 //Since we need to know the difference of leadexp with the other expvects we do nothing here 569 //but compute the diff below 580 570 } 581 571 … … 604 594 #endif 605 595 606 607 596 // The inequalities are now stored in ddineq 597 // Next we check for superflous rows 608 598 ddredrows = dd_RedundantRows(ddineq, &dderr); 609 599 if (dderr!=dd_NoError) // did an error occur? … … 640 630 //fRoot->setUCN(this->getUCN()); 641 631 //this->facetPtr = fRoot; //set variable facetPtr of class gcone to first facet 642 facet *fAct; 632 facet *fAct; //pointer to active facet 643 633 //fAct = fRoot; //Seems to do the trick. fRoot and fAct have to point to the same adress! 644 634 //std::cout << "fRoot = " << fRoot << ", fAct = " << fAct << endl; … … 715 705 fAct->setUCN(this->getUCN()); 716 706 }//if (isFlippable==FALSE) 717 707 //delete load; 718 708 }//for (int kk = 0; kk<ddrows; kk++) 719 709 720 710 //In cases like I=<x-1,y-1> there are only non-flippable facets... 721 711 if(numNonFlip==this->numFacets) 722 712 { … … 747 737 } 748 738 749 750 751 752 753 754 755 756 757 758 759 760 761 739 //Compute the number of facets 740 // wrong because ddineq->rowsize contains only irredundant facets. There can still be 741 // non-flippable ones! 742 //this->numFacets=ddineq->rowsize; 743 744 //Clean up but don't delete the return value! (Whatever it will turn out to be) 745 dd_FreeMatrix(ddineq); 746 set_free(ddredrows); 747 //free(ddnewpos); 748 //set_free(ddlinset); 749 //NOTE Commented out. Solved the bug that after facet2Matrix there were facets lost 750 //THIS SUCKS 751 //dd_free_global_constants(); 762 752 763 753 }//method getConeNormals(ideal I) … … 770 760 void gcone::getCodim2Normals(gcone const &gc) 771 761 { 772 762 //this->facetPtr->codim2Ptr = new facet(2); //instantiate a (codim-2)-facet 773 763 facet *fAct; 774 764 fAct = this->facetPtr; 775 765 facet *codim2Act; 776 766 //codim2Act = this->facetPtr->codim2Ptr; 777 767 778 768 dd_set_global_constants(); … … 783 773 dd_rowindex newpos; 784 774 785 775 //ddineq = facets2Matrix(gc); //get a matrix representation of the cone 786 776 ddineq = dd_CopyMatrix(gc.ddFacets); 787 777 … … 923 913 // cout << endl; 924 914 #endif 925 //TODO why not *check, *fNormal????926 915 if (isParallel(*check,*fNormal)) //pass *check when 927 916 { 928 // 917 // cout << "Parallel vector found, adding to initialFormElement" << endl; 929 918 initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly)); 930 919 } … … 939 928 }//for 940 929 #ifdef gfan_DEBUG 941 /* 930 /* cout << "Initial ideal is: " << endl; 942 931 idShow(initialForm); 943 932 //f->printFlipGB();*/ 944 // 945 #endif 946 933 // cout << "===" << endl; 934 #endif 935 //delete check; 947 936 948 937 /*2nd step: lift initial ideal to a GB of the neighbouring cone using minus alpha as weight*/ 949 938 /*Substep 2.1 950 939 compute $G_{-\alpha}(in_v(I)) 951 940 see journal p. 66 952 941 NOTE Check for different rings. Prolly it will not always be necessary to add a weight, if the 953 942 srcRing already has a weighted ordering 954 943 */ 955 944 ring srcRing=currRing; 956 945 ring tmpRing; … … 976 965 rChangeCurrRing(tmpRing); 977 966 978 967 //rWrite(currRing); cout << endl; 979 968 980 969 ideal ina; … … 991 980 // cout << "H="; idShow(H); cout << endl; 992 981 #endif 993 982 /*Substep 2.2 994 983 do the lifting and mark according to H 995 984 */ 996 985 rChangeCurrRing(srcRing); 997 986 ideal srcRing_H; … … 1007 996 // idShow(srcRing_HH); cout << endl; 1008 997 #endif 1009 1010 Mark according to G_-\alpha1011 Here we have a minimal basis srcRing_HH. In order to turn this basis into a reduced basis1012 we have to compute an interior point of C(srcRing_HH). For this we need to know the cone1013 represented by srcRing_HH MARKED ACCORDING TO G_{-\alpha}1014 Thus we check whether the leading monomials of srcRing_HH and srcRing_H coincide. If not we1015 compute the difference accordingly1016 998 /*Substep 2.2.1 999 * Mark according to G_-\alpha 1000 * Here we have a minimal basis srcRing_HH. In order to turn this basis into a reduced basis 1001 * we have to compute an interior point of C(srcRing_HH). For this we need to know the cone 1002 * represented by srcRing_HH MARKED ACCORDING TO G_{-\alpha} 1003 * Thus we check whether the leading monomials of srcRing_HH and srcRing_H coincide. If not we 1004 * compute the difference accordingly 1005 */ 1017 1006 dd_set_global_constants(); 1018 1007 bool markingsAreCorrect=FALSE; … … 1025 1014 iPMatrixRows = iPMatrixRows+pLength(aktpoly)-1; 1026 1015 } 1027 1028 construction of the differences1029 1016 /* additionally one row for the standard-simplex and another for a row that becomes 0 during 1017 * construction of the differences 1018 */ 1030 1019 intPointMatrix = dd_CreateMatrix(iPMatrixRows+10,this->numVars+1); //iPMatrixRows+10; 1031 1020 intPointMatrix->numbtype=dd_Integer; //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational … … 1082 1071 while (pNext(aktpoly)!=NULL) 1083 1072 { 1084 1073 /*The following if-else-block makes sure the first term (i.e. the wrongly marked term) 1085 1074 is not omitted when computing the differences*/ 1086 1075 if(markingsAreCorrect==TRUE) … … 1112 1101 dd_set_si(intPointMatrix->matrix[aktrow][jj],1); 1113 1102 } 1114 1103 //Let's make sure we compute interior points from the positive orthant 1115 1104 dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1); 1116 1105 int jj=1; … … 1187 1176 //#ifdef gfan_DEBUG 1188 1177 cout << "Flipped GB is UCN " << counter+1 << ":" << endl; 1189 f->printFlipGB();1190 //this->idDebugPrint(dstRing_I);1178 // f->printFlipGB(); 1179 this->idDebugPrint(dstRing_I); 1191 1180 cout << endl; 1192 1181 //#endif … … 1299 1288 ideal gb; 1300 1289 gb=kStd(inputIdeal,NULL,testHomog,NULL); 1290 idNorm(gb); 1301 1291 idSkipZeroes(gb); 1302 1292 this->gcBasis=gb; //write the GB into gcBasis … … 2403 2393 string UCNstr = ss.str(); 2404 2394 2405 char prefix[]="/tmp/cone";2406 char *UCNstring;2407 str cpy(UCNstring,UCNstr.c_str());2408 char suffix[]=".sg";2409 char *filename=strcat(prefix,UCNstring);2410 strcat(filename,suffix);2395 string prefix="/tmp/cone"; 2396 string suffix=".sg"; 2397 string filename; 2398 filename.append(prefix); 2399 filename.append(UCNstr); 2400 filename.append(suffix); 2411 2401 2412 ofstream gcOutputFile(filename );2413 facet *fAct; // = new facet(); //NOTE Why new?2402 ofstream gcOutputFile(filename.c_str()); 2403 facet *fAct; 2414 2404 fAct = gc.facetPtr; 2415 2405 facet *f2Act; … … 2438 2428 2439 2429 gcOutputFile << "FACETS" << endl; 2440 //while(fAct->next!=NULL)2430 2441 2431 while(fAct!=NULL) 2442 2432 { 2443 intvec *iv; // = new intvec(gc.numVars);2433 intvec *iv; 2444 2434 intvec *iv2; 2445 2435 iv=fAct->getFacetNormal(); … … 2474 2464 gcOutputFile << endl; 2475 2465 fAct=fAct->next; 2476 // delete iv; iv=NULL;2477 2466 } 2478 2479 2467 gcOutputFile.close(); 2480 // delete fAct; fAct=NULL;2481 2468 } 2482 2469 … … 2504 2491 bool hasNegCoeff = FALSE; //or a negative one? 2505 2492 size_t found; //used for find_first_(not)_of 2506 2507 // char prefix[]="/tmp/cone"; 2493 2508 2494 string prefix="/tmp/cone"; 2509 // const char *UCNstring = UCNstr.c_str();2510 //strcpy(UCNstring,UCNstr.c_str());2511 2512 // char suffix[]=".sg";2513 2495 string suffix=".sg"; 2514 // char *filename=strcat(prefix,UCNstring);2515 2496 string filename; 2516 2497 filename.append(prefix); 2517 2498 filename.append(UCNstr); 2518 2499 filename.append(suffix); 2519 // strcat(filename,suffix);2520 2500 2521 2501 ifstream gcInputFile(filename.c_str(), ifstream::in); … … 2539 2519 getline(gcInputFile, line); 2540 2520 strGcBasisLength = line; 2541 // >> gcBasisLength;2542 2521 gcBasisLength=atoi(strGcBasisLength.c_str()); 2543 2522 }
Note: See TracChangeset
for help on using the changeset viewer.