- Timestamp:
- Apr 20, 2009, 5:35:04 PM (15 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- 8614b753fb6893a43005f8652abd5d7296d3c992
- Parents:
- 6b0aa282252fc9ee946503d2609e77b28ea0aa7f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r6b0aa2 rf85223 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-04- 17 13:44:27$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.3 5 2009-04-17 13:44:27monerjan Exp $6 $Id: gfan.cc,v 1.3 5 2009-04-17 13:44:27monerjan Exp $4 $Date: 2009-04-20 15:35:04 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.36 2009-04-20 15:35:04 monerjan Exp $ 6 $Id: gfan.cc,v 1.36 2009-04-20 15:35:04 monerjan Exp $ 7 7 */ 8 8 … … 21 21 #include "ring.h" 22 22 #include "prCopy.h" 23 #include "iostream.h" //deprecated 23 #include <iostream.h> //deprecated 24 25 /*remove the following at your own risk*/ 26 #ifndef GMPRATIONAL 27 #define GMPRATIONAL 28 #endif 24 29 25 30 //Hacks for different working places … … 39 44 #include "/u/slg/monerjan/cddlib/include/setoper.h" 40 45 #include "/u/slg/monerjan/cddlib/include/cdd.h" 46 #include "/u/slg/monerjan/cddlib/include/cddmp.h" 41 47 #endif 42 48 … … 164 170 { 165 171 #ifdef gfan_DEBUG 166 cout << "*** Computing Inequalities... ***" <<endl;172 std::cout << "*** Computing Inequalities... ***" << std::endl; 167 173 #endif 168 174 //All variables go here - except ineq matrix and *v, see below … … 178 184 dd_rowset ddredrows; // # of redundant rows in ddineq 179 185 dd_rowset ddlinset; // the opposite 180 dd_rowindex ddnewpos; // all to make dd_Canonicalize happy181 dd_NumberType ddnumb=dd_ Real;//Number type186 dd_rowindex ddnewpos; // all to make dd_Canonicalize happy 187 dd_NumberType ddnumb=dd_Integer; //Number type 182 188 dd_ErrorType dderr=dd_NoError; // 183 189 // End of var declaration … … 203 209 ddrows=rows; 204 210 ddcols=cols; 205 dd_MatrixPtr ddineq; //Matrix to store the inequalities 211 dd_MatrixPtr ddineq; //Matrix to store the inequalities 206 212 ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there 207 213 … … 286 292 for (int jj = 1; jj <ddcols; jj++) 287 293 { 294 #ifdef GMPRATIONAL 295 double foo; 296 foo = mpq_get_d(ddineq->matrix[kk][jj]); 297 #ifdef gfan_DEBUG 298 std::cout << "fAct is " << foo << " at " << fAct << std::endl; 299 #endif 300 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 301 #endif 302 #ifndef GMPRATIONAL 288 303 double *foo; 289 foo = (double*)ddineq->matrix[kk][jj]; //get entry from actual position 304 foo = (double*)ddineq->matrix[kk][jj]; //get entry from actual position#endif 290 305 #ifdef gfan_DEBUG 291 306 std::cout << "fAct is " << *foo << " at " << fAct << std::endl; 292 #endif 307 #endif 293 308 (*load)[jj-1] = (int)*foo; //store typecasted entry at pos jj-1 of load 309 #endif //GMPRATIONAL 310 311 312 //(*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 294 313 //check for flipability here 295 314 if (jj<ddcols) //Is this facet NOT the last facet? Writing while instead of if is a really bad idea :) … … 364 383 fNormal = f->getFacetNormal(); //read this->fNormal; 365 384 #ifdef gfan_DEBUG 366 cout << "===" <<endl;367 cout << "running gcone::flip" <<endl;368 cout << "fNormal=";385 std::cout << "===" << std::endl; 386 std::cout << "running gcone::flip" << std::endl; 387 std::cout << "fNormal="; 369 388 fNormal->show(); 370 cout <<endl;389 std::cout << std::endl; 371 390 #endif 372 391 /*1st step: Compute the initial ideal*/ … … 473 492 compute the difference accordingly 474 493 */ 475 dd_set_global_constants ;494 dd_set_global_constants(); 476 495 bool markingsAreCorrect=FALSE; 477 496 dd_MatrixPtr intPointMatrix; … … 487 506 */ 488 507 intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1); 508 intPointMatrix->numbtype=dd_Integer; //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational 489 509 490 510 for (int ii=0;ii<IDELEMS(srcRing_HH);ii++) … … 560 580 /*Now we add the constraint for the standard simplex*/ 561 581 /*NOTE:Might actually work without the standard simplex*/ 562 //dd_set_si(intPointMatrix->matrix[aktrow][0],100);582 dd_set_si(intPointMatrix->matrix[aktrow][0],-1); 563 583 for (int jj=1;jj<=this->numVars;jj++) 564 584 { 565 //dd_set_si(intPointMatrix->matrix[aktrow][jj],-1);585 dd_set_si(intPointMatrix->matrix[aktrow][jj],1); 566 586 } 567 587 dd_WriteMatrix(stdout,intPointMatrix); 568 588 interiorPoint(intPointMatrix); //TODO This should finally return an intvec 569 589 dd_FreeMatrix(intPointMatrix); 590 //dd_free_global_constants(); 570 591 571 592 /*Step 3 … … 724 745 }//bool isParallel 725 746 726 void interiorPoint(dd_MatrixPtr &M) //no const &M here since we want to remove redundant rows747 void interiorPoint(dd_MatrixPtr M) //no const &M here since we want to remove redundant rows 727 748 { 728 749 dd_LPPtr lp,lpInt; 729 750 dd_ErrorType err=dd_NoError; 730 751 dd_LPSolverType solver=dd_DualSimplex; 731 dd_LPSolutionPtr lpSol ;752 dd_LPSolutionPtr lpSol=NULL; 732 753 dd_rowset ddlinset,ddredrows; 733 754 dd_rowindex ddnewpos; 734 dd_NumberType numb; 735 numb=dd_Integer; 736 737 M->numbtype=numb; 738 dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err); 739 dd_WriteMatrix(stdout,M); 755 dd_NumberType numb; 756 //M->representation=dd_Inequality; 757 //M->objective-dd_LPMin; //Not sure whether this is needed 758 dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1); 759 cout << "TICK 1" << endl; 760 //numb=dd_Rational; 761 762 //M->numbtype=dd_Real; 763 //dd_MatrixCanonicalize(&M, &ddlinset, &ddredrows, &ddnewpos, &err); 764 //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;} 765 cout << "Tick 2" << endl; 766 //dd_WriteMatrix(stdout,M); 740 767 741 768 lp=dd_Matrix2LP(M, &err); 769 //if (err!=dd_NoError){cout << "Error during dd_Matrix2LP" << endl;} 770 if (lp==NULL){cout << "LP is NULL" << endl;} 771 dd_WriteLP(stdout,lp); 772 cout << "Tick 3" << endl; 773 742 774 lpInt=dd_MakeLPforInteriorFinding(lp); 743 dd_LPSolve(lpInt,solver,&err); 744 lpSol=dd_CopyLPSolution(lpInt); 745 lpSol->numbtype=numb; 775 //if (err!=dd_NoError){cout << "Error during dd_MakeLPForInteriorFinding" << endl;} 776 dd_WriteLP(stdout,lpInt); 777 cout << "Tick 4" << endl; 778 779 dd_FindRelativeInterior(M,&ddlinset,&ddredrows,&lpSol,&err); 780 781 //dd_LPSolve(lpInt,solver,&err); //This will not result in a point from the relative interior 782 //if (err!=dd_NoError){cout << "Error during dd_LPSolve" << endl;} 783 cout << "Tick 5" << endl; 784 785 //lpSol=dd_CopyLPSolution(lpInt); 786 //if (err!=dd_NoError){cout << "Error during dd_CopyLPSolution" << endl;} 787 cout << "Tick 6" << endl; 788 746 789 cout << "Interior point: "; 747 790 for (int ii=1; ii<(lpSol->d)-1;ii++) … … 751 794 dd_FreeLPData(lp); 752 795 dd_FreeLPSolution(lpSol); 753 dd_FreeLPData(lpInt); 796 dd_FreeLPData(lpInt); 797 dd_FreeMatrix(M); 798 set_free(ddlinset); 799 set_free(ddredrows); 754 800 }//void interiorPoint(dd_MatrixPtr const &M) 755 801 };//class gcone
Note: See TracChangeset
for help on using the changeset viewer.