Changeset dcf8b4b in git


Ignore:
Timestamp:
Dec 1, 2009, 5:47:46 PM (14 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1a4313bf84d3433b6a113589a965c6ea1766c8ce
Parents:
1d37196eda0b0e8bea2d9be3b21f429dafca15d1
Message:
Garbage collection works
modified aktpoly usage in computeInv
modified denom array in makeInt


git-svn-id: file:///usr/local/Singular/svn/trunk@12352 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r1d37196 rdcf8b4b  
    178178        if(this->codim2Ptr!=NULL)
    179179                delete this->codim2Ptr;
    180 //      if(this->flipGB!=NULL)
    181 //              idDelete((ideal *)&this->flipGB);
    182 //      if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)
    183 //              rDelete(this->flipRing);
     180        if(this->flipGB!=NULL)
     181                idDelete((ideal *)&this->flipGB);
     182        if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)
     183                rDelete(this->flipRing);
    184184//      this->flipRing=NULL;
     185        this->prev=NULL;
     186        this->next=NULL;
    185187        //this=NULL;
    186188}
     
    193195        int notParallelCtr=0;
    194196        int ctr=0;
    195         intvec* fNormal;// = new intvec(pVariables);
    196         intvec* sNormal;// = new intvec(pVariables);
     197        intvec* fNormal; //No new since ivCopy and therefore getFacetNormal return a new
     198        intvec* sNormal;
    197199        fNormal = f->getFacetNormal();
    198200        sNormal = s->getFacetNormal();
     
    203205                facet* f2Act;
    204206                facet* s2Act;
    205                 f2Act = f->codim2Ptr;
    206                 intvec* f2Normal;
    207                 intvec* s2Normal;
     207                f2Act = f->codim2Ptr;           
    208208                ctr=0;
    209209                while(f2Act!=NULL)
    210210                {
     211                        intvec* f2Normal;
    211212                        f2Normal = f2Act->getFacetNormal();
    212213                        s2Act = s->codim2Ptr;
    213214                        while(s2Act!=NULL)
    214215                        {
     216                                intvec* s2Normal;
    215217                                s2Normal = s2Act->getFacetNormal();
    216218                                bool foo=areEqual(f2Normal,s2Normal);
    217219                                if(foo)
    218220                                        ctr++;
    219                                 s2Act = s2Act->next;                                                                           
     221                                s2Act = s2Act->next;
     222                                delete s2Normal;
    220223                        }
     224                        delete f2Normal;
    221225                        f2Act = f2Act->next;
    222                 }
    223         }
     226                }               
     227        }
     228        delete fNormal;
     229        delete sNormal;
    224230        if(ctr==f->numCodim2Facets)
    225231                res=TRUE;
     
    239245{                               
    240246        return ivCopy(this->fNormal);
     247//      return this->fNormal;
    241248}
    242249               
     
    307314        codim2Act = this->codim2Ptr;
    308315        intvec *fNormal;
    309         fNormal = this->getFacetNormal();
    310         intvec *f2Normal;
     316        fNormal = this->getFacetNormal();       
    311317        cout << "=======================" << endl;
    312318        cout << "Facet normal = (";
     
    317323        while(codim2Act!=NULL)
    318324        {
     325                intvec *f2Normal;
    319326                f2Normal = codim2Act->getFacetNormal();
    320327                cout << "(";
     
    322329                cout << ")" << endl;
    323330                codim2Act = codim2Act->next;
     331                delete f2Normal;
    324332        }
    325333        cout << "=======================" << endl;
     334        delete fNormal;
    326335}               
    327336               
     
    458467 * This is mainly for debugging purposes. Usually called from within gdb
    459468 */
    460 void gcone::showFacets(short codim)
     469void gcone::showFacets(const short codim)
    461470{
    462471        facet *f;
     
    469478                        f = this->facetPtr->codim2Ptr;
    470479                        break;
    471         }                       
    472                        
    473         intvec *iv;                     
     480        }       
    474481        while(f!=NULL)
    475482        {
     483                intvec *iv;
    476484                iv = f->getFacetNormal();
    477485                cout << "(";
     
    481489                else
    482490                        cout << ") ";
     491                delete iv;
    483492                f=f->next;
    484493        }
     
    493502        facet *codim2Act;
    494503        codim2Act = fAct->codim2Ptr;
    495         intvec *fNormal;
    496         intvec *f2Normal;
     504       
    497505        cout << endl;
    498506        while(fAct!=NULL)
    499507        {
     508                intvec *fNormal;               
    500509                fNormal=fAct->getFacetNormal();
    501510                cout << "(";
     
    505514                else
    506515                        cout << ")* ";
     516                delete fNormal;
    507517                codim2Act = fAct->codim2Ptr;
    508518                cout << " Codim2: ";
    509519                while(codim2Act!=NULL)
    510520                {
     521                        intvec *f2Normal;
    511522                        f2Normal = codim2Act->getFacetNormal();
    512523                        cout << "(";
    513524                        f2Normal->show(1,0);
    514525                        cout << ") ";
     526                        delete f2Normal;
    515527                        codim2Act = codim2Act->next;
    516528                }
     
    520532}
    521533               
    522 void gcone::idDebugPrint(ideal const &I)
     534void gcone::idDebugPrint(const ideal &I)
    523535{
    524536        int numElts=IDELEMS(I);
     
    533545}
    534546
    535 void gcone::invPrint(ideal const &I)
     547void gcone::invPrint(const ideal &I)
    536548{
    537549//      int numElts=IDELEMS(I);
     
    545557}
    546558
    547 bool gcone::isMonomial(ideal const &I)
     559bool gcone::isMonomial(const ideal &I)
    548560{
    549561        bool res = TRUE;
     
    596608 * an interior point of the cone.
    597609                 */
    598 void gcone::getConeNormals(ideal const &I, bool compIntPoint)
     610void gcone::getConeNormals(const ideal &I, bool compIntPoint)
    599611{
    600612        poly aktpoly;
     
    648660        * Quote: [...] every non-zero spoly should have at least one of its terms in inv(G)
    649661        */
    650         ideal initialForm=idInit(IDELEMS(I),1);
     662//      ideal initialForm=idInit(IDELEMS(I),1);
    651663        intvec *gamma=new intvec(this->numVars);
    652664        int falseGammaCounter=0;
     
    656668        for(int ii=0;ii<ddineq->rowsize;ii++)
    657669        {
     670                ideal initialForm=idInit(IDELEMS(I),1);
    658671                //read row ii into gamma
    659672                double tmp;     
     
    711724                                                p=pNext(p);                                             
    712725                                        }//while
     726                                        pDelete(&p);
     727                                        pDelete(&q);
    713728                                        if(isMaybeFacet==FALSE)
    714729                                        {
     
    734749                }//for jj
    735750                _start:;
     751                idDelete(&L);
    736752                delete P;
     753                idDelete(&initialForm);
    737754                //idDelete(L);         
    738755        }//for(ii<ddineq-rowsize
     756        delete gamma;
    739757        int offset=0;//needed for correction of redRowsArray[ii]
    740758        for( int ii=0;ii<num_elts;ii++ )
     
    833851        {                                       
    834852                WerrorS ("Only non-flippable facets. Terminating...\n");
    835                 exit(-1);//Bit harsh maybe...
     853//              exit(-1);//Bit harsh maybe...
    836854        }
    837855                       
     
    856874                this->setIntPoint(iv);  //stores the interior point in gcone::ivIntPt
    857875                delete iv;
     876                dd_FreeMatrix(posRestr);
    858877        }       
    859         //Clean up but don't delete the return value!
     878        //Clean up but don't delete the return value!   
    860879        dd_FreeMatrix(ddineq);
    861880        set_free(ddredrows);
     
    976995void gcone::flip(ideal gb, facet *f)            //Compute "the other side"
    977996{                       
    978         intvec *fNormal = new intvec(this->numVars);    //facet normal, check for parallelity                   
     997        intvec *fNormal;// = new intvec(this->numVars); //facet normal, check for parallelity                   
    979998        fNormal = f->getFacetNormal();  //read this->fNormal;
    980999
    9811000//      std::cout << "running gcone::flip" << std::endl;
    982         std::cout << "flipping UCN " << this->getUCN() << endl;
    983         cout << "over facet (";
    984         fNormal->show(1,0);
    985         cout << ") with UCN " << f->getUCN();
    986         std::cout << std::endl;
     1001//      std::cout << "flipping UCN " << this->getUCN() << endl;
     1002//      cout << "over facet (";
     1003//      fNormal->show(1,0);
     1004//      cout << ") with UCN " << f->getUCN();
     1005//      std::cout << std::endl;
    9871006        if(this->getUCN() != f->getUCN())
    9881007        {
     
    10141033        if( (srcRing->order[0]!=ringorder_a))
    10151034        {
    1016                 tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal));
     1035                intvec *iv = new intvec(this->numVars);
     1036                iv = ivNeg(fNormal);
     1037//              tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal));
     1038                tmpRing=rCopyAndAddWeight(srcRing,iv);
     1039                delete iv;
    10171040        }
    10181041        else
     
    10301053                rComplete(tmpRing);     
    10311054        }
    1032         delete fNormal;
     1055        delete fNormal;
    10331056        rChangeCurrRing(tmpRing);       
    10341057                       
     
    10511074        //H is needed further below, so don't idDelete here
    10521075        srcRing_HH=ffG(srcRing_H,this->gcBasis);
    1053 //      idDelete(&srcRing_H);
     1076        idDelete(&srcRing_H);
    10541077       
    10551078        /*Substep 2.2.1
     
    11941217        ideal dstRing_I;                       
    11951218        dstRing_I=idrCopyR(srcRing_HH,srcRing);
    1196         //idDelete(&srcRing_HH); //Hmm.... causes trouble
     1219        idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
    11971220        //dstRing_I=idrCopyR(inputIdeal,srcRing);
    11981221        BITSET save=test;
     
    12181241        f->flipRing=rCopy(dstRing);     //store the ring on the other side
    12191242//#ifdef gfan_DEBUG
    1220 //      cout << "Flipped GB is UCN " << counter+1 << ":" << endl;
     1243        cout << "Flipped GB is UCN " << counter+1 << ":" << endl;
    12211244//      this->idDebugPrint(dstRing_I);
    12221245//      cout << endl;
     
    12341257{
    12351258        intvec *check = new intvec(this->numVars);
    1236         poly initialFormElement[IDELEMS(gb)];
    1237         poly aktpoly;
     1259        poly initialFormElement;//[IDELEMS(gb)];
     1260//      poly aktpoly;
    12381261       
    12391262        for (int ii=0;ii<IDELEMS(gb);ii++)
    12401263        {
    1241                 aktpoly = pCopy((poly)gb->m[ii]);       
     1264//              aktpoly = pCopy((poly)gb->m[ii]);
     1265                poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly)
    12421266                int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
    12431267                int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
    12441268                pGetExpV(aktpoly,leadExpV);     //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p)
    1245                 initialFormElement[ii]=pHead(aktpoly);
     1269//              initialFormElement[ii]=pHead(aktpoly);
     1270                initialFormElement=pHead(aktpoly);
    12461271                               
    12471272                while(pNext(aktpoly)!=NULL)     /*loop trough terms and check for parallelity*/
     
    12571282                                (*check)[jj]=v[jj+1]-leadExpV[jj+1];
    12581283                        }
    1259 #ifdef gfan_DEBUG
    1260 //                      cout << "check=";                       
    1261 //                      check->show();
    1262 //                      cout << endl;
    1263 #endif
    12641284                        if (isParallel(*check,fNormal)) //pass *check when
    12651285                        {
    12661286                                //Found a parallel vector. Add it
    1267                                 initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly));
     1287//                              initialFormElement[ii] = pAdd(pCopy(initialFormElement[ii]),(poly)pHead(aktpoly));
     1288                                initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));
    12681289                        }                                               
    12691290                }//while
     
    12741295#endif
    12751296                /*Now initialFormElement must be added to (ideal)initialForm */
    1276                 initialForm->m[ii]=pCopy(initialFormElement[ii]);
    1277                 pDelete(&initialFormElement[ii]);
     1297//              initialForm->m[ii]=pCopy(initialFormElement[ii]);
     1298//              pDelete(&initialFormElement[ii]);
     1299                initialForm->m[ii]=pCopy(initialFormElement);
     1300                pDelete(&initialFormElement);
    12781301                omFree(leadExpV);
    12791302                omFree(v);             
    12801303        }//for
    12811304        delete check;
    1282         pDelete(&aktpoly);
     1305//      pDelete(&aktpoly);
    12831306}
    12841307
     
    12971320*/
    12981321//NOTE: use kNF or kNF2 instead of restOfDivision
    1299 ideal gcone::ffG(ideal const &H, ideal const &G)
     1322ideal gcone::ffG(const ideal &H, const ideal &G)
    13001323{
    13011324//                      cout << "Entering ffG" << endl;
     
    13311354 *\return void
    13321355 */
    1333 void gcone::getGB(ideal const &inputIdeal)             
     1356void gcone::getGB(const ideal &inputIdeal)             
    13341357{
    13351358        BITSET save=test;
     
    13591382*
    13601383*/
    1361 int gcone::dotProduct(intvec const &iva, intvec const &ivb)                             
     1384int gcone::dotProduct(const intvec &iva, const intvec &ivb)                             
    13621385{                       
    13631386        int res=0;
     
    13731396 * \f$ \alpha\parallel\beta\Leftrightarrow\langle\alpha,\beta\rangle^2=\langle\alpha,\alpha\rangle\langle\beta,\beta\rangle \f$
    13741397 */
    1375 bool gcone::isParallel(intvec const &a, intvec const &b)
     1398bool gcone::isParallel(const intvec &a, const intvec &b)
    13761399{                       
    13771400        int lhs,rhs;
     
    13951418 * Any rational point is automatically converted into an integer.
    13961419 */
    1397 void gcone::interiorPoint(dd_MatrixPtr const &M, intvec &iv) //no const &M here since we want to remove redundant rows
     1420void gcone::interiorPoint(const dd_MatrixPtr &M, intvec &iv) //no const &M here since we want to remove redundant rows
    13981421{
    13991422        dd_LPPtr lp,lpInt;
     
    14981521 *
    14991522 */
    1500 ring gcone::rCopyAndAddWeight(ring const &r, intvec const *ivw)                         
     1523ring gcone::rCopyAndAddWeight(const ring &r, const intvec *ivw)                         
    15011524{
    15021525        ring res=rCopy0(r);
     
    15541577/** \brief Check for equality of two intvecs
    15551578 */
    1556 bool gcone::areEqual(intvec const &a, intvec const &b)
     1579bool gcone::areEqual(const intvec &a, const intvec &b)
    15571580{
    15581581        bool res=TRUE;
     
    16261649           we must not memcpy them before these ops!
    16271650        */
    1628         intvec *fNormal;// = new intvec(this->numVars);
    1629         intvec *f2Normal;// = new intvec(this->numVars);
     1651       
    16301652        facet *codim2Act; codim2Act = NULL;                     
    16311653        facet *sl2Root; //sl2Root = new facet(2);
     
    16371659                if(fAct->isFlippable==TRUE)
    16381660                {
     1661                        intvec *fNormal;
    16391662                        fNormal = fAct->getFacetNormal();
    16401663                        if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
     
    16591682                        for(int jj=0;jj<fAct->numCodim2Facets;jj++)
    16601683                        {
     1684                                intvec *f2Normal;
    16611685                                f2Normal = codim2Act->getFacetNormal();
    16621686                                if(jj==0)
     
    16701694                                        sl2Act = sl2Act->next;
    16711695                                        sl2Act->setFacetNormal(f2Normal);
    1672                                 }                                       
     1696                                }
     1697                                delete f2Normal;                               
    16731698                                codim2Act = codim2Act->next;
    16741699                        }
    16751700                        fAct = fAct->next;
    1676                 }//if(fAct->isFlippable==TRUE)
     1701                        delete fNormal;                 
     1702                }//if(fAct->isFlippable==TRUE)                 
    16771703                else {fAct = fAct->next;}
    16781704        }//End of copying facets into SLA
     
    17341760#endif
    17351761                        /*add facets to SLA here*/
    1736                         SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);                 
     1762                        SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);
    17371763                        if(gfanHeuristic==1)
    17381764                        {
     
    17441770//                              idDelete((ideal*)&gcTmp->gcBasis);
    17451771                        }                       
    1746 // #if gfan_DEBUG
     1772#if gfan_DEBUG
    17471773                        if(SearchListRoot!=NULL)
    17481774                                gcTmp->showSLA(*SearchListRoot);
    1749 // #endif
     1775#endif
    17501776                        rChangeCurrRing(gcAct->baseRing);
    17511777                        //rDelete(rTmp);
     
    17611787                                break;
    17621788//                      fAct=fAct->next;
    1763                 }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );
    1764                 //NOTE Now all neighbouring cones of gcAct have been computed, so we may delete gcAct
    1765                 gcone *deleteMarker;
    1766                 deleteMarker=gcAct;
     1789                }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );         
    17671790                //Search for cone with smallest UCN
    17681791                gcNext = gcHead;
     
    18101833 * \param dd_MatrixPtr,intvec
    18111834 */
    1812 void gcone::makeInt(dd_MatrixPtr const &M, int const line, intvec &n)
     1835void gcone::makeInt(const dd_MatrixPtr &M, const int line, intvec &n)
    18131836{                       
    1814         mpz_t denom[this->numVars];
     1837//      mpz_t denom[this->numVars];
     1838        mpz_t *denom = new mpz_t[this->numVars];
    18151839        for(int ii=0;ii<this->numVars;ii++)
    18161840        {
     
    18381862                mpz_set(tmp,kgV);                               
    18391863        }
    1840                        
     1864        mpz_clear(tmp);
    18411865        /*Multiply the nominators by kgV*/
    18421866        mpq_t qkgV,res;
     
    18571881                n[ii]=(int)mpz_get_d(mpq_numref(res));
    18581882        }
    1859                         //mpz_clear(denom[this->numVars]);
     1883        delete [] denom;
    18601884        mpz_clear(kgV);
    18611885        mpq_clear(qkgV); mpq_clear(res);                       
     
    18691893void gcone::normalize()
    18701894{
    1871         int ggT=1;
     1895        int *ggT = new int;
     1896                *ggT=1;
    18721897        facet *fAct;
    18731898        facet *codim2Act;
    18741899        fAct = this->facetPtr;
    18751900        codim2Act = fAct->codim2Ptr;
    1876         intvec *n = new intvec(this->numVars);
    1877                        
    1878                         //while(codim2Act->next!=NULL)
     1901//      intvec *n = new intvec(this->numVars);
     1902                       
     1903        //while(codim2Act->next!=NULL)
    18791904        while(fAct!=NULL)
    18801905        {
    18811906                while(codim2Act!=NULL)
    18821907                {                               
     1908                        intvec *n;
    18831909                        n=codim2Act->getFacetNormal();
    18841910                        for(int ii=0;ii<this->numVars;ii++)
    18851911                        {
    1886                                 ggT = intgcd(ggT,(*n)[ii]);
     1912                                *ggT = intgcd((*ggT),(*n)[ii]);
    18871913                        }
    18881914                        for(int ii=0;ii<this->numVars;ii++)
    18891915                        {
    1890                                 (*n)[ii] = ((*n)[ii])/ggT;
     1916                                (*n)[ii] = ((*n)[ii])/(*ggT);
    18911917                        }
    18921918                        codim2Act->setFacetNormal(n);
    1893                         codim2Act = codim2Act->next;                           
     1919                        codim2Act = codim2Act->next;
     1920                        delete n;
    18941921                }
    18951922                fAct = fAct->next;
    18961923        }
    1897         delete n;
     1924        delete ggT;
     1925//      delete n;
    18981926                               
    18991927}
     
    19521980                lengthOfSearchList++;
    19531981        }
    1954 //      slEndStatic = slEnd;
    19551982        /*1st step: compare facetNormals*/
    1956         intvec *fNormal=NULL;
    1957 //      intvec *f2Normal=NULL;
    1958         intvec *slNormal=NULL;
    1959 //      intvec *sl2Normal=NULL;
     1983//      intvec *fNormal=NULL;
     1984//      intvec *slNormal=NULL;
    19601985                       
    19611986        while(fAct!=NULL)
     
    19631988                if(fAct->isFlippable==TRUE)
    19641989                {
    1965 //                      maybe=FALSE;
    1966 //                      doNotAdd=TRUE;
     1990                        intvec *fNormal=NULL;
     1991//                      intvec *slNormal=NULL;
    19671992                        fNormal=fAct->getFacetNormal();
    19681993                        slAct = slHead;
    19691994                        notParallelCtr=0;
    1970 //                      delete deleteMarker;
    1971 //                      deleteMarker=NULL;
    19721995                        /*If slAct==NULL and fAct!=NULL
    19731996                        we just copy all remaining facets into SLA*/
     
    19882011                                                slAct = slAct->next;
    19892012                                        }
    1990                                         //NOTE Below went into copy constructor                                                 
    1991 //                                      slAct->setFacetNormal(fAct->getFacetNormal());
    1992 //                                      slAct->setUCN(fAct->getUCN());
    1993 //                                      slAct->isFlippable=fAct->isFlippable;
    1994 //                                      facet *f2Copy;
    1995 //                                      f2Copy = fCopy->codim2Ptr;
    1996 //                                      sl2Act = slAct->codim2Ptr;
    1997 //                                      while(f2Copy!=NULL)
    1998 //                                      {
    1999 //                                              if(sl2Act==NULL)
    2000 //                                              {
    2001 //                                                      sl2Act = new facet(2);
    2002 //                                                      slAct->codim2Ptr = sl2Act;                                     
    2003 //                                              }
    2004 //                                              else
    2005 //                                              {
    2006 //                                                      facet *marker;
    2007 //                                                      marker = sl2Act;
    2008 //                                                      sl2Act->next = new facet(2);
    2009 //                                                      sl2Act = sl2Act->next;
    2010 //                                                      sl2Act->prev = marker;
    2011 //                                              }
    2012 //                                              sl2Act->setFacetNormal(f2Copy->getFacetNormal());
    2013 //                                              sl2Act->setUCN(f2Copy->getUCN());
    2014 //                                              f2Copy = f2Copy->next;
    2015 //                                      }
    20162013                                        fCopy = fCopy->next;
    20172014                                }
     
    20202017                        /*End of dumping into SLA*/
    20212018                        while(slAct!=NULL)
    2022                                         //while(slAct!=slEndStatic->next)
    2023                         {
    2024 //                              if(deleteMarker!=NULL)
    2025 //                              {
    2026 //                                      delete deleteMarker;
    2027 //                                      deleteMarker=NULL;
    2028 //                              }
     2019                        //while(slAct!=slEndStatic->next)
     2020                        {
     2021                                intvec *slNormal=NULL;
    20292022                                removalOccured=FALSE;
    20302023                                slNormal = slAct->getFacetNormal();
    2031 // #ifdef gfan_DEBUG
     2024#ifdef gfan_DEBUG
    20322025                                cout << "Checking facet (";
    20332026                                fNormal->show(1,1);
     
    20352028                                slNormal->show(1,1);
    20362029                                cout << ")" << endl;
    2037 // #endif                               
     2030#endif                         
    20382031                                if(areEqual(fAct,slAct))
    20392032                                {
     
    20622055//                                              deleteMarker=NULL;
    20632056                                        }
     2057#ifdef gfan_DEBUG
    20642058                                        cout << "Removing (";
    20652059                                        fNormal->show(1,1);
    20662060                                        cout << ") from list" << endl;
     2061#endif
     2062                                        delete slNormal;
    20672063                                        break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
    20682064                                }               
     
    20792075//                                      deleteMarker=NULL;
    20802076                                }
     2077                                delete slNormal;
    20812078                                                //if slAct was marked as to be deleted, delete it here!
    20822079                        }//while(slAct!=NULL)
     
    20852082                                        //if( (notParallelCtr==lengthOfSearchList ) || doNotAdd==FALSE )
    20862083                        {
    2087 // #ifdef gfan_DEBUG
     2084#ifdef gfan_DEBUG
    20882085                                cout << "Adding facet (";
    20892086                                fNormal->show(1,0);
    20902087                                cout << ") to SLA " << endl;
    2091 // #endif
     2088#endif
    20922089                                                //Add fAct to SLA
    20932090                                facet *marker;
     
    21082105                                slEnd->prev = marker;
    21092106                                //Copy codim2-facets
    2110                                 intvec *f2Normal;
     2107//                              intvec *f2Normal=new intvec(this->numVars);
    21112108                                while(f2Act!=NULL)
    21122109                                {
     2110                                        intvec *f2Normal;
    21132111                                        f2Normal=f2Act->getFacetNormal();
    21142112                                        if(slEndCodim2Root==NULL)
     
    21262124                                        }
    21272125                                        f2Act = f2Act->next;
     2126                                        delete f2Normal;
    21282127                                }
    21292128                                lengthOfSearchList++;                           
    21302129                        }//if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) ||
    21312130                        fAct = fAct->next;
     2131                        delete fNormal;
     2132//                      delete slNormal;
    21322133                }//if(fAct->isFlippable==TRUE)
    21332134                else
     
    21412142/** \brief Compute the gcd of two ints
    21422143 */
    2143 int gcone::intgcd(int a, int b)
     2144int gcone::intgcd(const int a, const int b)
    21442145{
    21452146        int r, p=a, q=b;
     
    21602161 *
    21612162 */
    2162 dd_MatrixPtr gcone::facets2Matrix(gcone const &gc)
     2163dd_MatrixPtr gcone::facets2Matrix(const gcone &gc)
    21632164{
    21642165        facet *fAct;
     
    21842185                }
    21852186                jj++;
     2187                delete comp;
    21862188                fAct=fAct->next;                               
    21872189        }                       
     
    22002202 * Each section starts with its name in CAPITALS
    22012203 */
    2202 void gcone::writeConeToFile(gcone const &gc, bool usingIntPoints)
     2204void gcone::writeConeToFile(const gcone &gc, bool usingIntPoints)
    22032205{
    22042206        int UCN=gc.UCN;
     
    22532255                {       
    22542256                        intvec *iv;
    2255                         intvec *iv2;
    22562257                        iv=fAct->getFacetNormal();
    22572258                        f2Act=fAct->codim2Ptr;
     
    22672268                                }
    22682269                        }
     2270                        delete iv;
    22692271                        while(f2Act!=NULL)
    22702272                        {
     2273                                intvec *iv2;
    22712274                                iv2=f2Act->getFacetNormal();   
    22722275                                for(int jj=0;jj<iv2->length();jj++)
     
    22812284                                        }
    22822285                                }
     2286                                delete iv2;
    22832287                                f2Act = f2Act->next;
    22842288                        }
     
    23032307        string strMonom, strCoeff, strCoeffNom, strCoeffDenom;         
    23042308        int gcBasisLength=0;
    2305         int intCoeff=1;
    2306         int intCoeffNom=1;              //better (number) but that's not compatible with stringstream;
    2307         int intCoeffDenom=1;
    2308         number nCoeff=nInit(1);
    2309         number nCoeffNom=nInit(1);
    2310         number nCoeffDenom=nInit(1);
     2309//      int intCoeff=1;
     2310//      int intCoeffNom=1;              //better (number) but that's not compatible with stringstream;
     2311//      int intCoeffDenom=1;
     2312       
    23112313        bool hasCoeffInQ = FALSE;       //does the polynomial have rational coeff?
    23122314        bool hasNegCoeff = FALSE;       //or a negative one?
     
    23242326        ring saveRing=currRing;
    23252327        rChangeCurrRing(gc->baseRing);
    2326         poly strPoly=pInit();
    2327         poly resPoly=pInit();   //The poly to be read in
     2328       
    23282329       
    23292330        string::iterator EOL;
     
    23442345                if(line=="GCBASIS")
    23452346                {
     2347                        number nCoeff=nInit(1);
     2348                        number nCoeffNom=nInit(1);
     2349                        number nCoeffDenom=nInit(1);                   
    23462350                        for(int jj=0;jj<gcBasisLength;jj++)
    23472351                        {
    23482352                                getline(gcInputFile,line);
    2349                                 //find out how many terms the poly consists of
    2350                                 for(EOL=line.begin(); EOL!=line.end();++EOL)
    2351                                 {
    2352                                         string s;
    2353                                         s=*EOL;
    2354                                         if(s=="+" || s=="-")
    2355                                                 terms++;
    2356                                 }
    23572353                                //magically convert strings into polynomials
    23582354                                //polys.cc:p_Read
    23592355                                //check until first occurance of + or -
    23602356                                //data or c_str
     2357                                poly strPoly=pInit();
     2358                                poly resPoly=pInit();   //The poly to be read in
    23612359                                while(!line.empty())
    23622360                                {
    2363 //                                      resPoly=pInit();
    2364 //                                      strPoly=pInit();
    23652361                                        hasNegCoeff = FALSE;
    23662362                                        hasCoeffInQ = FALSE;
     
    23872383                                                strMonom.erase(0,found);
    23882384                                                strMonom.erase(0,strMonom.find_first_not_of("1234567890/"));                   
    2389 //                                              ss << strCoeffNom;
    2390 //                                              ss >> intCoeffNom;
    2391 //                                              nCoeffNom=(snumber*)strCoeffNom.c_str();
    23922385                                                nRead(strCoeffNom.c_str(), &nCoeffNom);
    23932386                                                nRead(strCoeffDenom.c_str(), &nCoeffDenom);
    2394 //                                              nCoeffNom=nInit(intCoeffNom);
    2395 //                                              ss << strCoeffDenom;
    2396 //                                              ss >> intCoeffDenom;
    2397 //                                              nCoeffDenom=nInit(intCoeffDenom);
    2398 //                                              nCoeffDenom=(snumber*)strCoeffNom.c_str();
    2399                                                 //NOTE NOT SURE WHETHER THIS WILL WORK!
    2400                                                 //nCoeffNom=nInit(intCoeffNom);
    2401 //                                              nCoeffDenom=(number)strCoeffDenom.c_str();
    2402 //                                              nCoeffDenom=(number)strCoeffDenom.c_str();
    24032387                                        }
    24042388                                        else
     
    24472431                                                resPoly=pCopy(strPoly);                                                 
    24482432                                        else
    2449                                                 resPoly=pAdd(resPoly,strPoly);
    2450                                        
    2451                                        
    2452                                 }//while(!line.empty())         
    2453                        
     2433                                                resPoly=pAdd(resPoly,strPoly);                                 
     2434                                }//while(!line.empty())                 
    24542435                                gc->gcBasis->m[jj]=pCopy(resPoly);
    2455                                 resPoly=NULL;   //reset
     2436                                pDelete(&resPoly);      //reset
     2437//                              pDelete(&strPoly);      //NOTE Crashes
    24562438                        }
     2439                        nDelete(&nCoeff);
     2440                        nDelete(&nCoeffNom);
     2441                        nDelete(&nCoeffDenom);
    24572442                        break;
    24582443                }               
    2459         }//while(!gcInputFile.eof())
    2460        
     2444        }//while(!gcInputFile.eof())   
    24612445        gcInputFile.close();
    24622446        rChangeCurrRing(saveRing);
    24632447}
    24642448       
    2465 // static void gcone::idPrint(ideal &I)
    2466 // {
    2467 //      for(int ii=0;ii<IDELEMS(I);ii++)
    2468 //      {
    2469 //              cout << "_[" << ii << "]=" << I->m[ii] << endl;
    2470 //      }
    2471 // }
    24722449ring gcone::getBaseRing()
    24732450{
     
    25112488                l->m[3].rtyp=LIST_CMD;
    25122489                        lists lCodim2List = (lists)omAllocBin(slists_bin);
    2513                         lCodim2List->Init(gcAct->numFacets);           
    2514  
     2490                        lCodim2List->Init(gcAct->numFacets);
    25152491                        fAct = gcAct->facetPtr;//fAct->codim2Ptr;
    25162492                        int jj=0;
     
    25232499                                fAct = fAct->next;
    25242500                        }               
    2525                 l->m[3].data=(void*)lCodim2List;
    2526                
    2527                
     2501                l->m[3].data=(void*)lCodim2List;               
    25282502                l->m[4].rtyp=RING_CMD;
    25292503                l->m[4].data=(void*)(gcAct->getBaseRing());             
     
    25322506                res->m[ii].data=(void*)l;
    25332507                gcAct = gcAct->next;
    2534         }               
    2535        
     2508        }       
    25362509        return res;
    25372510}
     
    25452518{
    25462519        facet *fAct;
    2547         intvec *res;
    2548         intvec *fNormal = new intvec(gc->numVars);
     2520        intvec *res=new intvec(this->numVars);
     2521        intvec *fNormal;
    25492522//      int codim=n;
    25502523//      int bound;
     
    25532526        {
    25542527                intvec *m1Res=new intvec(gc->numFacets,gc->numVars,0);
    2555                 res = m1Res;
     2528                res = ivCopy(m1Res);
    25562529                fAct = gc->facetPtr;
     2530                delete m1Res;
    25572531//              bound = gc->numFacets*(this->numVars);         
    25582532        }
     
    25612535                fAct = f->codim2Ptr;
    25622536                intvec *m2Res = new intvec(f->numCodim2Facets,gc->numVars,0);
    2563                 res = m2Res;           
     2537                res = ivCopy(m2Res);
     2538                delete m2Res;   
    25642539//              bound = fAct->numCodim2Facets*(this->numVars);
    25652540
     
    25762551                fAct = fAct->next;
    25772552        }
    2578 
    25792553        delete fNormal;
    25802554        return *res;
     
    26012575        method = noRevS;
    26022576
    2603        
    2604 #ifdef gfan_DEBUG
    2605         cout << "Now in subroutine gfan" << endl;
    2606 #endif
    26072577        ring inputRing=currRing;        // The ring the user entered
    26082578        ring rootRing;                  // The ring associated to the target ordering
     
    26242594                {
    26252595                        WerrorS("Monomial input - terminating");
    2626                         res=gcAct->gcBasis;
    2627                         //break;
     2596                        exit(-1);
     2597                        gcAct->getConeNormals(gcAct->gcBasis);
     2598                        lResList=lprepareResult(gcAct,1);
     2599                        dd_free_global_constants;
     2600                        //This is filthy
     2601                        return lResList;
    26282602                }
    26292603                cout << endl;
    2630                 gcAct->getConeNormals(gcAct->gcBasis);         
    2631                 gcAct->noRevS(*gcAct);         
     2604                gcAct->getConeNormals(gcAct->gcBasis);
     2605                gcAct->noRevS(*gcAct);
     2606                rChangeCurrRing(inputRing);
    26322607                //res=gcAct->gcBasis;
    26332608                //Below is a workaround, since gcAct->gcBasis gets deleted in noRevS
     
    26552630                lResList->m[0].data=(void*)&ires;
    26562631        }
    2657        
     2632        //gcone::counter=0;
    26582633        /*Return result*/
    26592634        return lResList;
  • kernel/gfan.h

    r1d37196 rdcf8b4b  
    170170                bool isMonomial(ideal const &I);
    171171                intvec *ivNeg(const intvec *iv);
    172                 int dotProduct(intvec const &iva, intvec const &ivb);
     172                int dotProduct(const intvec &iva, const intvec &ivb);
    173173                bool isParallel(intvec const &a, intvec const &b);
    174174                bool areEqual(intvec const &a, intvec const &b);
Note: See TracChangeset for help on using the changeset viewer.