Changeset 147167f in git
- Timestamp:
- Mar 11, 2010, 7:41:13 PM (13 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 17f35f6769d568dadf1181f63670d7717e20726c
- Parents:
- 8e9b2432dca37f7a38575552109279486869c89e
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r8e9b24 r147167f 89 89 using namespace std; 90 90 91 #define ivIsStrictlyPositive iv64isStrictlyPositive 92 91 93 /** 92 94 *\brief Class facet … … 186 188 { 187 189 facet *res = new facet(); 188 res->fNormal=(intvec * const)f.fNormal;190 res->fNormal=(intvec * const)f.fNormal; 189 191 res->UCN=f.UCN; 190 192 res->isFlippable=f.isFlippable; … … 194 196 res->next=NULL; 195 197 res->flipGB=NULL; 198 res->flipRing=NULL; 196 199 return res; 197 200 } … … 199 202 void facet::shallowDelete() 200 203 { 204 #ifdef gfan_DEBUG 205 cout << "shallowdel@UCN " << this->getUCN() << endl; 206 #endif 201 207 this->fNormal=NULL; 202 this->UCN=0;208 // this->UCN=0; 203 209 this->interiorPoint=NULL; 204 210 this->codim2Ptr=NULL; … … 206 212 this->next=NULL; 207 213 this->flipGB=NULL; 214 this->flipRing=NULL; 215 assert(this->fNormal==NULL); 208 216 // delete(this); 209 217 } … … 212 220 facet::~facet() 213 221 { 222 #ifdef gfan_DEBUG 223 cout << "~facet@UCN " << this->getUCN() << endl; 224 #endif 214 225 if(this->fNormal!=NULL) 215 226 delete this->fNormal; … … 581 592 this->prev=NULL; 582 593 this->facetPtr=NULL; 583 // this->rootRing=r;584 594 this->inputIdeal=I; 585 595 this->baseRing=currRing; … … 621 631 #ifndef NDEBUG 622 632 #if SIZEOF_LONG==8 623 if( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb))633 if( ( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb) ) && (this->gcBasis!=NULL) ) 624 634 idDelete((ideal*)&this->gcBasis); 625 635 #elif SIZEOF_LONG!=8 … … 839 849 { 840 850 return rCopy(this->baseRing); 851 } 852 853 inline ring gcone::getRef2BaseRing() 854 { 855 return this->baseRing; 841 856 } 842 857 … … 1456 1471 mpq_set(colSum[jj],tmp); 1457 1472 mpq_clear(tmp); 1473 mpq_clear(sum); 1458 1474 } 1459 1475 mpz_t den; mpz_init(den); … … 2098 2114 gettimeofday(&start, 0); 2099 2115 #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; 2102 2118 #ifdef gfan_DEBUG 2103 2119 std::cout << "flipping UCN " << this->getUCN(); … … 2108 2124 #endif 2109 2125 if(this->getUCN() != f->getUCN()) 2110 { 2126 { cout << this->getUCN() << " vs " << f->getUCN() << endl; 2111 2127 WerrorS("Uh oh... Trying to flip over facet with incompatible UCN"); 2112 2128 exit(-1); … … 2155 2171 rComplete(tmpRing);*/ 2156 2172 } 2157 delete fNormal; 2173 // delete fNormal; //NOTE Do not delete when using getRef2FacetNormal(); 2158 2174 rChangeCurrRing(tmpRing); 2159 2175 //Now currRing should have (a(),a(),dp,C) … … 2325 2341 for (int ii=0;ii<size;ii++) 2326 2342 { 2327 // poly temp1 =pInit();2328 // poly temp2 =pInit();2329 poly temp3 =pInit();//polys to temporarily store values for pSub2343 // poly temp1;//=pInit(); 2344 // poly temp2;//=pInit(); 2345 poly temp3;//=pInit();//polys to temporarily store values for pSub 2330 2346 // 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 2332 2348 // temp2=pCopy(res->m[ii]); 2333 2349 //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 2337 2353 res->m[ii]=pCopy(temp3); 2338 2354 //res->m[ii]=pSub(temp1,temp2); //buggy 2339 2355 //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]); 2340 // pDelete(&temp1); 2356 // pDelete(&temp1);//TRY 2341 2357 // pDelete(&temp2); 2342 pDelete(&temp3); //NOTE does not work, so commented out2358 pDelete(&temp3); 2343 2359 } 2344 2360 return res; … … 2617 2633 * 2618 2634 * Used by noRevS 2635 *NOTE no longer used nor maintained. MM Mar 9, 2010 2619 2636 */ 2620 2637 inline void gcone::interiorPoint2() … … 2871 2888 /** \brief Check for equality of two intvecs 2872 2889 */ 2873 inline bool gcone::ivAreEqual( intvec &a,intvec &b)2890 inline bool gcone::ivAreEqual(const intvec &a, const intvec &b) 2874 2891 { 2875 2892 bool res=TRUE; … … 3193 3210 rDelete(fAct->flipRing); 3194 3211 3195 gcTmp->getConeNormals(gcTmp->gcBasis, FALSE); 3212 gcTmp->getConeNormals(gcTmp->gcBasis, FALSE); //TODO FALSE is default, so should not be needed here 3196 3213 // gcTmp->getCodim2Normals(*gcTmp); 3197 3214 gcTmp->getExtremalRays(*gcTmp); … … 3307 3324 * 3308 3325 * 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 3310 3328 * \param dd_MatrixPtr,intvec 3311 3329 */ … … 3663 3681 facet *slAct; //called with f=SearchListRoot 3664 3682 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; 3667 3686 3668 3687 facet *fAct; … … 3681 3700 if(fAct->isFlippable) 3682 3701 { 3702 facet *fDeleteMarker=NULL; 3683 3703 slAct = slHead; 3684 3704 if(slAct==NULL) … … 3714 3734 if(areEqual2(fAct,slAct)) 3715 3735 { 3716 f acet *marker=slAct;3736 fDeleteMarker=slAct; 3717 3737 if(slAct==slHead) 3718 3738 { … … 3734 3754 gcone::lengthOfSearchList--; 3735 3755 #ifdef gfan_DEBUG 3736 3737 #endif 3738 // marker->shallowDelete(); 3756 cout << "Removing (";fAct->fNormal->show(1,1);cout << ") from list" << endl; 3757 #endif 3758 fDeleteMarker->shallowDelete();//Sets everything to NULL 3739 3759 // delete(marker); 3740 3760 break; … … 3751 3771 } 3752 3772 fAct = fAct->next; 3773 // if(fDeleteMarker!=NULL) 3774 // { 3775 // delete fDeleteMarker; 3776 // fDeleteMarker=NULL; 3777 // } 3753 3778 } 3754 3779 else … … 3811 3836 this->baseRing=rCopy(replacementRing); 3812 3837 this->gcBasis=idCopy(temporaryGroebnerBasis); 3838 //FIXME idDelete & rDelete!!! MEMLEAK 3813 3839 /*And back to where we came from*/ 3814 rChangeCurrRing(srcRing); 3840 rChangeCurrRing(srcRing); 3841 idDelete( (ideal*)&temporaryGroebnerBasis ); 3842 rDelete(replacementRing); 3815 3843 } 3816 3844 … … 4102 4130 //check until first occurance of + or - 4103 4131 //data or c_str 4104 poly strPoly=pInit();//Ought to be inside the while loop, but that will eat your memory4105 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 4106 4134 while(!line.empty()) 4107 4135 { 4108 //poly strPoly;//=pInit();4136 poly strPoly;//=pInit(); 4109 4137 number nCoeff=nInit(1); 4110 4138 number nCoeffNom=nInit(1); … … 4153 4181 4154 4182 } 4155 const char* monom = strMonom.c_str(); 4183 const char* monom = strMonom.c_str(); 4156 4184 4157 4185 p_Read(monom,strPoly,currRing); //strPoly:=monom … … 4180 4208 resPoly=pCopy(strPoly); 4181 4209 else 4182 resPoly=pAdd(resPoly,strPoly); 4210 resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args 4183 4211 nDelete(&nCoeff); 4184 4212 nDelete(&nCoeffNom); … … 4188 4216 gc->gcBasis->m[jj]=pCopy(resPoly); 4189 4217 pDelete(&resPoly); //reset 4190 // pDelete(&strPoly); //NOTE Crashes 4218 // pDelete(&strPoly); //NOTE Crashes - already deleted by pAdd 4191 4219 } 4192 4220 break; … … 4232 4260 { 4233 4261 gcAct->readConeFromFile(gcAct->getUCN(),gcAct); 4234 rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak? 4235 } 4262 // rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak? 4263 } 4264 rChangeCurrRing(gcAct->getRef2BaseRing()); 4236 4265 res->m[ii].rtyp=LIST_CMD; 4237 4266 lists l=(lists)omAllocBin(slists_bin); … … 4251 4280 // rChangeCurrRing(tmpRing); 4252 4281 // 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()); 4254 4284 // rChangeCurrRing(saveRing); 4255 4285 … … 4375 4405 4376 4406 ring inputRing=currRing; // The ring the user entered 4377 ring rootRing; // The ring associated to the target ordering4407 // ring rootRing; // The ring associated to the target ordering 4378 4408 4379 4409 dd_set_global_constants(); … … 4400 4430 #endif 4401 4431 if(gcAct->isMonomial(gcAct->gcBasis)) 4402 { 4432 {//FIXME 4403 4433 WerrorS("Monomial input - terminating"); 4404 4434 lResList->Init(1); … … 4428 4458 gcDel = gcAct; 4429 4459 gcAct = gcAct->next; 4430 delete gcDel;4460 // delete gcDel; 4431 4461 } 4432 4462 }//method==noRevS -
kernel/gfan.h
r8e9b24 r147167f 134 134 { 135 135 private: 136 //ring rootRing; //good to know this -> generic walk136 //ring rootRing; //good to know this -> generic walk 137 137 ideal inputIdeal; //the original 138 138 ring baseRing; //the basering of the cone … … 204 204 inline int getCounter(); 205 205 inline ring getBaseRing(); 206 inline ring getRef2BaseRing(); 206 207 inline void setIntPoint(intvec *iv); 207 208 inline intvec *getIntPoint(bool shallow=FALSE); … … 222 223 // inline int dotProduct(const intvec* a, const intvec *b); 223 224 // 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); 225 226 inline bool areEqual( facet *f, facet *g); 226 227 inline bool areEqual2(facet* f, facet *g);
Note: See TracChangeset
for help on using the changeset viewer.