Changeset 73809b in git
- Timestamp:
- Mar 6, 2010, 2:36:13 PM (13 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- e6ddbdacf047de338a179b12ccb98096d4f02871
- Parents:
- c57a83edd49526195f04ddf602fca071cafed3b7
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
rc57a83e r73809b 75 75 #endif 76 76 77 //NOTE Defining this will slow things down! 78 //Only good for very coarse profiling 77 79 #define gfanp 78 80 #ifdef gfanp 79 81 #include <sys/time.h> 82 #endif 83 84 #ifndef SHALLOW 85 #define SHALLOW 80 86 #endif 81 87 … … 114 120 * could easily change that by renaming numCodim2Facets to numCodimNminusOneFacets or similar 115 121 */ 116 facet::facet( int const &n)122 facet::facet(const int &n) 117 123 { 118 124 this->fNormal=NULL; … … 144 150 //Needed for flip2 145 151 //NOTE ONLY REFERENCE 146 this->interiorPoint= /*ivCopy(*/f.interiorPoint/*)*/;//only referencing is prolly not the best thing to do in a copy constructor152 this->interiorPoint=ivCopy(f.interiorPoint);//only referencing is prolly not the best thing to do in a copy constructor 147 153 facet* f2Copy; 148 154 f2Copy=f.codim2Ptr; … … 151 157 while(f2Copy!=NULL) 152 158 { 153 if(f2Act==NULL )159 if(f2Act==NULL || f2Act==(facet*)0xfefefefefefefefe) 154 160 { 155 161 f2Act=new facet(2); … … 175 181 176 182 /** \brief Shallow copy constructor for facets 183 * We only need the interior point for equality testing 177 184 */ 178 facet::facet(const facet& f, bool shallow) 179 {} 185 facet* facet::shallowCopy(const facet& f) 186 { 187 facet *res = new facet(); 188 res->fNormal=(intvec* const)f.fNormal; 189 res->UCN=f.UCN; 190 res->isFlippable=f.isFlippable; 191 res->interiorPoint=(intvec * const)f.interiorPoint; 192 res->codim2Ptr=(facet * const)f.codim2Ptr; 193 res->prev=NULL; 194 res->next=NULL; 195 res->flipGB=NULL; 196 return res; 197 } 198 199 void facet::shallowDelete() 200 { 201 this->fNormal=NULL; 202 this->UCN=0; 203 this->interiorPoint=NULL; 204 this->codim2Ptr=NULL; 205 this->prev=NULL; 206 this->next=NULL; 207 this->flipGB=NULL; 208 // delete this; 209 } 180 210 181 211 /** The default destructor */ … … 217 247 return(this->fNormal); 218 248 } 219 220 bool gcone::areEqual2(facet* f, facet *g) 249 250 /** Equality check for facets based on unique interior points*/ 251 inline bool gcone::areEqual2(facet* f, facet *g) 221 252 { 222 253 #ifdef gfanp … … 225 256 gettimeofday(&start, 0); 226 257 #endif 227 bool res = FALSE; 228 const intvec* fNormal; 229 const intvec* gNormal; 230 fNormal = f->getRef2FacetNormal(); 231 gNormal = g->getRef2FacetNormal(); 232 intvec *fNRef=const_cast<intvec*>(fNormal); 233 intvec *gNRef=const_cast<intvec*>(gNormal); 234 if(isParallel(*fNRef,*gNRef)) 235 { 258 bool res = TRUE; 259 // const intvec *fNormal; 260 // const intvec *gNormal; 261 // fNormal = f->getRef2FacetNormal(); 262 // gNormal = g->getRef2FacetNormal(); 263 // intvec *fNRef=const_cast<intvec*>(fNormal); 264 // intvec *gNRef=const_cast<intvec*>(gNormal); 265 /*if(isParallel(fNRef,*gNRef)) 266 { 267 const intvec *fIntP = f->getRef2InteriorPoint(); 268 const intvec *gIntP = g->getRef2InteriorPoint(); 236 269 for(int ii=0;ii<this->numVars;ii++) 237 270 { 238 if( (*f Normal)[ii]!=(*gNormal)[ii] )239 { 240 res= TRUE;271 if( (*fIntP)[ii] != (*gIntP)[ii] ) 272 { 273 res=FALSE; 241 274 break; 242 275 } 243 276 } 244 277 } 245 return res; 278 else 279 res=FALSE;*/ 280 const intvec *fIntP = f->getRef2InteriorPoint(); 281 const intvec *gIntP = g->getRef2InteriorPoint(); 282 for(int ii=0;ii<this->numVars;ii++) 283 { 284 if( (*fIntP)[ii] != (*gIntP)[ii] ) 285 { 286 res=FALSE; 287 break; 288 } 289 } 246 290 #ifdef gfanp 247 291 gettimeofday(&end, 0); 248 292 t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec)); 249 293 #endif 294 return res; 250 295 } 251 296 … … 385 430 // return this->fNormal; 386 431 } 387 432 388 433 /** Method to print the facet normal*/ 389 434 inline void facet::printNormal() … … 456 501 { 457 502 return ivCopy(this->interiorPoint); 458 } 503 } 504 505 inline const intvec *facet::getRef2InteriorPoint() 506 { 507 return (this->interiorPoint); 508 } 459 509 460 510 /** \brief Debugging function … … 565 615 gcone::~gcone() 566 616 { 617 #ifndef NDEBUG 618 #if SIZEOF_LONG==8 619 if(this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb)) 620 idDelete((ideal*)&this->gcBasis); 621 #elif SIZEOF_LONG!=8 622 if(this->gcBasis!=(ideal)0xfbfbfbfb) 623 idDelete((ideal *)&this->gcBasis); 624 #endif 625 #else 567 626 if(this->gcBasis!=NULL) 568 627 idDelete((ideal *)&this->gcBasis); 628 #endif 629 // idDelete((ideal *)&this->gcBasis); 569 630 // if(this->inputIdeal!=NULL) 570 631 // idDelete((ideal *)&this->inputIdeal); … … 589 650 //dd_FreeMatrix(this->ddFacets); 590 651 } 591 652 653 /** Returns the number of cones existing at the time*/ 592 654 inline int gcone::getCounter() 593 655 { … … 603 665 } 604 666 605 /** \brief Return the interior point */ 606 inline intvec *gcone::getIntPoint() 607 { 608 return ivCopy(this->ivIntPt); 667 /** \brief Returns either a physical copy the interior point of a cone or just a reference to it.*/ 668 inline intvec *gcone::getIntPoint(bool shallow) 669 { 670 if(shallow==TRUE) 671 return this->ivIntPt; 672 else 673 return ivCopy(this->ivIntPt); 609 674 } 610 675 … … 762 827 { 763 828 return this->pred; 829 } 830 /** Returns a copy of the this->baseRing */ 831 inline ring gcone::getBaseRing() 832 { 833 return rCopy(this->baseRing); 764 834 } 765 835 … … 796 866 for (int ii=0;ii<IDELEMS(I);ii++) 797 867 { 798 aktpoly=(poly)I->m[ii]; 799 rows=rows+pLength(aktpoly)-1; 868 // aktpoly=(poly)I->m[ii]; 869 // rows=rows+pLength(aktpoly)-1; 870 rows=rows+pLength((poly)I->m[ii])-1; 800 871 } 801 872 … … 1005 1076 for (int kk = 0; kk<ddrows; kk++) 1006 1077 { 1078 int ggT=1;//NOTE Why does (int)mpq_get_d(ddineq->matrix[kk][1]) not work? 1007 1079 intvec *load = new intvec(this->numVars);//intvec to store a single facet normal that will then be stored via setFacetNormal 1008 1080 for (int jj = 1; jj <ddcols; jj++) … … 1010 1082 double foo; 1011 1083 foo = mpq_get_d(ddineq->matrix[kk][jj]); 1012 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 1084 (*load)[jj-1] = (int)foo; //store typecasted entry at pos jj-1 of load 1085 ggT = intgcd(ggT,(int&)foo); 1013 1086 }//for (int jj = 1; jj <ddcols; jj++) 1014 1087 if(ggT>1) 1088 { 1089 for(int ll=0;ll<this->numVars;ll++) 1090 (*load)[ll] /= ggT;//make primitive vector 1091 } 1015 1092 /*Quick'n'dirty hack for flippability. Executed only if gcone::hasHomInput==FALSE 1016 1093 * Otherwise every facet intersects the positive orthant … … 1312 1389 * So we keep pointer tmp to iv and delete(tmp), so there should not occur a 1313 1390 * memleak 1391 * TODO normalization 1314 1392 */ 1315 1393 void gcone::getExtremalRays(const gcone &gc) … … 1318 1396 timeval start, end; 1319 1397 gettimeofday(&start, 0); 1398 timeval poly_start, poly_end; 1399 gettimeofday(&poly_start,0); 1320 1400 #endif 1321 1401 //Add lineality space - dd_LinealitySpace … … 1347 1427 dd_MatrixPtr P; 1348 1428 P=dd_CopyGenerators(ddPolyh); 1349 /*dd_rowset ddlinset,ddredrows; dd_rowindex ddnewpos;1350 dd_MatrixCanonicalize(&P, &ddlinset, &ddredrows, &ddnewpos, &err);*/1351 1429 dd_FreePolyhedra(ddPolyh); 1430 dd_FreeMatrix(ddineq); 1431 #ifdef gfanp 1432 gettimeofday(&poly_end,0); 1433 t_ddPolyh += (poly_end.tv_sec - poly_start.tv_sec + 1e-6*(poly_end.tv_usec - poly_start.tv_usec)); 1434 #endif 1352 1435 /* Compute interior point on the fly*/ 1353 1436 intvec *ivIntPointOfCone = new intvec(this->numVars); 1437 // for(int ii=0;ii<P->rowsize;ii++) 1438 // {} 1354 1439 mpq_t *colSum = new mpq_t[this->numVars]; 1355 1440 int denom[this->numVars];//denominators of colSum 1441 //NOTE TODO need to gcd of rows and factor out! -> makeInt 1356 1442 for(int jj=0;jj<this->numVars;jj++) 1357 1443 { … … 1372 1458 } 1373 1459 //Now compute lcm of denominators of colSum[jj] 1460 //NOTE gcd as well and normalise instantly? 1374 1461 mpz_t kgV; mpz_init(kgV); 1375 1462 mpz_set_str(kgV,"1",10); … … 1389 1476 mpz_clear(den); 1390 1477 mpz_clear(tmp); 1478 int ggT=(*ivIntPointOfCone)[0]; 1391 1479 for (int ii=0;ii<(this->numVars);ii++) 1392 1480 { … … 1396 1484 (*ivIntPointOfCone)[ii]=(int)mpz_get_d(mpq_numref(product)); 1397 1485 mpq_clear(product); 1486 //Compute intgcd 1487 ggT=intgcd(ggT,(*ivIntPointOfCone)[ii]); 1488 } 1489 //Divide out a common gcd > 1 1490 if(ggT>1) 1491 { 1492 for(int ii=0;ii<this->numVars;ii++) 1493 (*ivIntPointOfCone)[ii] /= ggT; 1398 1494 } 1399 1495 mpq_clear(qkgV); 1496 delete [] colSum; 1400 1497 /*For homogeneous input (like Det3,3,5) the int points may be negative. So add a suitable multiple of (1,_,1)*/ 1401 1498 if(hasHomInput==TRUE && iv64isStrictlyPositive(ivIntPointOfCone)==FALSE) … … 1413 1510 } 1414 1511 delete ivOne; 1512 int ggT=(*ivIntPointOfCone)[0]; 1513 for(int ii=0;ii<this->numVars;ii++) 1514 ggT=intgcd( ggT, (*ivIntPointOfCone)[ii]); 1515 if(ggT>1) 1516 { 1517 for(int jj=0;jj<this->numVars;jj++) 1518 (*ivIntPointOfCone)[jj] /= ggT; 1519 } 1415 1520 } 1416 1521 assert(iv64isStrictlyPositive(ivIntPointOfCone)); 1522 1417 1523 this->setIntPoint(ivIntPointOfCone); 1418 1524 delete(ivIntPointOfCone); … … 1430 1536 { 1431 1537 intvec *rowvec = new intvec(this->numVars); 1432 makeInt(P,ii+1,*rowvec);//get an integer entry instead of rational 1538 makeInt(P,ii+1,*rowvec);//get an integer entry instead of rational, rowvec is primitve 1433 1539 if(dotProduct(*fNormal,*rowvec)==0) 1434 1540 { … … 1456 1562 } 1457 1563 delete(rowvec); 1458 } 1564 }//For non-homog input ivIntPointOfFacet should already be >0 here 1565 if(!hasHomInput) {assert(iv64isStrictlyPositive(ivIntPointOfFacet));} 1459 1566 //if we have no strictly pos ray but the input is homogeneous 1460 1567 //then add a suitable multiple of (1,...,1) … … 1477 1584 delete tmp; 1478 1585 } 1479 fAct->setInteriorPoint(ivIntPointOfFacet);1586 //fAct->setInteriorPoint(ivIntPointOfFacet); 1480 1587 delete ivOne; 1481 1588 } 1482 else 1483 fAct->setInteriorPoint(ivIntPointOfFacet); 1589 //else 1590 int ggT=(*ivIntPointOfFacet)[0]; 1591 for(int ii=0;ii<this->numVars;ii++) 1592 ggT=intgcd(ggT,(*ivIntPointOfFacet)[ii]); 1593 if(ggT>1) 1594 { 1595 for(int ii=0;ii<this->numVars;ii++) 1596 (*ivIntPointOfFacet)[ii] /= ggT; 1597 } 1598 fAct->setInteriorPoint(ivIntPointOfFacet); 1484 1599 1485 1600 delete(ivIntPointOfFacet); … … 1637 1752 if( (srcRing->order[0]!=ringorder_a)) 1638 1753 { 1639 intvec *iv = new intvec(this->numVars);1640 iv = ivNeg(fNormal); 1754 intvec *iv;// = new intvec(this->numVars); 1755 iv = ivNeg(fNormal);//ivNeg uses ivCopy -> new 1641 1756 // tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal)); 1642 1757 tmpRing=rCopyAndAddWeight(srcRing,iv); … … 2345 2460 inline int gcone::dotProduct(const intvec &iva, const intvec &ivb) 2346 2461 { 2347 int res=0; 2462 int res=0; 2348 2463 for (int i=0;i<this->numVars;i++) 2349 2464 { … … 2360 2475 */ 2361 2476 inline bool gcone::isParallel(const intvec &a,const intvec &b) 2362 { 2477 { 2478 /*#ifdef gfanp 2479 timeval start, end; 2480 gettimeofday(&start, 0); 2481 #endif*/ 2363 2482 int lhs,rhs; 2364 2483 bool res; … … 2374 2493 res = FALSE; 2375 2494 } 2495 // #ifdef gfanp 2496 // gettimeofday(&end, 0); 2497 // t_isParallel += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec)); 2498 // #endif 2376 2499 return res; 2377 2500 }//bool isParallel … … 2952 3075 } 2953 3076 3077 //NOTE not needed anywhere 2954 3078 ring rCopyAndChangeWeight(ring const &r, intvec *ivw) 2955 3079 { … … 2973 3097 /** \brief Check for equality of two intvecs 2974 3098 */ 2975 inline bool gcone:: areEqual(intvec &a, intvec &b)3099 inline bool gcone::ivAreEqual(intvec &a, intvec &b) 2976 3100 { 2977 3101 bool res=TRUE; … … 3102 3226 } 3103 3227 3104 /** Compute the kernel of a given mxn-matrix */3105 // dd_MatrixPtr gcone::kernel(const dd_MatrixPtr &M)3106 // {3107 // }3108 3228 3109 3229 /** \brief The new method of Markwig and Jensen … … 3154 3274 3155 3275 //Compute unique representation of Facets and rays, i.e. primitive vectors 3156 gcAct->normalize();3276 // gcAct->normalize(); 3157 3277 3158 3278 /* Make a copy of the facet list of first cone … … 3167 3287 if(fAct->isFlippable==TRUE) 3168 3288 { 3289 /*Using shallow copy here*/ 3290 #ifdef SHALLOW 3291 if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable 3292 { 3293 if(SearchListRoot!=NULL) 3294 delete(SearchListRoot); 3295 SearchListRoot = fAct->shallowCopy(*fAct); 3296 SearchListAct = SearchListRoot; //SearchListRoot is already 'new'ed at beginning of method! 3297 } 3298 else 3299 { 3300 SearchListAct->next = fAct->shallowCopy(*fAct); 3301 SearchListAct = SearchListAct->next; 3302 } 3303 fAct=fAct->next; 3304 #else 3305 /*End of shallow copy*/ 3169 3306 intvec *fNormal; 3170 3307 fNormal = fAct->getFacetNormal(); … … 3217 3354 } 3218 3355 fAct = fAct->next; 3219 delete fNormal; 3356 delete fNormal; 3357 #endif 3220 3358 }//if(fAct->isFlippable==TRUE) 3221 3359 else {fAct = fAct->next;} … … 3224 3362 SearchListAct = SearchListRoot; //Set to beginning of list 3225 3363 /*Make SearchList doubly linked*/ 3364 #ifndef NDEBUG 3365 #if SIZEOF_LONG==8 3366 while(SearchListAct!=(facet*)0xfefefefefefefefe && SearchListAct!=NULL) 3367 { 3368 if(SearchListAct->next!=(facet*)0xfefefefefefefefe && SearchListAct->next!=NULL){ 3369 #elif SIZEOF_LONG!=8 3370 while(SearchListAct!=(facet*)0xfefefefe) 3371 { 3372 if(SearchListAct->next!=(facet*)0xfefefefe){ 3373 #endif 3374 #else 3226 3375 while(SearchListAct!=NULL) 3227 3376 { 3228 if(SearchListAct->next!=NULL) 3229 { 3377 if(SearchListAct->next!=NULL){ 3378 #endif 3379 // if(SearchListAct->next!=NULL) 3380 // { 3230 3381 SearchListAct->next->prev = SearchListAct; 3231 3382 } … … 3243 3394 We always choose the first facet from SearchList as facet to be flipped 3244 3395 */ 3245 while( (SearchListAct!=NULL))// && counter<363)3396 while( (SearchListAct!=NULL))//&& counter<490) 3246 3397 {//NOTE See to it that the cone is only changed after ALL facets have been flipped! 3247 3398 fAct = SearchListAct; … … 3271 3422 // gcTmp->getCodim2Normals(*gcTmp); 3272 3423 gcTmp->getExtremalRays(*gcTmp); 3273 gcTmp->normalize();// will be done in g2c3424 // gcTmp->normalize();// will be done in g2c 3274 3425 //gcTmp->ddFacets should not be needed anymore, so 3275 3426 // //NOTE If flip2 is used we need to get an interior point of gcTmp … … 3283 3434 #endif 3284 3435 /*add facets to SLA here*/ 3436 #ifdef SHALLOW 3437 SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot); 3438 #else 3285 3439 SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot); 3440 #endif 3286 3441 if(gfanHeuristic==1) 3287 3442 { … … 3377 3532 /** \brief Make a set of rational vectors into integers 3378 3533 * 3379 * We compute the lcm of the denominators and multiply with this to get integer values. 3534 * We compute the lcm of the denominators and multiply with this to get integer values. 3535 * If the gcd of the nominators > 1 we divide by the gcd => primitive vector 3380 3536 * \param dd_MatrixPtr,intvec 3381 3537 */ … … 3423 3579 3424 3580 // mpq_canonicalize(qkgV); 3581 int ggT=1; 3425 3582 for (int ii=0;ii<(M->colsize)-1;ii++) 3426 3583 { 3427 3584 mpq_mul(res,qkgV,M->matrix[line-1][ii+1]); 3428 3585 n[ii]=(int)mpz_get_d(mpq_numref(res)); 3586 ggT=intgcd(ggT,n[ii]); 3587 } 3588 //Normalization 3589 if(ggT>1) 3590 { 3591 for(int ii=0;ii<this->numVars;ii++) 3592 n[ii] /= ggT; 3429 3593 } 3430 3594 delete [] denom; … … 3541 3705 */ 3542 3706 volatile bool removalOccured=FALSE; 3543 int ctr=0; //encountered equalities in SLA3544 int notParallelCtr=0;3707 // int ctr=0; //encountered equalities in SLA 3708 // int notParallelCtr=0; 3545 3709 // gcone::lengthOfSearchList=1; 3546 3710 while(slEnd->next!=NULL) … … 3555 3719 { 3556 3720 intvec *fNormal=NULL; 3557 fNormal=fAct->getFacetNormal(); 3721 fNormal=fAct->getFacetNormal(); 3558 3722 slAct = slHead; 3559 notParallelCtr=0;3723 //notParallelCtr=0; 3560 3724 /*If slAct==NULL and fAct!=NULL 3561 3725 we just copy all remaining facets into SLA*/ … … 3570 3734 if(slAct==NULL) 3571 3735 { 3572 slAct = new facet(*fCopy );//copy constructor3736 slAct = new facet(*fCopy/*,TRUE*/);//copy constructor 3573 3737 slHead = slAct; 3574 3738 } 3575 3739 else 3576 3740 { 3577 slAct->next = new facet(*fCopy );3741 slAct->next = new facet(*fCopy/*,TRUE*/); 3578 3742 slAct = slAct->next; 3579 3743 } … … 3592 3756 cout << "Checking facet (";fNormal->show(1,1);cout << ") against (";slNormal->show(1,1);cout << ")" << endl; 3593 3757 #endif 3594 if(areEqual(fAct,slAct)) 3595 { 3758 // if( (areEqual(fAct,slAct) && (!areEqual2(fAct,slAct)) )) 3759 // exit(-1); 3760 if(areEqual2(fAct,slAct)) 3761 { 3596 3762 deleteMarker = slAct; 3597 3763 if(slAct==slHead) … … 3648 3814 facet *f2Act; 3649 3815 f2Act = fAct->codim2Ptr; 3650 3816 3651 3817 slEnd->next = new facet(); 3652 3818 slEnd = slEnd->next;//Update slEnd … … 3663 3829 //Better: have slEnd->interiorPoint point to fAct->interiorPoint 3664 3830 //NOTE Only reference -> c.f. copy constructor 3665 //slEnd->setInteriorPoint(fAct->getInteriorPoint());3831 //slEnd->setInteriorPoint(fAct->getInteriorPoint()); 3666 3832 slEnd->interiorPoint = fAct->interiorPoint; 3667 3833 slEnd->prev = marker; 3668 3834 //Copy codim2-facets 3669 //intvec *f2Normal=new intvec(this->numVars);3835 //intvec *f2Normal=new intvec(this->numVars); 3670 3836 while(f2Act!=NULL) 3671 3837 { … … 3707 3873 return slHead; 3708 3874 }//addC2N 3875 3876 /** Try using shallow copies*/ 3877 facet * gcone::enqueue2(facet *f) 3878 { 3879 assert(f!=NULL); 3880 #ifdef gfanp 3881 timeval start, end; 3882 gettimeofday(&start, 0); 3883 #endif 3884 facet *slHead; 3885 slHead = f; 3886 facet *slAct; //called with f=SearchListRoot 3887 slAct = f; 3888 facet *slEnd; //Pointer to end of SLA 3889 slEnd = f; 3890 3891 facet *fAct; 3892 fAct = this->facetPtr;//New facets to compare 3893 facet *codim2Act; 3894 codim2Act = this->facetPtr->codim2Ptr; 3895 // facet *sl2Act; 3896 // sl2Act = f->codim2Ptr; 3897 volatile bool removalOccured=FALSE; 3898 while(slEnd->next!=NULL) 3899 { 3900 slEnd=slEnd->next; 3901 } 3902 while(fAct!=NULL) 3903 { 3904 if(fAct->isFlippable) 3905 { 3906 slAct = slHead; 3907 if(slAct==NULL) 3908 { 3909 facet *fCopy; 3910 fCopy = fAct; 3911 while(fCopy!=NULL) 3912 { 3913 if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable 3914 { 3915 if(slAct==NULL) 3916 { 3917 slAct = slAct->shallowCopy(*fCopy);//shallow copy constructor 3918 slHead = slAct; 3919 } 3920 else 3921 { 3922 slAct->next = slAct->shallowCopy(*fCopy); 3923 slAct = slAct->next; 3924 } 3925 } 3926 fCopy = fCopy->next; 3927 } 3928 break; 3929 } 3930 /*Comparison starts here*/ 3931 while(slAct!=NULL) 3932 { 3933 removalOccured=FALSE; 3934 #ifdef gfan_DEBUG 3935 cout << "Checking facet (";fAct->fNormal->show(1,1);cout << ") against (";slAct->fNormal->show(1,1);cout << ")" << endl; 3936 #endif 3937 if(areEqual2(fAct,slAct)) 3938 { 3939 facet *marker=slAct; 3940 if(slAct==slHead) 3941 { 3942 slHead = slAct->next; 3943 if(slHead!=NULL) 3944 slHead->prev = NULL; 3945 } 3946 else if (slAct==slEnd) 3947 { 3948 slEnd=slEnd->prev; 3949 slEnd->next = NULL; 3950 } 3951 else 3952 { 3953 slAct->prev->next = slAct->next; 3954 slAct->next->prev = slAct->prev; 3955 } 3956 removalOccured=TRUE; 3957 gcone::lengthOfSearchList--; 3958 #ifdef gfan_DEBUG 3959 cout << "Removing (";fAct->fNormal->show(1,1);cout << ") from list" << endl; 3960 #endif 3961 marker->shallowDelete(); 3962 // delete(marker); 3963 break; 3964 } 3965 slAct = slAct->next; 3966 }//while(slAct!=NULL) 3967 if(removalOccured==FALSE) 3968 { 3969 facet *marker=slEnd; 3970 slEnd->next = fAct->shallowCopy(*fAct); 3971 slEnd = slEnd->next; 3972 slEnd->prev=marker; 3973 gcone::lengthOfSearchList++; 3974 } 3975 fAct = fAct->next; 3976 } 3977 else 3978 fAct = fAct->next; 3979 }//while(fAct!=NULL) 3980 3981 #ifdef gfanp 3982 gettimeofday(&end, 0); 3983 time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec)); 3984 #endif 3985 return slHead; 3986 } 3987 3709 3988 /** 3710 3989 * During flip2 every gc->baseRing gets two ringorder_a … … 3758 4037 rChangeCurrRing(srcRing); 3759 4038 } 3760 //A try with the STL3761 facet * gcone::enqueue2(facet *f)3762 {3763 // vector<facet*> searchList;3764 // facet *fAct;3765 // fAct=this->facetPtr;3766 // facet *slAct;3767 // slAct = f;3768 // facet *slHead;3769 // while(fAct!=NULL)3770 // {3771 // if(fAct->isFlippable==TRUE)3772 // {3773 // if(searchList.size()==0)3774 // {3775 // facet *fCopy;3776 // fCopy=fAct;3777 // while(fCopy!=NULL)3778 // {3779 // if(fCopy->isFlippable==TRUE)3780 // searchList.push_back(fCopy);3781 // fCopy=fCopy->next;3782 // }3783 // }3784 // }3785 // }3786 }3787 4039 3788 4040 /** \brief Compute the gcd of two ints 3789 4041 */ 3790 inline int gcone::intgcd(const int a, const intb)4042 inline int gcone::intgcd(const int &a, const int &b) 3791 4043 { 3792 4044 int r, p=a, q=b; … … 3869 4121 3870 4122 ofstream gcOutputFile(filename.c_str()); 4123 assert(gcOutputFile); 3871 4124 facet *fAct; 3872 4125 fAct = gc.facetPtr; … … 4167 4420 } 4168 4421 4169 ring gcone::getBaseRing() 4170 { 4171 return rCopy(this->baseRing); 4172 } 4422 4173 4423 /** \brief Sort the rays of a facet lexicographically 4174 4424 */ … … 4191 4441 * 4192 4442 */ 4193 lists lprepareResult(gcone *gc, int n)4443 lists lprepareResult(gcone *gc, const int n) 4194 4444 { 4195 4445 gcone *gcAct; … … 4205 4455 { 4206 4456 gcAct->readConeFromFile(gcAct->getUCN(),gcAct); 4207 rChangeCurrRing(gcAct->getBaseRing()); 4457 rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak? 4208 4458 } 4209 4459 res->m[ii].rtyp=LIST_CMD; … … 4224 4474 // rChangeCurrRing(tmpRing); 4225 4475 // l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing()); 4226 l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing()); 4476 l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak? 4227 4477 // rChangeCurrRing(saveRing); 4228 4478 4229 4479 l->m[2].rtyp=INTVEC_CMD; 4230 intvec iv=(gcAct->f2M(gcAct,gcAct->facetPtr)); 4480 intvec iv=(gcAct->f2M(gcAct,gcAct->facetPtr));//NOTE memleak? 4231 4481 l->m[2].data=(void*)ivCopy(&iv); 4232 4482 … … 4311 4561 float gcone::time_getCodim2Normals; 4312 4562 float gcone::t_getExtremalRays; 4563 float gcone::t_ddPolyh; 4313 4564 float gcone::time_flip; 4314 4565 float gcone::time_flip2; … … 4322 4573 float gcone::t_mI; 4323 4574 float gcone::t_iP; 4575 float gcone::t_isParallel; 4324 4576 unsigned gcone::parallelButNotEqual=0; 4325 4577 unsigned gcone::numberOfFacetChecks=0; … … 4421 4673 // cout << " t_iP:" << gcone::t_iP << endl; 4422 4674 cout << "t_getExtremalRays:" << gcone::t_getExtremalRays << endl; 4675 cout << " t_ddPolyh:" << gcone::t_ddPolyh << endl; 4423 4676 cout << "t_Flip:" << gcone::time_flip << endl; 4424 4677 cout << " t_markings:" << gcone::t_markings << endl; … … 4431 4684 cout << "t_enqueue:" << gcone::time_enqueue << endl; 4432 4685 cout << " t_areEqual:" <<gcone::t_areEqual << endl; 4686 cout << "t_isParallel:" <<gcone::t_isParallel << endl; 4433 4687 cout << endl; 4434 4688 cout << "Checked " << gcone::numberOfFacetChecks << " Facets" << endl; -
kernel/gfan.h
rc57a83e r73809b 23 23 extern int gfanHeuristic; 24 24 // extern dd_MatrixPtr ddLinealitySpace; 25 #define gfanp 25 26 26 // #ifdef gfanp 27 27 // extern static float time_getConeNormals; … … 75 75 facet *codim2Ptr; //Pointer to (codim-2)-facet. Bit of recursion here ;-) 76 76 int numCodim2Facets; //#of (codim-2)-facets of this facet. Set in getCodim2Normals() 77 unsigned numRays; //Number of spanning rays of the cone 77 78 ring flipRing; //the ring on the other side of the facet 78 unsigned numRays; //Number of spanning rays of the cone79 79 80 /** The default constructor. */ 80 81 facet(); 81 82 /** Constructor for lower dimensional faces*/ 82 facet( int const &n);83 facet(const int &n); 83 84 /** The copy constructor */ 84 85 facet(const facet& f); 85 facet(const facet& f, bool shallow); 86 facet* shallowCopy(const facet& f); 87 void shallowDelete(); 86 88 /** The default destructor */ 87 89 ~facet(); … … 113 115 inline void setInteriorPoint(intvec *iv); 114 116 inline intvec *getInteriorPoint(); 117 inline const intvec *getRef2InteriorPoint(); 115 118 /** \brief Debugging function 116 119 * prints the facet normal an all (codim-2)-facets that belong to it … … 145 148 static float time_getCodim2Normals; 146 149 static float t_getExtremalRays; 150 static float t_ddPolyh; 147 151 static float time_flip; 148 152 static float time_flip2; … … 157 161 static float t_mI; 158 162 static float t_iP; 163 static float t_isParallel; 159 164 static unsigned parallelButNotEqual; 160 165 static unsigned numberOfFacetChecks; … … 196 201 inline ring getBaseRing(); 197 202 inline void setIntPoint(intvec *iv); 198 inline intvec *getIntPoint( );203 inline intvec *getIntPoint(bool shallow=FALSE); 199 204 inline void showIntPoint(); 200 205 inline void setNumFacets(); … … 213 218 // inline int dotProduct(const intvec* a, const intvec *b); 214 219 // inline bool isParallel(const intvec* a, const intvec* b); 215 inline bool areEqual(intvec &a, intvec &b);220 inline bool ivAreEqual(intvec &a, intvec &b); 216 221 inline bool areEqual( facet *f, facet *g); 217 222 inline bool areEqual2(facet* f, facet *g); 218 inline int intgcd( int a, intb);223 inline int intgcd(const int &a, const int &b); 219 224 inline void writeConeToFile(const gcone &gc, bool usingIntPoints=FALSE); 220 225 inline void readConeFromFile(int gcNum, gcone *gc); … … 252 257 friend class facet; 253 258 }; 254 lists lprepareResult(gcone *gc, int n);259 lists lprepareResult(gcone *gc, const int n); 255 260 // bool iv64isStrictlyPositive(intvec *); 256 261 #endif
Note: See TracChangeset
for help on using the changeset viewer.