Changeset 229d22 in git
- Timestamp:
- Apr 24, 2009, 5:23:16 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- fa30ac48535b5e4377fcd1c33b14209a59454ae3
- Parents:
- fb5992617c66ac356cd294471f9005dad76ed84e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
rfb5992 r229d22 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-04-2 3 09:44:58$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.3 8 2009-04-23 09:44:58monerjan Exp $6 $Id: gfan.cc,v 1.3 8 2009-04-23 09:44:58monerjan Exp $4 $Date: 2009-04-24 15:23:16 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.39 2009-04-24 15:23:16 monerjan Exp $ 6 $Id: gfan.cc,v 1.39 2009-04-24 15:23:16 monerjan Exp $ 7 7 */ 8 8 … … 136 136 private: 137 137 int numFacets; //#of facets of the cone 138 ring rootRing; 138 ring rootRing; //good to know this -> generic walk 139 139 ideal inputIdeal; //the original 140 140 public: … … 149 149 } 150 150 151 /** \brief Constructor with ring and ideal 152 * 153 * This constructor takes the root ring and the root ideal as parameters and stores 154 * them in the private members gcone::rootRing and gcone::inputIdeal 155 */ 151 156 gcone(ring r, ideal I) 152 157 { … … 162 167 facet *facetPtr; //Will hold the adress of the first facet; set by gcone::getConeNormals 163 168 poly gcMarkedTerm; //marked terms of the cone's Groebner basis 169 /** # of variables in the ring */ 164 170 int numVars; //#of variables in the ring 165 171 … … 306 312 double foo; 307 313 foo = mpq_get_d(ddineq->matrix[kk][jj]); 308 #ifdef gfan_DEBUG314 /*#ifdef gfan_DEBUG 309 315 std::cout << "fAct is " << foo << " at " << fAct << std::endl; 310 #endif 316 #endif*/ 311 317 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 312 318 #endif … … 314 320 double *foo; 315 321 foo = (double*)ddineq->matrix[kk][jj]; //get entry from actual position#endif 316 #ifdef gfan_DEBUG322 /*#ifdef gfan_DEBUG 317 323 std::cout << "fAct is " << *foo << " at " << fAct << std::endl; 318 #endif 324 #endif*/ 319 325 (*load)[jj-1] = (int)*foo; //store typecasted entry at pos jj-1 of load 320 326 #endif //GMPRATIONAL … … 383 389 * is parallel to \f$ leadexp(g) \f$ 384 390 * Parallelity is checked using basic linear algebra. See gcone::isParallel. 385 * Other possibilities include scomputing the rank of the matrix consisting of the vectors in question and391 * Other possibilities include computing the rank of the matrix consisting of the vectors in question and 386 392 * computing an interior point of the facet and taking all terms having the same weight with respect 387 393 * to this interior point. … … 460 466 */ 461 467 ring srcRing=currRing; 468 469 /* copied and modified from ring.cc::rAssureSyzComp */ 470 //ring tmpRing=rCopyAndChangeWeight(srcRing,fNormal); 462 471 ring tmpRing=rCopy0(srcRing); 472 int i=rBlocks(srcRing); 473 int j; 474 tmpRing->order=(int *)omAlloc((i+1)*sizeof(int)); 475 /*NOTE This should probably be set, but as of now crashes Singular*/ 476 /*tmpRing->block0=(int *)omAlloc0((i+1)*sizeof(int)); 477 tmpRing->block1=(int *)omAlloc0((i+1)*sizeof(int));*/ 478 tmpRing->wvhdl[0] =( int *)omAlloc((fNormal->length())*sizeof(int)); //found in Singular/ipshell.cc 479 for(j=i;j>0;j--) 480 { 481 tmpRing->order[j]=srcRing->order[j-1]; 482 tmpRing->block0[j]=srcRing->block0[j-1]; 483 tmpRing->block1[j]=srcRing->block1[j-1]; 484 if (srcRing->wvhdl[j-1] != NULL) 485 { 486 tmpRing->wvhdl[j] = (int*) omMemDup(srcRing->wvhdl[j-1]); 487 } 488 } 463 489 tmpRing->order[0]=ringorder_a; 464 tmpRing->wvhdl[0] =( int *)omAlloc((fNormal->length())*sizeof(int)); //found in Singular/ipshell.cc 490 tmpRing->order[1]=ringorder_dp; 491 tmpRing->order[2]=ringorder_C; 492 //tmpRing->wvhdl[0] =( int *)omAlloc((fNormal->length())*sizeof(int)); //found in Singular/ipshell.cc 465 493 466 494 for (int ii=0;ii<this->numVars;ii++) … … 492 520 ideal srcRing_HH; 493 521 srcRing_H=idrCopyR(H,tmpRing); 494 idShow(srcRing_H); 522 #ifdef gfan_DEBUG 523 cout << "srcRing_H = "; 524 idShow(srcRing_H); cout << endl; 525 #endif 495 526 srcRing_HH=ffG(srcRing_H,this->gcBasis); 496 idShow(srcRing_HH); 527 #ifdef gfan_DEBUG 528 cout << "srcRing_HH = "; 529 idShow(srcRing_HH); cout << endl; 530 #endif 497 531 /*Substep 2.2.1 498 532 Mark according to G_-\alpha … … 606 640 */ 607 641 ring dstRing=rCopy0(srcRing); 642 i=rBlocks(srcRing); 643 644 dstRing->order=(int *)omAlloc((i+1)*sizeof(int)); 645 for(j=i;j>0;j--) 646 { 647 dstRing->order[j]=srcRing->order[j-1]; 648 dstRing->block0[j]=srcRing->block0[j-1]; 649 dstRing->block1[j]=srcRing->block1[j-1]; 650 if (srcRing->wvhdl[j-1] != NULL) 651 { 652 dstRing->wvhdl[j] = (int*) omMemDup(srcRing->wvhdl[j-1]); 653 } 654 } 608 655 dstRing->order[0]=ringorder_a; 609 //dstRing->order[1]=ringorder_dp; 656 dstRing->order[1]=ringorder_dp; 657 dstRing->order[2]=ringorder_C; 610 658 dstRing->wvhdl[0] =( int *)omAlloc((iv_weight->length())*sizeof(int)); 659 611 660 for (int ii=0;ii<this->numVars;ii++) 612 661 { … … 615 664 rComplete(dstRing); 616 665 rChangeCurrRing(dstRing); 666 #ifdef gfan_DEBUG 617 667 rWrite(dstRing); cout << endl; 618 ideal dstRing_I; 619 //dstRing_I=idrCopyR(gb,srcRing);668 #endif 669 ideal dstRing_I; 620 670 dstRing_I=idrCopyR(srcRing_HH,srcRing); 621 671 //validOpts<1>=TRUE; 672 #ifdef gfan_DEBUG 622 673 idShow(dstRing_I); 623 ideal foo; 674 #endif 624 675 BITSET save=test; 625 676 test|=Sy_bit(OPT_REDSB); 626 test|=Sy_bit(6); //OPT_DEBUG 627 //foo=kStd(idrCopyR(this->inputIdeal,this->rootRing),NULL,testHomog,NULL); 628 foo=kStd(dstRing_I,NULL,testHomog,NULL); 629 idShow(foo); 630 kInterRed(foo); 631 idSkipZeroes(foo); 632 idShow(foo); 677 test|=Sy_bit(6); //OPT_DEBUG 678 dstRing_I=kStd(idrCopyR(this->inputIdeal,this->rootRing),NULL,testHomog,NULL); 679 kInterRed(dstRing_I); 680 idSkipZeroes(dstRing_I); 633 681 test=save; 682 /*End of step 3 - reduction*/ 683 684 f->setFlipGB(dstRing_I);//store the flipped GB 685 f->printFlipGB(); 634 686 635 687 }//void flip(ideal gb, facet *f) … … 784 836 }//bool isParallel 785 837 838 /** \brief Compute an interior point of a given cone 839 */ 786 840 void interiorPoint(dd_MatrixPtr const &M, intvec &iv) //no const &M here since we want to remove redundant rows 787 841 { … … 828 882 if (err!=dd_NoError){cout << "Error during dd_CopyLPSolution" << endl;} 829 883 //cout << "Tick 6" << endl; 830 884 #ifdef gfan_DEBUG 831 885 cout << "Interior point: "; 886 #endif 832 887 for (int ii=1; ii<(lpSol->d)-1;ii++) 833 888 { 889 #ifdef gfan_DEBUG 834 890 dd_WriteNumber(stdout,lpSol->sol[ii]); 891 #endif 892 /* NOTE This works only as long as gmp returns fractions with the same denominator*/ 835 893 (iv)[ii-1]=(int)mpz_get_d(mpq_numref(lpSol->sol[ii])); //looks evil, but does the trick 836 894 } … … 839 897 dd_FreeLPData(lp); 840 898 set_free(ddlinset); 841 set_free(ddredrows); 842 843 /*At this point we have an interior point of type mpq_t 844 Need to convert to an intvec 845 NOTE: Resolved 846 */ 899 set_free(ddredrows); 847 900 848 901 }//void interiorPoint(dd_MatrixPtr const &M) 902 903 ring rCopyAndChangeWeight(ring const r, intvec const *ivw) 904 { 905 ring res=rCopy0(r, FALSE, FALSE); 906 int i=rBlocks(r); 907 int j; 908 909 res->order=(int *)omAlloc((i+1)*sizeof(int)); 910 /*res->block0=(int *)omAlloc0((i+1)*sizeof(int)); 911 res->block1=(int *)omAlloc0((i+1)*sizeof(int)); 912 int ** wvhdl =(int **)omAlloc0((i+1)*sizeof(int**));*/ 913 for(j=i;j>0;j--) 914 { 915 res->order[j]=r->order[j-1]; 916 res->block0[j]=r->block0[j-1]; 917 res->block1[j]=r->block1[j-1]; 918 if (r->wvhdl[j-1] != NULL) 919 { 920 res->wvhdl[j] = (int*) omMemDup(r->wvhdl[j-1]); 921 } 922 } 923 res->order[0]=ringorder_a; 924 res->order[1]=ringorder_dp; 925 res->order[2]=ringorder_C; 926 //res->wvhdl = wvhdl; 927 928 res->wvhdl[0] =( int *)omAlloc((ivw->length())*sizeof(int)); 929 for (int ii=0;ii<this->numVars;ii++) 930 { 931 res->wvhdl[0][ii]=(*ivw)[ii]; 932 } 933 934 rComplete(res); 935 return res; 936 }//rCopyAndChange 849 937 };//class gcone 850 938 … … 858 946 ring inputRing=currRing; // The ring the user entered 859 947 ring rootRing; // The ring associated to the target ordering 860 ideal res; 861 //matrix ineq; //Matrix containing the boundary inequalities 948 ideal res; 862 949 facet *fRoot; 863 950 … … 874 961 rootRing=rCopy0(currRing); 875 962 rootRing->order[0]=ringorder_lp; 963 /*rootRing->order[0]=ringorder_a; 964 rootRing->order[1]=ringorder_lp; 965 rootRing->wvhdl[0] =( int *)omAlloc(numvar*sizeof(int)); 966 rootRing->wvhdl[0][1]=1; 967 rootRing->wvhdl[0][2]=1;*/ 876 968 rComplete(rootRing); 877 969 rChangeCurrRing(rootRing);
Note: See TracChangeset
for help on using the changeset viewer.