Changeset 1fcefd in git
- Timestamp:
- May 11, 2009, 4:27:44 PM (15 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 5435c37074ca280bb7d26c85ede7b6f237e78cb3
- Parents:
- 0b1568ce1cbf77cc61022a7be99c105dc5e27cc6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r0b1568 r1fcefd 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-05- 08 12:58:01$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.4 8 2009-05-08 12:58:01monerjan Exp $6 $Id: gfan.cc,v 1.4 8 2009-05-08 12:58:01monerjan Exp $4 $Date: 2009-05-11 14:27:44 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.49 2009-05-11 14:27:44 monerjan Exp $ 6 $Id: gfan.cc,v 1.49 2009-05-11 14:27:44 monerjan Exp $ 7 7 */ 8 8 … … 21 21 #include "ring.h" 22 22 #include "prCopy.h" 23 #include <iostream .h> //deprecated23 #include <iostream> //deprecated 24 24 #include <bitset> 25 26 /*remove the following at your own risk*/ 25 #include <fstream> //read-write cones to files 26 27 /*DO NOT REMOVE THIS*/ 27 28 #ifndef GMPRATIONAL 28 29 #define GMPRATIONAL … … 53 54 54 55 //#include gcone.h 56 using namespace std; 55 57 56 58 /** … … 190 192 intvec *ivIntPt; //an interior point of the cone 191 193 192 public: 194 public: 195 /** Pointer to the first facet */ 196 facet *facetPtr; //Will hold the adress of the first facet; set by gcone::getConeNormals 197 198 /** # of variables in the ring */ 199 int numVars; //#of variables in the ring 200 201 /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/ 202 ideal gcBasis; //GB of the cone, set by gcone::getGB(); 203 gcone *next; //Pointer to *previous* cone in search tree 204 193 205 /** \brief Default constructor. 194 206 * … … 206 218 * This constructor takes the root ring and the root ideal as parameters and stores 207 219 * them in the private members gcone::rootRing and gcone::inputIdeal 220 * Since knowledge of the root ring is only needed when using reverse search, 221 * this constructor is not needed when using the "second" method 208 222 */ 209 223 gcone(ring r, ideal I) … … 235 249 gb=gc.facetPtr->getFlipGB(); 236 250 this->gcBasis=gb;//gc.facetPtr->getFlipGB(); //this cone's GB is the flipped GB 237 idShow(this->gcBasis);251 //idShow(this->gcBasis); 238 252 239 253 /*Reverse direction of the facet normal to make it an inner normal*/ … … 243 257 } 244 258 245 fAct->setFacetNormal(ivtmp); 259 fAct->setFacetNormal(ivtmp); 260 delete ivtmp; 246 261 } 247 262 248 263 /** \brief Default destructor */ 249 264 ~gcone(){;} //destructor 250 251 /** Pointer to the first facet */ 252 facet *facetPtr; //Will hold the adress of the first facet; set by gcone::getConeNormals 253 254 /** # of variables in the ring */ 255 int numVars; //#of variables in the ring 256 257 /** Contains the Groebner basis of the cone. Is set by gcone::getGB(ideal I)*/ 258 ideal gcBasis; //GB of the cone, set by gcone::getGB(); 259 gcone *next; //Pointer to *previous* cone in search tree 265 260 266 261 267 /** \brief Set the interior point of a cone */ … … 408 414 facet *fAct; //instantiate pointer to active facet 409 415 fAct = fRoot; //Seems to do the trick. fRoot and fAct have to point to the same adress! 410 std::cout << "fRoot = " << fRoot << ", fAct = " << fAct << endl;416 //std::cout << "fRoot = " << fRoot << ", fAct = " << fAct << endl; 411 417 for (int kk = 0; kk<ddrows; kk++) 412 418 { 413 intvec *load = new intvec( numvar); //intvec to store a single facet normal that will then be stored via setFacetNormal419 intvec *load = new intvec(this->numVars); //intvec to store a single facet normal that will then be stored via setFacetNormal 414 420 for (int jj = 1; jj <ddcols; jj++) 415 421 { … … 417 423 double foo; 418 424 foo = mpq_get_d(ddineq->matrix[kk][jj]); 419 /*#ifdef gfan_DEBUG425 #ifdef gfan_DEBUG 420 426 std::cout << "fAct is " << foo << " at " << fAct << std::endl; 421 #endif */427 #endif 422 428 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 423 #endif 424 #ifndef GMPRATIONAL 425 double *foo; 426 foo = (double*)ddineq->matrix[kk][jj]; //get entry from actual position#endif 427 /*#ifdef gfan_DEBUG 428 std::cout << "fAct is " << *foo << " at " << fAct << std::endl; 429 #endif*/ 430 (*load)[jj-1] = (int)*foo; //store typecasted entry at pos jj-1 of load 431 #endif //GMPRATIONAL 432 429 #endif 433 430 434 431 //(*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load … … 444 441 { 445 442 intvec *ivCanonical = new intvec(load->length()); 446 (*ivCanonical)[jj]=1; 447 if (dotProduct(load,ivCanonical)<0) 443 (*ivCanonical)[jj]=1; 444 cout << "dotProd=" << dotProduct(*load,*ivCanonical) << endl; 445 if (dotProduct(*load,*ivCanonical)<0) 448 446 { 449 447 isFlippable=TRUE; … … 480 478 } 481 479 482 //Clean up but don't delete the return value! (Whatever it will turn out to be) 483 480 //Clean up but don't delete the return value! (Whatever it will turn out to be) 484 481 dd_FreeMatrix(ddineq); 485 482 set_free(ddredrows); … … 899 896 }//GGW 900 897 898 /** \brief Compute the negative of a given intvec 899 */ 901 900 intvec *ivNeg(intvec const &iv) 902 901 { … … 1208 1207 }//bool isSearchFacet 1209 1208 1209 /** \brief Check for equality of two intvecs 1210 */ 1210 1211 bool areEqual(intvec const &a, intvec const &b) 1211 1212 { … … 1222 1223 } 1223 1224 1225 /** \brief The reverse search algorithm 1226 */ 1224 1227 void reverseSearch(gcone *gcAct) //no const possible here since we call gcAct->flip 1225 1228 { … … 1260 1263 }//while(fAct->next!=NULL) 1261 1264 }//reverseSearch 1262 friend class facet; 1265 1266 /** \brief Write information about a cone into a file on disk 1267 * 1268 * This methods writes the information needed for the "second" method into a file. 1269 * The file's is divided in sections containing information on 1270 * 1) the ring 1271 * 2) the cone's Groebner Basis 1272 * 3) the cone's facets 1273 * Each line contains exactly one date 1274 * Each section starts with its name in CAPITALS 1275 */ 1276 void writeConeToFile(gcone const &gc) 1277 { 1278 ofstream gcOutputFile("/tmp/cone1.gc"); 1279 if (!gcOutputFile) 1280 { 1281 cout << "Error opening file for writing in writeConeToFile" << endl; 1282 } 1283 else 1284 { 1285 gcOutputFile << "RING" << endl; 1286 //Write this->gcBasis into file 1287 gcOutputFile << "GCBASIS" << endl; 1288 for (int ii=0;ii<IDELEMS(gc.gcBasis);ii++) 1289 { 1290 gcOutputFile << p_String((poly)gc.gcBasis->m[ii],gc.baseRing) << endl; 1291 } 1292 1293 facet *fAct = new facet(); 1294 fAct = gc.facetPtr; 1295 gcOutputFile << "FACETS" << endl; 1296 while(fAct!=NULL) 1297 { 1298 intvec *iv = new intvec(gc.numVars); 1299 iv=fAct->getFacetNormal(); 1300 for (int ii=0;ii<iv->length();ii++) 1301 { 1302 if (ii<iv->length()-1) 1303 { 1304 gcOutputFile << (*iv)[ii] << ","; 1305 } 1306 else 1307 { 1308 gcOutputFile << (*iv)[ii] << endl; 1309 } 1310 } 1311 fAct=fAct->next; 1312 } 1313 1314 gcOutputFile.close(); 1315 } 1316 }//writeConeToFile(gcone const &gc) 1317 1318 /** \brief Reads a cone from a file identified by its number 1319 */ 1320 void readConeFromFile(int gcNum) 1321 { 1322 } 1323 1324 friend class facet; 1263 1325 };//class gcone 1264 1326 … … 1266 1328 { 1267 1329 int numvar = pVariables; 1330 1331 enum searchMethod { 1332 reverseSearch, 1333 noRevS 1334 }; 1335 1336 searchMethod method; 1337 method = noRevS; 1338 //method = reverseSearch; 1268 1339 1269 1340 #ifdef gfan_DEBUG … … 1275 1346 facet *fRoot; 1276 1347 1277 /* 1278 1. Select target order, say dp. 1279 2. Compute GB of inputIdeal wrt target order -> newRing, setCurrRing etc... 1280 3. getConeNormals 1281 */ 1348 if (method==reverseSearch) 1349 { 1282 1350 1283 1351 /* Construct a new ring which will serve as our root*/ … … 1313 1381 But since we are in the root all facets should be search facets. IS THIS TRUE? 1314 1382 NOTE: Check for flippability is not very sophisticated 1315 */ 1316 /*facet *fAct=new facet(); 1317 fAct=gcAct->facetPtr; 1318 while(fAct->next!=NULL) 1383 */ 1384 //gcAct->reverseSearch(gcAct); 1385 rChangeCurrRing(rootRing); 1386 res=gcRoot->gcBasis; 1387 }//if method==reverSearch 1388 1389 if(method==noRevS) 1319 1390 { 1320 gcAct->flip(gcAct->gcBasis,gcAct->facetPtr); 1321 gcone *gcTmp = new gcone(*gcAct); 1322 idShow(gcTmp->gcBasis); 1323 gcTmp->getConeNormals(gcTmp->gcBasis, TRUE); 1324 gcTmp->getIntPoint(); 1325 fAct = fAct->next; 1326 }*/ 1327 gcAct->reverseSearch(gcAct); 1391 gcone *gcRoot = new gcone(currRing,inputIdeal); 1392 gcone *gcAct; 1393 gcAct = gcRoot; 1394 gcAct->numVars=pVariables; 1395 gcAct->getGB(inputIdeal); 1396 gcAct->getConeNormals(gcAct->gcBasis); 1397 gcAct->writeConeToFile(*gcAct); 1398 res=gcAct->gcBasis; 1399 } 1328 1400 1329 1401 /*As of now extra.cc expects gfan to return type ideal. Probably this will change in near future. … … 1334 1406 => Count the cones! 1335 1407 */ 1336 rChangeCurrRing(rootRing);1408 //rChangeCurrRing(rootRing); 1337 1409 //res=gcAct->gcBasis; 1338 res=gcRoot->gcBasis;1410 //res=gcRoot->gcBasis; 1339 1411 return res; 1340 1412 //return GBlist;
Note: See TracChangeset
for help on using the changeset viewer.