Changeset e98068 in git for kernel/gfan.cc


Ignore:
Timestamp:
Oct 19, 2009, 5:40:39 PM (15 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d2cd5158d8448e8c4da85855996e71834afaec9d
Parents:
d1f231e3b792657bbd71d87ddd26f304449bd4f4
Message:
readConeFromFile


git-svn-id: file:///usr/local/Singular/svn/trunk@12195 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    rd1f231 re98068  
    22Compute the Groebner fan of an ideal
    33$Author: monerjan $
    4 $Date: 2009-10-13 14:35:17 $
    5 $Header: /exports/cvsroot-2/cvsroot/kernel/gfan.cc,v 1.96 2009-10-13 14:35:17 monerjan Exp $
    6 $Id: gfan.cc,v 1.96 2009-10-13 14:35:17 monerjan 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 $
    77*/
    88
     
    11871187//#ifdef gfan_DEBUG
    11881188        cout << "Flipped GB is UCN " << counter+1 << ":" << endl;
    1189                         //f->printFlipGB();
    1190         this->idDebugPrint(dstRing_I);
     1189        f->printFlipGB();
     1190//      this->idDebugPrint(dstRing_I);
    11911191        cout << endl;
    11921192//#endif                       
     
    17101710        };
    17111711        heuristic h;
    1712         h=ram;
     1712        h=hdd;
    17131713       
    17141714#ifdef gfan_DEBUG
     
    19001900                                        //implant the GB into gcAct
    19011901                                        readConeFromFile(gcNext->getUCN(), gcAct);
     1902                                        rAct=rCopy(gcAct->baseRing);
     1903                                        rComplete(rAct);
     1904                                        rChangeCurrRing(rAct);
    19021905                                        break;
    19031906                                }                               
     
    24892492        string UCNstr = ss.str();
    24902493        string line;
    2491         string modLine;
    2492         string strMonom, strCoeff;             
     2494        string strGcBasisLength;
     2495        string strMonom, strCoeff, strCoeffNom, strCoeffDenom;         
    24932496        int gcBasisLength=0;
    24942497        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);
    24952503        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();
    24992510        //strcpy(UCNstring,UCNstr.c_str());
    25002511       
    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);
    25042520                                       
    2505         ifstream gcInputFile(filename, ifstream::in);
     2521        ifstream gcInputFile(filename.c_str(), ifstream::in);
    25062522       
    25072523        ring saveRing=currRing;
     
    25162532        {
    25172533                getline(gcInputFile,line);
    2518        
     2534                hasCoeffInQ = FALSE;
     2535                hasNegCoeff = FALSE;
     2536               
    25192537                if(line=="GCBASISLENGTH")
    25202538                {
    25212539                        getline(gcInputFile, line);
    2522                         ss << line;
    2523                         ss >> gcBasisLength;
     2540                        strGcBasisLength = line;
     2541//                       >> gcBasisLength;
     2542                        gcBasisLength=atoi(strGcBasisLength.c_str());
    25242543                }
    25252544                if(line=="GCBASIS")
     
    25402559                                //check until first occurance of + or -
    25412560                                //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())
    25612562                                {
    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)
    25632569                                        {
    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                                                }
    25672604                                                else
    2568                                                         strMonom = line.substr(start,stop-1);
    2569                                                 start=stop+1; //forget + or - between monomials
    2570                                                 //Check for coeff != 1
    2571                                                 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  )
    25782605                                                {
    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))
    25802627                                                        {
    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 );
    25902632                                                        }
    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                                                                                                       
    26072634                                        }
    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                       
    26092644                                gcBasis->m[jj]=pCopy(resPoly);
    26102645                                resPoly=NULL;   //reset
Note: See TracChangeset for help on using the changeset viewer.