Changeset 63a2f8 in git
- Timestamp:
- Mar 26, 2010, 2:21:53 PM (13 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 25d15e8446fc517a57510738439e5916bed4071e
- Parents:
- b78b73c2edf5c1cdd8c86014f84cb640bf73f3df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
rb78b73 r63a2f8 76 76 //NOTE Defining this will slow things down! 77 77 //Only good for very coarse profiling 78 #define gfanp78 //#define gfanp 79 79 #ifdef gfanp 80 80 #include <sys/time.h> … … 201 201 { 202 202 #ifdef gfan_DEBUG 203 printf("shallowdel@UCN %i\n", this->getUCN());203 // printf("shallowdel@UCN %i\n", this->getUCN()); 204 204 #endif 205 205 this->fNormal=NULL; … … 219 219 { 220 220 #ifdef gfan_DEBUG 221 printf("~facet@UCN %i\n",this->getUCN());221 // printf("~facet@UCN %i\n",this->getUCN()); 222 222 #endif 223 223 if(this->fNormal!=NULL) … … 226 226 delete this->interiorPoint; 227 227 /* Cleanup the codim2-structure */ 228 if(this->codim==2) 229 // if(this->codim2Ptr!=NULL) 230 { 231 facet *codim2Ptr; 232 codim2Ptr = this->codim2Ptr; 233 while(codim2Ptr!=NULL) 234 { 235 if(codim2Ptr->fNormal!=NULL) 236 { 237 delete codim2Ptr->fNormal;//NOTE Do not want this anymore since the rays are now in gcone! 238 codim2Ptr = codim2Ptr->next; 239 } 240 } 241 // delete this->codim2Ptr; 242 } 228 // if(this->codim==2) 229 // { 230 // facet *codim2Ptr; 231 // codim2Ptr = this->codim2Ptr; 232 // while(codim2Ptr!=NULL) 233 // { 234 // if(codim2Ptr->fNormal!=NULL) 235 // { 236 // delete codim2Ptr->fNormal;//NOTE Do not want this anymore since the rays are now in gcone! 237 // codim2Ptr = codim2Ptr->next; 238 // } 239 // } 240 // } 243 241 //The rays are stored in the cone! 244 // if(this->codim2Ptr!=NULL)245 // delete this->codim2Ptr;246 242 if(this->flipGB!=NULL) 247 243 idDelete((ideal *)&this->flipGB); 248 if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)244 // if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb) 249 245 // rDelete(this->flipRing); //See vol II/134 250 246 // this->flipRing=NULL; … … 735 731 codim2Act = codim2Act->next; 736 732 } 737 printf("UCN = %i ",fAct->getUCN());733 printf("UCN = %i\n",fAct->getUCN()); 738 734 fAct = fAct->next; 739 735 } … … 807 803 { 808 804 return rCopy(this->baseRing); 805 } 806 807 inline void gcone::setBaseRing(ring r) 808 { 809 this->baseRing=rCopy(r); 809 810 } 810 811 … … 863 864 //simpler version of storing expvect diffs 864 865 int *leadexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int)); 865 // int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));866 866 pGetExpV(aktpoly,leadexpv); 867 while(pNext(aktpoly)!=NULL) 868 { 869 aktpoly=pNext(aktpoly); 867 poly pNextTerm=aktpoly; 868 while(pNext(pNextTerm)/*pNext(aktpoly)*/!=NULL) 869 { 870 pNextTerm/*aktpoly*/=pNext(pNextTerm); 870 871 int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int)); 871 pGetExpV( aktpoly,tailexpv);872 pGetExpV(pNextTerm,tailexpv); 872 873 for(int kk=1;kk<=this->numVars;kk++) 873 874 { … … 924 925 if(P->p!=NULL) //spoly non zero=? 925 926 { 926 poly p =pInit();927 poly q =pInit();927 poly p;//=pInit(); NOTE Evil memleak if pInit is used 928 poly q;//=pInit(); 928 929 p=pCopy(P->p); 929 930 q=pHead(p); //Monomial q … … 932 933 while(p!=NULL) 933 934 { 934 q=pHead(p); 935 // unsigned long sevSpoly=pGetShortExpVector(q); 936 // unsigned long not_sevL; 935 q=pHead(p); 937 936 for(int ll=0;ll<IDELEMS(L);ll++) 938 937 { 939 // not_sevL=~pGetShortExpVector(L->m[ll]);//940 //if(!(sevSpoly & not_sevL) && pLmDivisibleBy(L->m[ll],q) )//i.e. spoly is in L941 938 if(pLmEqual(L->m[ll],q) || pDivisibleBy(L->m[ll],q)) 942 939 { … … 1507 1504 } 1508 1505 } 1509 assert(iv64isStrictlyPositive(ivIntPointOfCone));1506 // assert(iv64isStrictlyPositive(ivIntPointOfCone)); 1510 1507 1511 1508 this->setIntPoint(ivIntPointOfCone); … … 1517 1514 facet *fAct=gc.facetPtr; 1518 1515 //Construct an array to hold the extremal rays of the cone 1519 this->gcRays = (intvec**)omAlloc0(sizeof(intvec*)*P->rowsize); 1516 this->gcRays = (intvec**)omAlloc0(sizeof(intvec*)*P->rowsize); 1520 1517 for(int ii=0;ii<P->rowsize;ii++) 1521 1518 { … … 1524 1521 this->gcRays[ii] = ivCopy(rowvec); 1525 1522 delete rowvec; 1526 } 1523 } 1527 1524 this->numRays=P->rowsize; 1528 1525 //Check which rays belong to which facet … … 3146 3143 Choose a facet from SearchList, flip it and forget the previous cone 3147 3144 We always choose the first facet from SearchList as facet to be flipped 3148 */ 3145 */ 3149 3146 while( (SearchListAct!=NULL))//&& counter<490) 3150 3147 {//NOTE See to it that the cone is only changed after ALL facets have been flipped! 3151 fAct = SearchListAct; 3152 3148 fAct = SearchListAct; 3153 3149 while(fAct!=NULL) 3154 3150 // while( (fAct->getUCN() == fAct->next->getUCN()) ) … … 3158 3154 ring rTmp=rCopy(fAct->flipRing); 3159 3155 // ring rTmp=fAct->flipRing; //segfaults 3160 rComplete(rTmp); 3156 rComplete(rTmp); 3161 3157 rChangeCurrRing(rTmp); 3162 3158 gcone *gcTmp = new gcone::gcone(*gcAct,*fAct);//copy constructor! … … 3171 3167 idDelete((ideal *)&fAct->flipGB); 3172 3168 rDelete(fAct->flipRing); 3173 3169 3174 3170 gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/); //TODO FALSE is default, so should not be needed here 3175 3171 // gcTmp->getCodim2Normals(*gcTmp); 3176 3172 gcTmp->getExtremalRays(*gcTmp); 3177 3178 3173 3179 3174 // //NOTE If flip2 is used we need to get an interior point of gcTmp 3180 3175 // // and replace gcTmp->baseRing with an appropriate ring with only … … 3189 3184 /*add facets to SLA here*/ 3190 3185 #ifdef SHALLOW 3191 SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot); 3186 // printf("fActUCN before enq2: %i\n",fAct->getUCN()); 3187 facet *tmp; tmp=gcTmp->enqueue2(SearchListRoot); 3188 // printf("\nheadUCN=%i\n",tmp->getUCN()); 3189 // printf("fActUCN after enq2: %i\n",fAct->getUCN()); 3190 SearchListRoot=tmp; 3191 // SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot); 3192 3192 #else 3193 3193 SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot); … … 3213 3213 if(fAct->getUCN() == fAct->next->getUCN()) 3214 3214 { 3215 fAct=fAct->next; 3215 printf("Switching UCN from %i to %i\n",fAct->getUCN(),fAct->next->getUCN()); 3216 fAct=fAct->next; 3216 3217 } 3217 3218 else 3219 { 3220 //rDelete(gcAct->baseRing); 3221 // printf("break\n"); 3218 3222 break; 3223 } 3219 3224 // fAct=fAct->next; 3220 3225 }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) ); 3221 3226 //Search for cone with smallest UCN 3222 gcNext = gcHead;3223 3227 #ifndef NDEBUG 3224 3228 #if SIZEOF_LONG==8 //64 bit … … 3264 3268 } 3265 3269 } 3266 //else if(gcNext->getUCN() < SearchListRoot->getUCN() )3267 //{3268 // idDelete( (ideal*)&gcNext->gcBasis ); 3269 // rDelete(gcNext->baseRing); 3270 //}3270 else if(gcNext->getUCN() < SearchListRoot->getUCN() ) 3271 { 3272 idDelete( (ideal*)&gcNext->gcBasis ); 3273 // rDelete(gcNext->baseRing);//TODO Why does this crash? 3274 } 3271 3275 /*else 3272 3276 { … … 3282 3286 } 3283 3287 UCNcounter++; 3284 SearchListAct = SearchListRoot; 3288 SearchListAct = SearchListRoot; 3285 3289 } 3286 3290 printf("\nFound %i cones - terminating\n", counter); … … 3671 3675 if(slAct==NULL) 3672 3676 { 3677 printf("Zero length SLA\n"); 3673 3678 facet *fCopy; 3674 3679 fCopy = fAct; … … 3703 3708 fDeleteMarker=slAct; 3704 3709 if(slAct==slHead) 3705 { 3710 { 3711 // fDeleteMarker=slHead; 3712 // printf("headUCN@enq=%i\n",slHead->getUCN()); 3706 3713 slHead = slAct->next; 3714 // printf("headUCN@enq=%i\n",slHead->getUCN()); 3707 3715 if(slHead!=NULL) 3716 { 3708 3717 slHead->prev = NULL; 3718 } 3719 fDeleteMarker->shallowDelete(); 3720 // delete fDeleteMarker;//NOTE this messes up fAct in noRevS! 3721 // printf("headUCN@enq=%i\n",slHead->getUCN()); 3709 3722 } 3710 3723 else if (slAct==slEnd) … … 3712 3725 slEnd=slEnd->prev; 3713 3726 slEnd->next = NULL; 3727 fDeleteMarker->shallowDelete(); 3728 // delete(fDeleteMarker); 3714 3729 } 3715 3730 else … … 3717 3732 slAct->prev->next = slAct->next; 3718 3733 slAct->next->prev = slAct->prev; 3734 fDeleteMarker->shallowDelete(); 3735 // delete(fDeleteMarker); 3719 3736 } 3720 3737 removalOccured=TRUE; 3721 3738 gcone::lengthOfSearchList--; 3722 3739 #ifdef gfan_DEBUG 3723 printf("Removing (");fAct->fNormal->show(1,1);printf(") from list ");3724 #endif 3725 fDeleteMarker->shallowDelete();//Sets everything to NULL3726 // delete( marker);3727 break; 3740 printf("Removing (");fAct->fNormal->show(1,1);printf(") from list\n"); 3741 #endif 3742 /*fDeleteMarker->shallowDelete();*///Sets everything to NULL 3743 // delete(fDeleteMarker); 3744 break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct 3728 3745 } 3729 slAct = slAct->next; 3746 slAct = slAct->next; 3730 3747 }//while(slAct!=NULL) 3731 3748 if(removalOccured==FALSE) … … 3740 3757 // if(fDeleteMarker!=NULL) 3741 3758 // { 3742 // delete fDeleteMarker; 3759 // fDeleteMarker->shallowDelete(); 3760 // delete(fDeleteMarker); 3743 3761 // fDeleteMarker=NULL; 3744 3762 // } … … 3752 3770 time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec)); 3753 3771 #endif 3772 // printf("headUCN@enq=%i\n",slHead->getUCN()); 3754 3773 return slHead; 3755 3774 } … … 3803 3822 this->baseRing=rCopy(replacementRing); 3804 3823 this->gcBasis=idCopy(temporaryGroebnerBasis); 3805 //FIXME idDelete & rDelete!!! MEMLEAK3824 //FIXME idDelete & rDelete!!! DONE! 3806 3825 /*And back to where we came from*/ 3807 3826 rChangeCurrRing(srcRing); … … 4138 4157 else 4139 4158 resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args 4140 nDelete(&nCoeff);4159 // nDelete(&nCoeff); 4141 4160 nDelete(&nCoeffNom); 4142 4161 nDelete(&nCoeffDenom); … … 4152 4171 { 4153 4172 facet *fAct=gc->facetPtr; 4154 for(int ll=0;ll<this->numFacets;ll++)4173 while(fAct!=NULL) 4155 4174 { 4156 4175 getline(gcInputFile,line); … … 4402 4421 gcAct->noRevS(*gcAct); //Here we go! 4403 4422 //Switch back to the ring the computation was started in 4404 //rChangeCurrRing(inputRing);4423 // rChangeCurrRing(inputRing); 4405 4424 //res=gcAct->gcBasis; 4406 4425 //Below is a workaround, since gcAct->gcBasis gets deleted in noRevS … … 4424 4443 //Simply return an empty list 4425 4444 WerrorS("Ring has non-global ordering.\nThis function requires your current ring to be endowed with a global ordering.\n Now terminating!"); 4445 gcone *gcRoot=new gcone(); 4446 gcone *gcPtr = gcRoot; 4447 for(int ii=0;ii<10000;ii++) 4448 { 4449 gcPtr->setBaseRing(currRing); 4450 facet *fPtr=gcPtr->facetPtr=new facet(); 4451 for(int jj=0;jj<5;jj++) 4452 { 4453 intvec *iv=new intvec(pVariables); 4454 fPtr->setFacetNormal(iv); 4455 delete(iv); 4456 fPtr->next=new facet(); 4457 fPtr=fPtr->next; 4458 } 4459 gcPtr->next=new gcone(); 4460 gcPtr->next->prev=gcPtr; 4461 gcPtr=gcPtr->next; 4462 } 4463 gcPtr=gcRoot; 4464 while(gcPtr!=NULL) 4465 { 4466 gcPtr=gcPtr->next; 4467 // delete(gcPtr->prev); 4468 } 4426 4469 goto pointOfNoReturn; 4427 4470 }
Note: See TracChangeset
for help on using the changeset viewer.