Changeset 551009 in git
- Timestamp:
- Feb 1, 2015, 2:29:36 PM (9 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 670e639535c5bd70580255e59bdb06627c71b9f1
- Parents:
- ff48aac293b5ce716bc796167bee1af9044d6942
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-01 14:29:36+01:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:06+01:00
- Location:
- Singular/dyn_modules/gfanlib
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/adjustWeights.cc
rff48aa r551009 2 2 #include <kernel/mod2.h> 3 3 4 static bool checkForNonPositiveEntries(const gfan::ZVector w)4 static bool checkForNonPositiveEntries(const gfan::ZVector &w) 5 5 { 6 6 for (unsigned i=0; i<w.size(); i++) … … 16 16 } 17 17 18 static bool checkForNonPositiveLaterEntries(const gfan::ZVector w)18 static bool checkForNonPositiveLaterEntries(const gfan::ZVector &w) 19 19 { 20 20 // if (w[0].sign()<0) … … 42 42 * if and only if it is homogeneous with respect to w. 43 43 **/ 44 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector w)44 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w) 45 45 { 46 46 /* find the smallest entry min of w */ … … 60 60 } 61 61 62 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector w)62 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w) 63 63 { 64 64 /* find the biggest entry max of w … … 81 81 * w containing only positive weights 82 82 **/ 83 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVectorw)83 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w) 84 84 { 85 85 assume(checkForNonPositiveEntries(w)); … … 107 107 } 108 108 109 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVectorw)109 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w) 110 110 { 111 111 // assume(checkForNonPositiveLaterEntries(w)); -
Singular/dyn_modules/gfanlib/adjustWeights.h
rff48aa r551009 4 4 #include <gfanlib/gfanlib_vector.h> 5 5 6 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector w);7 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector w);8 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVectorw);9 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVectorw);6 gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w); 7 gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w); 8 gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w); 9 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w); 10 10 11 11 #endif -
Singular/dyn_modules/gfanlib/bbcone.cc
rff48aa r551009 1618 1618 1619 1619 1620 BOOLEAN memleaktest(leftv res, leftv args) 1621 { 1622 bigintmat* ineq = NULL; 1623 if (args->Typ() == INTMAT_CMD) 1624 { 1625 intvec* ineq0 = (intvec*) args->Data(); 1626 ineq = iv2bim(ineq0,coeffs_BIGINT); 1627 } 1628 else 1629 ineq = (bigintmat*) args->Data(); 1630 gfan::ZMatrix* zm = bigintmatToZMatrix(ineq); 1631 gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth())); 1632 delete zm; 1633 if (args->Typ() == INTMAT_CMD) 1634 delete ineq; 1635 res->rtyp = coneID; 1636 res->data = (void*) zc; 1637 return FALSE; 1620 /*** 1621 * Computes a relative interior point for each facet of zc 1622 **/ 1623 gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc) 1624 { 1625 gfan::ZMatrix inequalities = zc.getFacets(); 1626 gfan::ZMatrix equations = zc.getImpliedEquations(); 1627 int r = inequalities.getHeight(); 1628 int c = inequalities.getWidth(); 1629 1630 /* our cone has r facets, if r==0 return empty matrices */ 1631 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c); 1632 if (r==0) return relativeInteriorPoints; 1633 1634 /* next we iterate over each of the r facets, 1635 * build the respective cone and add it to the list 1636 * this is the i=0 case */ 1637 gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c); 1638 gfan::ZMatrix newEquations = equations; 1639 newEquations.appendRow(inequalities[0]); 1640 gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations); 1641 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint()); 1642 1643 /* these are the cases i=1,...,r-2 */ 1644 for (int i=1; i<r-1; i++) 1645 { 1646 newInequalities = inequalities.submatrix(0,0,i,c); 1647 newInequalities.append(inequalities.submatrix(i+1,0,r,c)); 1648 newEquations = equations; 1649 newEquations.appendRow(inequalities[i]); 1650 facet = gfan::ZCone(newInequalities,newEquations); 1651 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint()); 1652 } 1653 1654 /* this is the i=r-1 case */ 1655 newInequalities = inequalities.submatrix(0,0,r-1,c); 1656 newEquations = equations; 1657 newEquations.appendRow(inequalities[r-1]); 1658 facet = gfan::ZCone(newInequalities,newEquations); 1659 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint()); 1660 1661 return relativeInteriorPoints; 1638 1662 } 1639 1663 … … 1693 1717 p->iiAddCproc("","listOfFacets",FALSE,listOfFacets); 1694 1718 p->iiAddCproc("","facetContaining",FALSE,facetContaining); 1695 p->iiAddCproc("","memleaktest",FALSE,memleaktest);1696 1719 coneID=setBlackboxStuff(b,"cone"); 1697 1720 } -
Singular/dyn_modules/gfanlib/bbcone.h
rff48aa r551009 20 20 gfan::ZVector randomPoint(const gfan::ZCone* zc); 21 21 gfan::ZCone liftUp(const gfan::ZCone &zc); 22 gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc); 22 23 23 24 #endif -
Singular/dyn_modules/gfanlib/groebnerCone.cc
rff48aa r551009 22 22 #include <bbcone.h> 23 23 24 #ifndef NDEBUG 24 25 static bool checkPolynomialInput(const ideal I, const ring r) 25 26 { … … 56 57 return zc.containsRelatively(p); 57 58 } 59 60 static bool checkOrderingAndWeight(const ideal I, const ring r, const gfan::ZVector w, const tropicalStrategy& currentCase) 61 { 62 groebnerCone sigma(I,r,currentCase); 63 gfan::ZCone zc = sigma.getPolyhedralCone(); 64 return zc.contains(w); 65 } 66 67 bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const 68 { 69 /* check first whether interiorPoint lies on the boundary of the cone */ 70 if (!polyhedralCone.contains(interiorPoint)) 71 { 72 std::cout << "ERROR: interiorPoint is not contained in the Groebner cone!" << std::endl 73 << "cone: " << std::endl 74 << toString(&polyhedralCone) 75 << "interiorPoint:" << std::endl 76 << interiorPoint << std::endl; 77 return false; 78 } 79 if (polyhedralCone.containsRelatively(interiorPoint)) 80 { 81 std::cout << "ERROR: interiorPoint is contained in the interior of the maximal Groebner cone!" << std::endl 82 << "cone: " << std::endl 83 << toString(&polyhedralCone) 84 << "interiorPoint:" << std::endl 85 << interiorPoint << std::endl; 86 return false; 87 } 88 gfan::ZCone hopefullyAFacet = polyhedralCone.faceContaining(interiorPoint); 89 if (hopefullyAFacet.dimension()!=(polyhedralCone.dimension()-1)) 90 { 91 std::cout << "ERROR: interiorPoint is not contained in the interior of a facet!" << std::endl 92 << "cone: " << std::endl 93 << toString(&polyhedralCone) 94 << "interiorPoint:" << std::endl 95 << interiorPoint << std::endl; 96 return false; 97 } 98 /* check whether facet normal points outwards */ 99 gfan::ZCone dual = polyhedralCone.dualCone(); 100 if(dual.contains(facetNormal)) 101 { 102 std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl 103 << "cone: " << std::endl 104 << toString(&polyhedralCone) 105 << "facetNormal:" << std::endl 106 << facetNormal << std::endl; 107 return false; 108 } 109 return true; 110 } 111 #endif //NDEBUG 58 112 59 113 groebnerCone::groebnerCone(): … … 116 170 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 117 171 id_Delete(&redI,polynomialRing); 118 }119 120 static bool checkOrderingAndWeight(const ideal I, const ring r, const gfan::ZVector w, const tropicalStrategy& currentCase)121 {122 groebnerCone sigma(I,r,currentCase);123 gfan::ZCone zc = sigma.getPolyhedralCone();124 return zc.contains(w);125 172 } 126 173 … … 334 381 } 335 382 383 /** 384 * Returns true if Groebner cone contains w, false otherwise 385 */ 386 bool groebnerCone::contains(const gfan::ZVector &w) const 387 { 388 return polyhedralCone.contains(w); 389 } 390 336 391 337 392 /*** … … 362 417 } 363 418 364 bool groebnerCone::checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const365 {366 /* check first whether interiorPoint lies on the boundary of the cone */367 if (!polyhedralCone.contains(interiorPoint))368 {369 std::cout << "ERROR: interiorPoint is not contained in the Groebner cone!" << std::endl370 << "cone: " << std::endl371 << toString(&polyhedralCone)372 << "interiorPoint:" << std::endl373 << interiorPoint << std::endl;374 return false;375 }376 if (polyhedralCone.containsRelatively(interiorPoint))377 {378 std::cout << "ERROR: interiorPoint is contained in the interior of the maximal Groebner cone!" << std::endl379 << "cone: " << std::endl380 << toString(&polyhedralCone)381 << "interiorPoint:" << std::endl382 << interiorPoint << std::endl;383 return false;384 }385 gfan::ZCone hopefullyAFacet = polyhedralCone.faceContaining(interiorPoint);386 if (hopefullyAFacet.dimension()!=(polyhedralCone.dimension()-1))387 {388 std::cout << "ERROR: interiorPoint is not contained in the interior of a facet!" << std::endl389 << "cone: " << std::endl390 << toString(&polyhedralCone)391 << "interiorPoint:" << std::endl392 << interiorPoint << std::endl;393 return false;394 }395 /* check whether facet normal points outwards */396 gfan::ZCone dual = polyhedralCone.dualCone();397 if(dual.contains(facetNormal))398 {399 std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl400 << "cone: " << std::endl401 << toString(&polyhedralCone)402 << "facetNormal:" << std::endl403 << facetNormal << std::endl;404 return false;405 }406 return true;407 }408 409 419 /** 410 420 * Given an interior point on the facet and the outer normal factor on the facet, 411 421 * returns the adjacent groebnerCone sharing that facet 412 422 */ 413 groebnerCone groebnerCone::flipCone(const gfan::ZVector interiorPoint, const gfan::ZVectorfacetNormal) const423 groebnerCone groebnerCone::flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const 414 424 { 415 425 assume(this->checkFlipConeInput(interiorPoint,facetNormal)); … … 508 518 509 519 510 /***511 * Computes a relative interior point for each facet of zc512 **/513 static gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone zc)514 {515 gfan::ZMatrix inequalities = zc.getFacets();516 gfan::ZMatrix equations = zc.getImpliedEquations();517 int r = inequalities.getHeight();518 int c = inequalities.getWidth();519 520 /* our cone has r facets, if r==0 return empty matrices */521 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);522 if (r==0) return relativeInteriorPoints;523 524 /* next we iterate over each of the r facets,525 * build the respective cone and add it to the list526 * this is the i=0 case */527 gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);528 gfan::ZMatrix newEquations = equations;529 newEquations.appendRow(inequalities[0]);530 gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations);531 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());532 533 /* these are the cases i=1,...,r-2 */534 for (int i=1; i<r-1; i++)535 {536 newInequalities = inequalities.submatrix(0,0,i,c);537 newInequalities.append(inequalities.submatrix(i+1,0,r,c));538 newEquations = equations;539 newEquations.appendRow(inequalities[i]);540 facet = gfan::ZCone(newInequalities,newEquations);541 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());542 }543 544 /* this is the i=r-1 case */545 newInequalities = inequalities.submatrix(0,0,r-1,c);546 newEquations = equations;547 newEquations.appendRow(inequalities[r-1]);548 facet = gfan::ZCone(newInequalities,newEquations);549 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint());550 551 return relativeInteriorPoints;552 }553 554 555 520 bool groebnerCone::pointsOutwards(const gfan::ZVector w) const 556 521 { … … 572 537 { 573 538 ideal initialIdeal = initial(polynomialIdeal,polynomialRing,interiorPoints[i]); 574 gfan::ZMatrix ray = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i], *currentStrategy);539 gfan::ZMatrix ray = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],currentStrategy); 575 540 for (int j=0; j<ray.getHeight(); j++) 576 541 if (pointsOutwards(ray[j])) -
Singular/dyn_modules/gfanlib/groebnerCone.h
rff48aa r551009 52 52 groebnerCone& operator=(const groebnerCone& sigma); 53 53 54 void deletePolynomial Ideal()54 void deletePolynomialData() 55 55 { 56 56 assume ((!polynomialIdeal) || (polynomialIdeal && polynomialRing)); 57 57 if (polynomialIdeal) id_Delete(&polynomialIdeal,polynomialRing); 58 }59 60 void deletePolynomialRing()61 {62 assume ((!polynomialIdeal) || (polynomialIdeal && polynomialRing));63 58 if (polynomialRing) rDelete(polynomialRing); 64 polynomial Ring= NULL;59 polynomialIdeal = NULL; 65 60 } 66 61 … … 70 65 gfan::ZVector getInteriorPoint() const { return interiorPoint; }; 71 66 const tropicalStrategy* getTropicalStrategy() const {return currentStrategy; }; 72 73 67 friend struct groebnerCone_compare; 74 68 75 /*** 69 /** 70 * Returns true if Groebner cone contains w, false otherwise 71 */ 72 bool contains(const gfan::ZVector &w) const; 73 74 /** 76 75 * Returns a point in the tropical variety, if the groebnerCone contains one. 77 76 * Returns an empty vector otherwise. 78 * */77 */ 79 78 gfan::ZVector tropicalPoint() const; 80 79 81 /** *80 /** 82 81 * Given an interior point on the facet and the outer normal factor on the facet, 83 82 * returns the adjacent groebnerCone sharing that facet 84 **/ 83 */ 84 groebnerCone flipCone(const gfan::ZVector &interiorPoint, const gfan::ZVector &facetNormal) const; 85 86 /** 87 * Returns a complete list of neighboring Groebner cones. 88 */ 89 groebnerCones groebnerNeighbours() const; 90 91 /** 92 * Returns a complete list of neighboring Groebner cones in the tropical variety. 93 */ 94 groebnerCones tropicalNeighbours() const; 95 96 /** 97 * Debug tools. 98 */ 99 #ifndef NDEBUG 85 100 bool checkFlipConeInput(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const; 86 101 bool pointsOutwards(const gfan::ZVector) const; 87 groebnerCone flipCone(const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const; 88 89 /*** 90 * Returns a complete list of neighboring Groebner cones. 91 **/ 92 groebnerCones groebnerNeighbours() const; 93 94 /*** 95 * Returns a complete list of neighboring Groebner cones in the tropical variety. 96 **/ 97 groebnerCones tropicalNeighbours() const; 102 #endif 98 103 }; 99 104 -
Singular/dyn_modules/gfanlib/startingCone.cc
rff48aa r551009 170 170 tropicalStrategy currentStrategy(I,currRing); 171 171 poly g = I->m[0]; 172 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing, currentStrategy);172 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,¤tStrategy); 173 173 for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++) 174 174 { … … 205 205 tropicalStrategy currentStrategy(I,currRing); 206 206 poly g = I->m[0]; 207 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing, currentStrategy);207 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,¤tStrategy); 208 208 for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++) 209 209 { … … 240 240 tropicalStrategy currentStrategy(I,currRing); 241 241 poly g = I->m[0]; 242 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing, currentStrategy);242 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,¤tStrategy); 243 243 for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++) 244 244 { … … 276 276 tropicalStrategy currentStrategy(I,currRing); 277 277 poly g = I->m[0]; 278 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing, currentStrategy);278 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,¤tStrategy); 279 279 for (std::set<gfan::ZCone>::iterator zc=Tg.begin(); zc!=Tg.end(); zc++) 280 280 { … … 312 312 { 313 313 poly g = I->m[0]; 314 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing, currentStrategy);314 std::set<gfan::ZCone> Tg = tropicalVariety(g,currRing,¤tStrategy); 315 315 if (Tg.empty()) 316 316 { -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
rff48aa r551009 51 51 * and it lies in a Groebner cone of dimension at least rank(E)=dim(A). 52 52 **/ 53 static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector u, const gfan::ZVectorw,54 const gfan::ZMatrix W, const tropicalStrategy¤tStrategy)53 static ring genericlyWeightedOrdering(const ring r, const gfan::ZVector &u, const gfan::ZVector &w, 54 const gfan::ZMatrix &W, const tropicalStrategy* currentStrategy) 55 55 { 56 56 int n = rVar(r); … … 74 74 s->block0[0] = 1; 75 75 s->block1[0] = n; 76 gfan::ZVector uAdjusted = currentStrategy .adjustWeightForHomogeneity(u);76 gfan::ZVector uAdjusted = currentStrategy->adjustWeightForHomogeneity(u); 77 77 s->wvhdl[0] = ZVectorToIntStar(uAdjusted,overflow); 78 78 s->order[1] = ringorder_a; 79 79 s->block0[1] = 1; 80 80 s->block1[1] = n; 81 gfan::ZVector wAdjusted = currentStrategy .adjustWeightUnderHomogeneity(w,uAdjusted);81 gfan::ZVector wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(w,uAdjusted); 82 82 s->wvhdl[1] = ZVectorToIntStar(wAdjusted,overflow); 83 83 for (int j=0; j<h-1; j++) … … 86 86 s->block0[j+2] = 1; 87 87 s->block1[j+2] = n; 88 wAdjusted = currentStrategy .adjustWeightUnderHomogeneity(W[j],uAdjusted);88 wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[j],uAdjusted); 89 89 s->wvhdl[j+2] = ZVectorToIntStar(wAdjusted,overflow); 90 90 } … … 92 92 s->block0[h+1] = 1; 93 93 s->block1[h+1] = n; 94 wAdjusted = currentStrategy .adjustWeightUnderHomogeneity(W[h-1],uAdjusted);94 wAdjusted = currentStrategy->adjustWeightUnderHomogeneity(W[h-1],uAdjusted); 95 95 s->wvhdl[h+1] = ZVectorToIntStar(wAdjusted,overflow); 96 96 s->order[h+2] = ringorder_C; … … 111 111 * the initial ideal inI with respect to it, computes the star of the tropical variety in u. 112 112 **/ 113 std::set<gfan::ZCone> tropicalStar(ideal inI, const ring r, const gfan::ZVectoru,114 const tropicalStrategy currentStrategy)113 std::set<gfan::ZCone> tropicalStar(ideal &inI, const ring &r, const gfan::ZVector &u, 114 const tropicalStrategy* currentStrategy) 115 115 { 116 116 int k = idSize(inI); 117 int d = currentStrategy .getExpectedDimension();117 int d = currentStrategy->getExpectedDimension(); 118 118 119 119 /* Compute the common refinement over all tropical varieties … … 148 148 ideal ininIs = initial(inIsSTD,s,w,W); 149 149 150 poly mons = currentStrategy .checkInitialIdealForMonomial(ininIs,s,w);150 poly mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,w); 151 151 if (mons) 152 152 { … … 176 176 rDelete(s); 177 177 178 gfan::ZVector wNeg = currentStrategy .negateWeight(w);178 gfan::ZVector wNeg = currentStrategy->negateWeight(w); 179 179 if (zc->contains(wNeg)) 180 180 { … … 188 188 ininIs = initial(inIsSTD,s,wNeg,W); 189 189 190 mons = currentStrategy .checkInitialIdealForMonomial(ininIs,s,wNeg);190 mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,wNeg); 191 191 if (mons) 192 192 { … … 219 219 220 220 221 gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u, const tropicalStrategy ¤tStrategy)221 gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u, const tropicalStrategy* currentStrategy) 222 222 { 223 223 std::set<gfan::ZCone> C = tropicalStar(I,r,u,currentStrategy); … … 226 226 // delete zf; 227 227 gfan::ZMatrix raysOfC(0,u.size()); 228 if (!currentStrategy .restrictToLowerHalfSpace())228 if (!currentStrategy->restrictToLowerHalfSpace()) 229 229 { 230 230 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++) … … 266 266 tropicalStrategy currentCase(inI,currRing); 267 267 gfan::ZVector* v = bigintmatToZVector(u); 268 std::set<gfan::ZCone> C = tropicalStar(inI,currRing,*v, currentCase);268 std::set<gfan::ZCone> C = tropicalStar(inI,currRing,*v,¤tCase); 269 269 id_Delete(&inI,currRing); 270 270 delete u; -
Singular/dyn_modules/gfanlib/tropicalCurves.h
rff48aa r551009 8 8 9 9 std::set<gfan::ZCone> tropicalStar(const ideal I, const ring r, const gfan::ZVector u, 10 const tropicalStrategy ¤tStrategy);10 const tropicalStrategy* currentStrategy); 11 11 gfan::ZMatrix raysOfTropicalStar(ideal I, const ring r, const gfan::ZVector u, 12 const tropicalStrategy ¤tStrategy);12 const tropicalStrategy* currentStrategy); 13 13 14 14 #ifndef NDEBUG -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
rff48aa r551009 85 85 * if and only if it is homogeneous with respect to u 86 86 */ 87 gfan::ZVector (*weightAdjustingAlgorithm1) ( gfan::ZVectorw);87 gfan::ZVector (*weightAdjustingAlgorithm1) (const gfan::ZVector &w); 88 88 /** 89 89 * A function such that: … … 92 92 * with respect to w the weights u and v coincide 93 93 */ 94 gfan::ZVector (*weightAdjustingAlgorithm2) ( gfan::ZVector v, gfan::ZVectorw);94 gfan::ZVector (*weightAdjustingAlgorithm2) (const gfan::ZVector &v, const gfan::ZVector &w); 95 95 /** 96 96 * A function that reduces the generators of an ideal I so that … … 266 266 { 267 267 wNeg[0]=w[0]; 268 for ( inti=1; i<w.size(); i++)268 for (unsigned i=1; i<w.size(); i++) 269 269 wNeg[i]=w[i]; 270 270 } -
Singular/dyn_modules/gfanlib/tropicalTraversal.cc
rff48aa r551009 1 #include <bbcone.h> 1 2 #include <groebnerCone.h> 3 #include <tropicalCurves.h> 4 5 std::vector<bool> checkNecessaryFlips(const groebnerCones &tropicalVariety, const groebnerCones &workingList, 6 const gfan::ZVector &interiorPoint, const gfan::ZMatrix &normalVectors) 7 { 8 int k = normalVectors.getHeight(); 9 std::vector<bool> needToFlip(k,true); 10 11 int n = normalVectors.getWidth(); 12 gfan::ZMatrix testVectors(k,n); 13 gfan::ZVector bigInteriorPoint = 1000*interiorPoint; 14 for (int i=0; i<k; i++) 15 testVectors[i] = bigInteriorPoint+normalVectors[i]; 16 17 for (groebnerCones::iterator sigma = tropicalVariety.begin(); sigma!=tropicalVariety.end(); sigma++) 18 { 19 if (sigma->contains(interiorPoint)) 20 { 21 for (int i=0; i<k; i++) 22 { 23 if (needToFlip[i] && sigma->contains(testVectors[i])) 24 needToFlip[i] = false; 25 } 26 } 27 } 28 29 for (groebnerCones::iterator sigma = workingList.begin(); sigma!=workingList.end(); sigma++) 30 { 31 if (sigma->contains(interiorPoint)) 32 { 33 for (int i=0; i<k; i++) 34 { 35 if (needToFlip[i] && sigma->contains(testVectors[i])) 36 needToFlip[i] = false; 37 } 38 } 39 } 40 41 return needToFlip; 42 } 43 44 groebnerCones tropicalTraversalMinimizingFlips(const groebnerCone startingCone) 45 { 46 groebnerCones tropicalVariety; 47 groebnerCones workingList; 48 workingList.insert(startingCone); 49 const tropicalStrategy* currentStrategy=startingCone.getTropicalStrategy(); 50 while(!workingList.empty()) 51 { 52 // std::cout << "starting traversal" << std::endl; 53 /** 54 * Pick an element the working list and compute interior points on its facets 55 */ 56 groebnerCone sigma=*(workingList.begin()); 57 gfan::ZMatrix interiorPoints = interiorPointsOfFacets(sigma.getPolyhedralCone()); 58 59 for (int i=0; i<interiorPoints.getHeight(); i++) 60 { 61 /** 62 * For each interior point, compute the rays of the tropical star in that point 63 */ 64 gfan::ZVector interiorPoint = interiorPoints[i]; 65 if (!(currentStrategy->restrictToLowerHalfSpace() && interiorPoint[0].sign()==0)) 66 { 67 ideal inI = initial(sigma.getPolynomialIdeal(),sigma.getPolynomialRing(),interiorPoint); 68 gfan::ZMatrix normalVectors = raysOfTropicalStar(inI, 69 sigma.getPolynomialRing(), 70 interiorPoint, 71 sigma.getTropicalStrategy()); 72 id_Delete(&inI,sigma.getPolynomialRing()); 73 74 std::vector<bool> needToFlip = checkNecessaryFlips(tropicalVariety,workingList,interiorPoint,normalVectors); 75 for (int j=0; j<normalVectors.getHeight(); j++) 76 { 77 if (needToFlip[j]) 78 { 79 groebnerCone neighbour = sigma.flipCone(interiorPoint,normalVectors[j]); 80 workingList.insert(neighbour); 81 } 82 } 83 } 84 } 85 86 sigma.deletePolynomialData(); 87 workingList.erase(sigma); 88 tropicalVariety.insert(sigma); 89 // std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl; 90 // std::cout << "workingList.size():" << workingList.size() << std::endl; 91 } 92 return tropicalVariety; 93 } 2 94 3 95 groebnerCones tropicalTraversal(const groebnerCone startingCone) -
Singular/dyn_modules/gfanlib/tropicalTraversal.h
rff48aa r551009 2 2 #define TROPICAL_TRAVERSAL_H 3 3 4 groebnerCones tropicalTraversalMinimizingFlips(const groebnerCone startingCone); 4 5 groebnerCones tropicalTraversal(const groebnerCone startingCone); 5 6 -
Singular/dyn_modules/gfanlib/tropicalVariety.cc
rff48aa r551009 54 54 { 55 55 tropicalStrategy currentStrategy(I,currRing); 56 std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing, currentStrategy);56 std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,¤tStrategy); 57 57 // gfan::ZFan* zf = toZFan(maxCones); 58 58 // delete zf; … … 79 79 ring startingRing = currentStrategy.getStartingRing(); 80 80 poly gStart = startingIdeal->m[0]; 81 std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing, currentStrategy);81 std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,¤tStrategy); 82 82 res->rtyp = fanID; 83 83 res->data = (char*) toZFan(maxCones); -
Singular/dyn_modules/gfanlib/tropicalVarietyOfIdeals.cc
rff48aa r551009 6 6 { 7 7 groebnerCone startingCone = tropicalStartingCone(currentStrategy); 8 groebnerCones tropicalVariety = tropicalTraversal (startingCone);8 groebnerCones tropicalVariety = tropicalTraversalMinimizingFlips(startingCone); 9 9 return toFanStar(tropicalVariety); 10 10 } -
Singular/dyn_modules/gfanlib/tropicalVarietyOfPolynomials.cc
rff48aa r551009 18 18 * i.e. g is either 0 or a non-zero monomial. 19 19 **/ 20 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy ¤tCase)20 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy* currentCase) 21 21 { 22 22 int n = rVar(r); … … 44 44 equation.appendRow(exponents[i]-exponents[j]); 45 45 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 46 if (currentCase .restrictToLowerHalfSpace())46 if (currentCase->restrictToLowerHalfSpace()) 47 47 inequalities.appendRow(lowerHalfSpaceCondition); 48 48 for (int k=0; k<l; k++) -
Singular/dyn_modules/gfanlib/tropicalVarietyOfPolynomials.h
rff48aa r551009 13 13 #endif 14 14 15 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy ¤tCase);15 std::set<gfan::ZCone> tropicalVariety(const poly g, const ring r, const tropicalStrategy* currentCase); 16 16 17 17 #ifndef NDEBUG
Note: See TracChangeset
for help on using the changeset viewer.