Changeset 147167f in git


Ignore:
Timestamp:
Mar 11, 2010, 7:41:13 PM (14 years ago)
Author:
Martin Monerjan
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
17f35f6769d568dadf1181f63670d7717e20726c
Parents:
8e9b2432dca37f7a38575552109279486869c89e
Message:
static facet slEnd
Possibility for deletion in enqueue2. Yet disabled
Fixed memleak in replaceDouble...
poly strPoly into inner loop in readConeFromFile
getRef2BaseRing (for lpreparelist)
delete gcDel //ed as workaround for crashes with option 0


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

Legend:

Unmodified
Added
Removed
  • kernel/gfan.cc

    r8e9b24 r147167f  
    8989using namespace std;
    9090
     91#define ivIsStrictlyPositive iv64isStrictlyPositive
     92
    9193/**
    9294*\brief Class facet
     
    186188{
    187189        facet *res = new facet();
    188         res->fNormal=(intvec* const)f.fNormal;
     190        res->fNormal=(intvec * const)f.fNormal;
    189191        res->UCN=f.UCN;
    190192        res->isFlippable=f.isFlippable;
     
    194196        res->next=NULL;
    195197        res->flipGB=NULL;
     198        res->flipRing=NULL;
    196199        return res;
    197200}
     
    199202void facet::shallowDelete()
    200203{
     204#ifdef gfan_DEBUG
     205        cout << "shallowdel@UCN " << this->getUCN() << endl;
     206#endif
    201207        this->fNormal=NULL;
    202         this->UCN=0;
     208//      this->UCN=0;
    203209        this->interiorPoint=NULL;
    204210        this->codim2Ptr=NULL;
     
    206212        this->next=NULL;
    207213        this->flipGB=NULL;
     214        this->flipRing=NULL;
     215        assert(this->fNormal==NULL);   
    208216//      delete(this);
    209217}
     
    212220facet::~facet()
    213221{
     222#ifdef gfan_DEBUG
     223        cout << "~facet@UCN " << this->getUCN() << endl;
     224#endif
    214225        if(this->fNormal!=NULL)
    215226                delete this->fNormal;
     
    581592        this->prev=NULL;
    582593        this->facetPtr=NULL;                   
    583 //      this->rootRing=r;
    584594        this->inputIdeal=I;
    585595        this->baseRing=currRing;
     
    621631#ifndef NDEBUG
    622632  #if SIZEOF_LONG==8
    623         if(this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb))
     633        if( ( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb) ) && (this->gcBasis!=NULL) )
    624634                idDelete((ideal*)&this->gcBasis);
    625635  #elif SIZEOF_LONG!=8
     
    839849{
    840850        return rCopy(this->baseRing);
     851}
     852
     853inline ring gcone::getRef2BaseRing()
     854{
     855        return this->baseRing;
    841856}
    842857
     
    14561471                        mpq_set(colSum[jj],tmp);
    14571472                        mpq_clear(tmp);
     1473                        mpq_clear(sum);
    14581474                }
    14591475                mpz_t den; mpz_init(den);
     
    20982114        gettimeofday(&start, 0);
    20992115#endif
    2100         /*const*/ intvec *fNormal;
    2101         fNormal = f/*->getRef2FacetNormal();*/->getFacetNormal();       //read this->fNormal;
     2116        const intvec *fNormal;
     2117        fNormal = f->getRef2FacetNormal();/*->getFacetNormal();*/       //read this->fNormal;
    21022118#ifdef gfan_DEBUG
    21032119        std::cout << "flipping UCN " << this->getUCN();
     
    21082124#endif
    21092125        if(this->getUCN() != f->getUCN())
    2110         {
     2126        {       cout << this->getUCN() << " vs " << f->getUCN() << endl;
    21112127                WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
    21122128                exit(-1);
     
    21552171                rComplete(tmpRing);*/
    21562172        }
    2157         delete fNormal;
     2173//      delete fNormal; //NOTE Do not delete when using getRef2FacetNormal();
    21582174        rChangeCurrRing(tmpRing);       
    21592175        //Now currRing should have (a(),a(),dp,C)               
     
    23252341        for (int ii=0;ii<size;ii++)
    23262342        {
    2327 //              poly temp1=pInit();
    2328 //              poly temp2=pInit();
    2329                 poly temp3=pInit();//polys to temporarily store values for pSub
     2343//              poly temp1;//=pInit();
     2344//              poly temp2;//=pInit();
     2345                poly temp3;//=pInit();//polys to temporarily store values for pSub
    23302346//              res->m[ii]=pCopy(kNF(G, NULL,H->m[ii],0,0));
    2331 //              temp1=pCopy(H->m[ii]);
     2347//              temp1=pCopy(H->m[ii]);//TRY
    23322348//              temp2=pCopy(res->m[ii]);
    23332349                //NOTE if gfanHeuristic=0 (sic!) this results in dPolyErrors - mon from wrong ring
    2334 //              temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));
    2335 //              temp3=pSub(temp1, temp2);
    2336                 temp3=pSub(pCopy(H->m[ii]),pCopy(kNF(G,NULL,H->m[ii],0,0)));
     2350//              temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));//TRY
     2351//              temp3=pSub(temp1, temp2);//TRY
     2352                temp3=pSub(pCopy(H->m[ii]),pCopy(kNF(G,NULL,H->m[ii],0,0)));//NOTRY
    23372353                res->m[ii]=pCopy(temp3);
    23382354                //res->m[ii]=pSub(temp1,temp2); //buggy         
    23392355                //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);
    2340 //              pDelete(&temp1);
     2356//              pDelete(&temp1);//TRY
    23412357//              pDelete(&temp2);
    2342                 pDelete(&temp3); //NOTE does not work, so commented out
     2358                pDelete(&temp3);
    23432359        }
    23442360        return res;
     
    26172633*
    26182634* Used by noRevS
     2635*NOTE no longer used nor maintained. MM Mar 9, 2010
    26192636*/
    26202637inline void gcone::interiorPoint2()
     
    28712888/** \brief Check for equality of two intvecs
    28722889 */
    2873 inline bool gcone::ivAreEqual(intvec &a, intvec &b)
     2890inline bool gcone::ivAreEqual(const intvec &a, const intvec &b)
    28742891{
    28752892        bool res=TRUE;
     
    31933210                        rDelete(fAct->flipRing);
    31943211                       
    3195                         gcTmp->getConeNormals(gcTmp->gcBasis, FALSE);   
     3212                        gcTmp->getConeNormals(gcTmp->gcBasis, FALSE);   //TODO FALSE is default, so should not be needed here
    31963213//                      gcTmp->getCodim2Normals(*gcTmp);
    31973214                        gcTmp->getExtremalRays(*gcTmp);
     
    33073324 *
    33083325 * We compute the lcm of the denominators and multiply with this to get integer values.
    3309  * If the gcd of the nominators > 1 we divide by the gcd => primitive vector
     3326 * If the gcd of the nominators > 1 we divide by the gcd => primitive vector.
     3327 * Expects a new intvec as 3rd parameter
    33103328 * \param dd_MatrixPtr,intvec
    33113329 */
     
    36633681        facet *slAct;   //called with f=SearchListRoot
    36643682        slAct = f;
    3665         facet *slEnd;   //Pointer to end of SLA
    3666         slEnd = f;
     3683        static facet *slEnd;    //Pointer to end of SLA
     3684        if(slEnd==NULL)
     3685                slEnd = f;
    36673686       
    36683687        facet *fAct;
     
    36813700                if(fAct->isFlippable)
    36823701                {
     3702                        facet *fDeleteMarker=NULL;
    36833703                        slAct = slHead;
    36843704                        if(slAct==NULL)
     
    37143734                                if(areEqual2(fAct,slAct))
    37153735                                {
    3716                                         facet *marker=slAct;
     3736                                        fDeleteMarker=slAct;
    37173737                                        if(slAct==slHead)
    37183738                                        {                                               
     
    37343754                                        gcone::lengthOfSearchList--;
    37353755#ifdef gfan_DEBUG
    3736                                         cout << "Removing (";fAct->fNormal->show(1,1);cout << ") from list" << endl;
    3737 #endif
    3738 //                                      marker->shallowDelete();
     3756cout << "Removing (";fAct->fNormal->show(1,1);cout << ") from list" << endl;
     3757#endif
     3758                                        fDeleteMarker->shallowDelete();//Sets everything to NULL
    37393759//                                      delete(marker);
    37403760                                        break;
     
    37513771                        }
    37523772                        fAct = fAct->next;
     3773//                      if(fDeleteMarker!=NULL)
     3774//                      {
     3775//                              delete fDeleteMarker;
     3776//                              fDeleteMarker=NULL;
     3777//                      }
    37533778                }
    37543779                else
     
    38113836        this->baseRing=rCopy(replacementRing);
    38123837        this->gcBasis=idCopy(temporaryGroebnerBasis);
     3838        //FIXME idDelete & rDelete!!! MEMLEAK
    38133839        /*And back to where we came from*/
    3814         rChangeCurrRing(srcRing);                       
     3840        rChangeCurrRing(srcRing);
     3841        idDelete( (ideal*)&temporaryGroebnerBasis );
     3842        rDelete(replacementRing);       
    38153843}
    38163844
     
    41024130                                //check until first occurance of + or -
    41034131                                //data or c_str
    4104                                 poly strPoly=pInit();//Ought to be inside the while loop, but that will eat your memory
    4105                                 poly resPoly=pInit();   //The poly to be read in                                                       
     4132//                              poly strPoly;//=pInit();//Ought to be inside the while loop, but that will eat your memory
     4133                                poly resPoly=pInit();   //The poly to be read in               
    41064134                                while(!line.empty())
    41074135                                {
    4108 //                                      poly strPoly;//=pInit();
     4136                                        poly strPoly;//=pInit();
    41094137                                        number nCoeff=nInit(1);
    41104138                                        number nCoeffNom=nInit(1);
     
    41534181                                                                                               
    41544182                                        }
    4155                                         const char* monom = strMonom.c_str();
     4183                                        const char* monom = strMonom.c_str();                                   
    41564184                                               
    41574185                                        p_Read(monom,strPoly,currRing); //strPoly:=monom                               
     
    41804208                                                resPoly=pCopy(strPoly);                                                 
    41814209                                        else
    4182                                                 resPoly=pAdd(resPoly,strPoly);
     4210                                                resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args
    41834211                                        nDelete(&nCoeff);
    41844212                                        nDelete(&nCoeffNom);
     
    41884216                                gc->gcBasis->m[jj]=pCopy(resPoly);
    41894217                                pDelete(&resPoly);      //reset
    4190 //                              pDelete(&strPoly);      //NOTE Crashes                         
     4218//                              pDelete(&strPoly);      //NOTE Crashes - already deleted by pAdd                               
    41914219                        }
    41924220                        break;
     
    42324260                {
    42334261                        gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
    4234                         rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak?
    4235                 }               
     4262//                      rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak?
     4263                }
     4264                rChangeCurrRing(gcAct->getRef2BaseRing());     
    42364265                res->m[ii].rtyp=LIST_CMD;
    42374266                lists l=(lists)omAllocBin(slists_bin);
     
    42514280//              rChangeCurrRing(tmpRing);
    42524281//              l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing());
    4253                 l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak?
     4282//              l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak?
     4283                l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getRef2BaseRing());
    42544284//              rChangeCurrRing(saveRing);
    42554285
     
    43754405       
    43764406                ring inputRing=currRing;        // The ring the user entered
    4377                 ring rootRing;                  // The ring associated to the target ordering
     4407//              ring rootRing;                  // The ring associated to the target ordering
    43784408
    43794409                dd_set_global_constants();
     
    44004430        #endif
    44014431                        if(gcAct->isMonomial(gcAct->gcBasis))
    4402                         {
     4432                        {//FIXME
    44034433                                WerrorS("Monomial input - terminating");
    44044434                                lResList->Init(1);
     
    44284458                                gcDel = gcAct;
    44294459                                gcAct = gcAct->next;
    4430                                 delete gcDel;
     4460//                              delete gcDel;
    44314461                        }
    44324462                }//method==noRevS
  • kernel/gfan.h

    r8e9b24 r147167f  
    134134{
    135135        private:               
    136 //              ring rootRing;          //good to know this -> generic walk
     136                //ring rootRing;                //good to know this -> generic walk
    137137                ideal inputIdeal;       //the original
    138138                ring baseRing;          //the basering of the cone                             
     
    204204                inline int getCounter();
    205205                inline ring getBaseRing();
     206                inline ring getRef2BaseRing();
    206207                inline void setIntPoint(intvec *iv);
    207208                inline intvec *getIntPoint(bool shallow=FALSE);
     
    222223//              inline int dotProduct(const intvec* a, const intvec *b);
    223224//              inline bool isParallel(const intvec* a, const intvec* b);
    224                 inline bool ivAreEqual(intvec &a, intvec &b);
     225                inline bool ivAreEqual(const intvec &a, const intvec &b);
    225226                inline bool areEqual( facet *f,  facet *g);
    226227                inline bool areEqual2(facet* f, facet *g);
Note: See TracChangeset for help on using the changeset viewer.