Changeset e98068 in git
- Timestamp:
- Oct 19, 2009, 5:40:39 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- d2cd5158d8448e8c4da85855996e71834afaec9d
- Parents:
- d1f231e3b792657bbd71d87ddd26f304449bd4f4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
rd1f231 re98068 2 2 Compute the Groebner fan of an ideal 3 3 $Author: monerjan $ 4 $Date: 2009-10-1 3 14:35:17$5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.9 6 2009-10-13 14:35:17monerjan Exp $6 $Id: gfan.cc,v 1.9 6 2009-10-13 14:35:17monerjan Exp $4 $Date: 2009-10-19 15:40:39 $ 5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.97 2009-10-19 15:40:39 monerjan Exp $ 6 $Id: gfan.cc,v 1.97 2009-10-19 15:40:39 monerjan Exp $ 7 7 */ 8 8 … … 1187 1187 //#ifdef gfan_DEBUG 1188 1188 cout << "Flipped GB is UCN " << counter+1 << ":" << endl; 1189 //f->printFlipGB();1190 this->idDebugPrint(dstRing_I);1189 f->printFlipGB(); 1190 // this->idDebugPrint(dstRing_I); 1191 1191 cout << endl; 1192 1192 //#endif … … 1710 1710 }; 1711 1711 heuristic h; 1712 h= ram;1712 h=hdd; 1713 1713 1714 1714 #ifdef gfan_DEBUG … … 1900 1900 //implant the GB into gcAct 1901 1901 readConeFromFile(gcNext->getUCN(), gcAct); 1902 rAct=rCopy(gcAct->baseRing); 1903 rComplete(rAct); 1904 rChangeCurrRing(rAct); 1902 1905 break; 1903 1906 } … … 2489 2492 string UCNstr = ss.str(); 2490 2493 string line; 2491 string modLine;2492 string strMonom, strCoeff ;2494 string strGcBasisLength; 2495 string strMonom, strCoeff, strCoeffNom, strCoeffDenom; 2493 2496 int gcBasisLength=0; 2494 2497 int intCoeff=1; 2498 int intCoeffNom=1; //better (number) but that's not compatible with stringstream; 2499 int intCoeffDenom=1; 2500 number nCoeff=nInit(1); 2501 number nCoeffNom=nInit(1); 2502 number nCoeffDenom=nInit(1); 2495 2503 bool hasCoeffInQ = FALSE; //does the polynomial have rational coeff? 2496 2497 char prefix[]="/tmp/cone"; 2498 const char *UCNstring = UCNstr.c_str(); 2504 bool hasNegCoeff = FALSE; //or a negative one? 2505 size_t found; //used for find_first_(not)_of 2506 2507 // char prefix[]="/tmp/cone"; 2508 string prefix="/tmp/cone"; 2509 // const char *UCNstring = UCNstr.c_str(); 2499 2510 //strcpy(UCNstring,UCNstr.c_str()); 2500 2511 2501 char suffix[]=".sg"; 2502 char *filename=strcat(prefix,UCNstring); 2503 strcat(filename,suffix); 2512 // char suffix[]=".sg"; 2513 string suffix=".sg"; 2514 // char *filename=strcat(prefix,UCNstring); 2515 string filename; 2516 filename.append(prefix); 2517 filename.append(UCNstr); 2518 filename.append(suffix); 2519 // strcat(filename,suffix); 2504 2520 2505 ifstream gcInputFile(filename , ifstream::in);2521 ifstream gcInputFile(filename.c_str(), ifstream::in); 2506 2522 2507 2523 ring saveRing=currRing; … … 2516 2532 { 2517 2533 getline(gcInputFile,line); 2518 2534 hasCoeffInQ = FALSE; 2535 hasNegCoeff = FALSE; 2536 2519 2537 if(line=="GCBASISLENGTH") 2520 2538 { 2521 2539 getline(gcInputFile, line); 2522 ss << line; 2523 ss >> gcBasisLength; 2540 strGcBasisLength = line; 2541 // >> gcBasisLength; 2542 gcBasisLength=atoi(strGcBasisLength.c_str()); 2524 2543 } 2525 2544 if(line=="GCBASIS") … … 2540 2559 //check until first occurance of + or - 2541 2560 //data or c_str 2542 // for(EOL=line.begin(); EOL!=line.end();++EOL) 2543 // { 2544 // string s; 2545 // s=*EOL; 2546 // if(s=="+" || s=="-") 2547 // { 2548 // strMonom=line.substr(0,*EOL); 2549 // modLine=line.substr(*EOL,line.length()); //Truncate 2550 // line=modLine; 2551 // const char* monom = strMonom.c_str(); 2552 // p_Read(monom,strPoly,currRing); 2553 // resPoly=pAdd(resPoly,strPoly); 2554 // } 2555 // 2556 // } 2557 int start,stop; 2558 start=0; 2559 stop=0; 2560 for(int ii=0;ii<line.length();ii++) 2561 while(!line.empty()) 2561 2562 { 2562 if(line[ii]=='+' || line[ii]=='-') 2563 found = line.find_first_of("+-"); //get the first monomial 2564 string tmp; 2565 tmp=line[found]; 2566 // if(found!=0 && (tmp.compare("-")==0) ) 2567 // hasNegCoeff = TRUE; //We have a coeff < 0 2568 if(found==0) 2563 2569 { 2564 stop=ii; 2565 if(start==0) 2566 strMonom = line.substr(start,stop); 2570 if(tmp.compare("-")==0) 2571 hasNegCoeff = TRUE; 2572 line.erase(0,1); //remove leading + or - 2573 found = line.find_first_of("+-"); //adjust found 2574 } 2575 strMonom = line.substr(0,found); 2576 line.erase(0,found); 2577 found = strMonom.find_first_of("/"); 2578 if(found!=string::npos) //i.e. "/" exists in strMonom 2579 { 2580 hasCoeffInQ = TRUE; 2581 strCoeffNom=strMonom.substr(0,found); 2582 strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890"));//string::npos); 2583 ss << strCoeffNom; 2584 ss >> intCoeffNom; 2585 nCoeffNom=nInit(intCoeffNom); 2586 ss << strCoeffDenom; 2587 ss >> intCoeffDenom; 2588 nCoeffDenom=nInit(intCoeffDenom); 2589 //NOTE NOT SURE WHETHER THIS WILL WORK! 2590 //nCoeffNom=nInit(intCoeffNom); 2591 // nCoeffDenom=(number)strCoeffDenom.c_str(); 2592 // nCoeffDenom=(number)strCoeffDenom.c_str(); 2593 } 2594 else 2595 { 2596 found = strMonom.find_first_not_of("1234567890"); 2597 strCoeff = strMonom.substr(0,found); 2598 if(!strCoeff.empty()) 2599 { 2600 // ss << strCoeff; 2601 // ss >> intCoeff; 2602 nCoeff=(snumber*)strCoeff.c_str(); 2603 } 2567 2604 else 2568 strMonom = line.substr(start,stop-1);2569 start=stop+1; //forget + or - between monomials2570 //Check for coeff != 12571 int coeffStop=0;2572 if(strMonom[0] == '1' ||2573 strMonom[jj] == 2 || strMonom[jj] == 3 ||2574 strMonom[jj] == 4 || strMonom[jj] == 5 ||2575 strMonom[jj] == 6 || strMonom[jj] == 7 ||2576 strMonom[jj] == 8 || strMonom[jj] == 9 ||2577 strMonom[jj] == 0 )2578 2605 { 2579 for(int jj=1;jj<strMonom.length();jj++) 2606 // intCoeff = 1; 2607 nCoeff = nInit(1); 2608 } 2609 2610 } 2611 const char* monom = strMonom.c_str(); 2612 2613 p_Read(monom,strPoly,currRing); 2614 switch (hasCoeffInQ) 2615 { 2616 case TRUE: 2617 if(hasNegCoeff) 2618 nCoeff=nNeg(nCoeffNom); 2619 // intCoeffNom *= -1; 2620 // pSetCoeff(strPoly, nDiv((number)intCoeffNom, (number)intCoeffDenom)); 2621 pSetCoeff(strPoly, nDiv(nCoeffNom, nCoeffDenom)); 2622 case FALSE: 2623 if(hasNegCoeff) 2624 nCoeff=nNeg(nCoeff); 2625 // intCoeff *= -1; 2626 if(!nIsOne(nCoeff)) 2580 2627 { 2581 if(strMonom[jj] != 1 && 2582 strMonom[jj] != 2 && strMonom[jj] != 3 && 2583 strMonom[jj] != 4 && strMonom[jj] != 5 && 2584 strMonom[jj] != 6 && strMonom[jj] != 7 && 2585 strMonom[jj] != 8 && strMonom[jj] != 9 && 2586 strMonom[jj] != 0 ) 2587 { 2588 coeffStop=jj-1; 2589 } 2628 // if(hasNegCoeff) 2629 // intCoeff *= -1; 2630 // pSetCoeff(strPoly,(number) intCoeff); 2631 pSetCoeff(strPoly, nCoeff ); 2590 2632 } 2591 strCoeff = strMonom.substr(0,coeffStop); 2592 ss << strCoeff; 2593 ss >> intCoeff; 2594 //Trim 2595 strMonom = strMonom.substr( coeffStop,strMonom.length() ); 2596 }//strMonom==1|| 2597 //Check for coeff from Q 2598 2599 const char* monom = strMonom.c_str(); 2600 2601 p_Read(monom,strPoly,currRing); 2602 pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1??? 2603 if(pIsConstantComp(resPoly)) 2604 resPoly=pCopy(strPoly); 2605 else 2606 resPoly=pAdd(resPoly,strPoly); 2633 2607 2634 } 2608 } 2635 //pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1??? 2636 if(pIsConstantComp(resPoly)) 2637 resPoly=pCopy(strPoly); 2638 else 2639 resPoly=pAdd(resPoly,strPoly); 2640 2641 2642 }//while(!line.empty()) 2643 2609 2644 gcBasis->m[jj]=pCopy(resPoly); 2610 2645 resPoly=NULL; //reset
Note: See TracChangeset
for help on using the changeset viewer.