Changeset eacb781 in git
- Timestamp:
- Aug 23, 2014, 4:25:47 PM (9 years ago)
- Branches:
- (u'spielwiese', '91e5db82acc17434e4062bcfa44e6efa7d41fd30')
- Children:
- 9c03260ac0404405e4994f73b30ef46f079535d8
- Parents:
- 78abc705dd6af8b10c453361ab125294a2432189
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2014-08-23 16:25:47+02:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:04+01:00
- Location:
- Singular/dyn_modules/gfanlib
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/adjustWeights.cc
r78abc7 reacb781 4 4 static bool checkForNonPositiveEntries(const gfan::ZVector w) 5 5 { 6 for (unsigned i= 1; i<w.size(); i++)6 for (unsigned i=0; i<w.size(); i++) 7 7 { 8 8 if (w[i].sign()<=0) … … 15 15 return true; 16 16 } 17 18 static bool checkForNonPositiveLaterEntries(const gfan::ZVector w) 19 { 20 if (w[0].sign()<0) 21 { 22 std::cout << "ERROR: negative weight in weight vector first entry" << std::endl 23 << "weight: " << w << std::endl; 24 return false; 25 } 26 for (unsigned i=1; i<w.size(); i++) 27 { 28 if (w[i].sign()<=0) 29 { 30 std::cout << "ERROR: non-positive weight in weight vector later entries" << std::endl 31 << "weight: " << w << std::endl; 32 return false; 33 } 34 } 35 return true; 36 } 37 17 38 18 39 /*** … … 50 71 for (unsigned i=1; i<w.size(); i++) 51 72 v[i]=-w[i]+max+1; 52 assume(checkForNonPositive Entries(v));73 assume(checkForNonPositiveLaterEntries(v)); 53 74 return v; 54 75 } … … 87 108 gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector e, const gfan::ZVector w) 88 109 { 89 assume(checkForNonPositive Entries(w));110 assume(checkForNonPositiveLaterEntries(w)); 90 111 /* find k such that e+k*w is strictly positive, 91 112 * i.e. k such that e[i]+k*w[i] is strictly positive 92 113 * for all i=0,...,n */ 93 114 gfan::Integer k((long)0); 94 if (e[0].sign()<=0 )115 if (e[0].sign()<=0 && w[0].sign()>0) 95 116 k = gfan::Integer((long)1)-(e[0]/w[0]); 96 117 for (unsigned i=1; i<e.size(); i++) … … 105 126 /* compute e+k*w, check it for correctness and return it */ 106 127 gfan::ZVector v = e+k*w; 107 assume(checkForNonPositive Entries(v));128 assume(checkForNonPositiveLaterEntries(v)); 108 129 return v; 109 130 } -
Singular/dyn_modules/gfanlib/containsMonomial.cc
r78abc7 reacb781 62 62 } 63 63 rComplete(s,1); 64 rTest(s); 64 65 return s; 65 66 } … … 93 94 94 95 rComplete(s,1); 96 rTest(s); 95 97 return s; 96 98 } … … 136 138 r->cf = nInitChar(n_Zp,(void*)(long)n_Int(p_GetCoeff(I->m[0],currRing),currRing->cf)); 137 139 rComplete(r); 140 rTest(r); 138 141 139 142 ideal J = id_Copy(I, currRing); poly cache; number temp; -
Singular/dyn_modules/gfanlib/flip.cc
r78abc7 reacb781 38 38 * (2) Is is a Groebner basis of the same ideal with respect to the ordering on s 39 39 **/ 40 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy& currentStrategy) 40 std::pair<ideal,ring> flip0(const ideal I, const ring r, 41 const gfan::ZVector interiorPoint, 42 const gfan::ZVector facetNormal, 43 const gfan::ZVector adjustedInteriorPoint, 44 const gfan::ZVector adjustedFacetNormal) 41 45 { 42 /* read out appropiate functions for adjusting weights and adjust themm */43 gfan::ZVector adjustedInteriorPoint = currentStrategy.adjustWeightForHomogeneity(interiorPoint);44 gfan::ZVector adjustedFacetNormal = currentStrategy.adjustWeightUnderHomogeneity(facetNormal,adjustedInteriorPoint);45 46 46 /* create a ring with weighted ordering */ 47 47 bool ok; … … 62 62 sAdjusted->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok); 63 63 sAdjusted->order[2] = ringorder_C; 64 rComplete(sAdjusted,1); 64 rComplete(sAdjusted); 65 rTest(sAdjusted); 65 66 nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf); 66 67 … … 100 101 s->block1[2] = n; 101 102 s->order[3] = ringorder_C; 102 rComplete(s,1); 103 rComplete(s); 104 rTest(s); 103 105 identity = n_SetMap(sAdjusted->cf,s->cf); 104 106 k = idSize(IsAdjustedGB); ideal IsGB = idInit(k); -
Singular/dyn_modules/gfanlib/flip.h
r78abc7 reacb781 1 #ifndef FLIP_H2 #define FLIP_H1 #ifndef GFANLIB_FLIP_H 2 #define GFANLIB_FLIP_H 3 3 4 4 #include <utility> 5 5 #include <libpolys/polys/simpleideals.h> 6 #include <gfanlib/gfanlib_vector.h> 6 7 7 #include <gfanlib/gfanlib_vector.h> 8 #include <tropicalStrategy.h> 9 10 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy& currentCase); 8 std::pair<ideal,ring> flip0(const ideal I, const ring r, 9 const gfan::ZVector interiorPoint, 10 const gfan::ZVector facetNormal, 11 const gfan::ZVector adjustedInteriorPoint, 12 const gfan::ZVector adjustedFacetNormal); 11 13 12 14 #endif -
Singular/dyn_modules/gfanlib/groebnerCone.cc
r78abc7 reacb781 72 72 if (I) polynomialIdeal = id_Copy(I,r); 73 73 if (r) polynomialRing = rCopy(r); 74 currentCase.reduce(I,r); 74 75 75 76 int n = rVar(polynomialRing); … … 82 83 for (int i=0; i<idSize(polynomialIdeal); i++) 83 84 { 84 g = polynomialIdeal->m[i]; 85 pGetExpV(g,leadexpv); 86 leadexpw = intStar2ZVector(n, leadexpv); 87 pIter(g); 88 while (g) 89 { 90 pGetExpV(g,tailexpv); 91 tailexpw = intStar2ZVector(n, tailexpv); 92 inequalities.appendRow(leadexpw-tailexpw); 85 g = I->m[i]; 86 if (g) 87 { 88 p_GetExpV(g,leadexpv,r); 89 leadexpw = intStar2ZVector(n, leadexpv); 93 90 pIter(g); 91 while (g) 92 { 93 p_GetExpV(g,tailexpv,r); 94 tailexpw = intStar2ZVector(n, tailexpv); 95 inequalities.appendRow(leadexpw-tailexpw); 96 pIter(g); 97 } 94 98 } 95 99 } 96 100 omFreeSize(leadexpv,(n+1)*sizeof(int)); 97 101 omFreeSize(tailexpv,(n+1)*sizeof(int)); 102 if (currentStrategy->restrictToLowerHalfSpace()) 103 { 104 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 105 lowerHalfSpaceCondition[0] = -1; 106 inequalities.appendRow(lowerHalfSpaceCondition); 107 } 108 98 109 polyhedralCone = gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth())); 110 polyhedralCone.canonicalize(); 99 111 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 100 112 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); … … 116 128 if (I) polynomialIdeal = id_Copy(I,r); 117 129 if (r) polynomialRing = rCopy(r); 130 currentCase.reduce(I,r); 118 131 119 132 int n = rVar(r); … … 124 137 { 125 138 poly g = polynomialIdeal->m[i]; 126 p_GetExpV(g,expv,polynomialRing); 127 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 128 long d = wDeg(g,polynomialRing,w); 129 for (pIter(g); g; pIter(g)) 139 if (g) 130 140 { 131 141 p_GetExpV(g,expv,polynomialRing); 132 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 133 if (wDeg(g,polynomialRing,w)==d) 134 equations.appendRow(leadexpv-tailexpv); 135 else 142 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 143 long d = wDeg(g,polynomialRing,w); 144 for (pIter(g); g; pIter(g)) 136 145 { 137 assume(wDeg(g,polynomialRing,w)<d); 138 inequalities.appendRow(leadexpv-tailexpv); 146 p_GetExpV(g,expv,polynomialRing); 147 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 148 if (wDeg(g,polynomialRing,w)==d) 149 equations.appendRow(leadexpv-tailexpv); 150 else 151 { 152 assume(wDeg(g,polynomialRing,w)<d); 153 inequalities.appendRow(leadexpv-tailexpv); 154 } 139 155 } 140 156 } 141 157 } 142 158 omFreeSize(expv,(n+1)*sizeof(int)); 159 if (currentStrategy->restrictToLowerHalfSpace()) 160 { 161 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 162 lowerHalfSpaceCondition[0] = -1; 163 inequalities.appendRow(lowerHalfSpaceCondition); 164 } 143 165 144 166 polyhedralCone = gfan::ZCone(inequalities,equations); 167 polyhedralCone.canonicalize(); 145 168 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 146 169 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); … … 159 182 if (I) polynomialIdeal = id_Copy(I,r); 160 183 if (r) polynomialRing = rCopy(r); 184 currentCase.reduce(I,r); 161 185 162 186 int n = rVar(r); … … 167 191 { 168 192 poly g = polynomialIdeal->m[i]; 169 p_GetExpV(g,expv,polynomialRing); 170 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 171 long d1 = wDeg(g,polynomialRing,u); 172 long d2 = wDeg(g,polynomialRing,w); 173 for (pIter(g); g; pIter(g)) 193 if (g) 174 194 { 175 195 p_GetExpV(g,expv,polynomialRing); 176 gfan::ZVector tailexpv = intStar2ZVector(n,expv);177 if (wDeg(g,polynomialRing,u)==d1 && wDeg(g,polynomialRing,w)==d2)178 equations.appendRow(leadexpv-tailexpv);179 else196 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 197 long d1 = wDeg(g,polynomialRing,u); 198 long d2 = wDeg(g,polynomialRing,w); 199 for (pIter(g); g; pIter(g)) 180 200 { 181 assume(wDeg(g,polynomialRing,u)<d1 || wDeg(g,polynomialRing,w)<d2); 182 inequalities.appendRow(leadexpv-tailexpv); 201 p_GetExpV(g,expv,polynomialRing); 202 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 203 if (wDeg(g,polynomialRing,u)==d1 && wDeg(g,polynomialRing,w)==d2) 204 equations.appendRow(leadexpv-tailexpv); 205 else 206 { 207 assume(wDeg(g,polynomialRing,u)<d1 || wDeg(g,polynomialRing,w)<d2); 208 inequalities.appendRow(leadexpv-tailexpv); 209 } 183 210 } 184 211 } 185 212 } 186 213 omFreeSize(expv,(n+1)*sizeof(int)); 214 if (currentStrategy->restrictToLowerHalfSpace()) 215 { 216 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 217 lowerHalfSpaceCondition[0] = -1; 218 inequalities.appendRow(lowerHalfSpaceCondition); 219 } 187 220 188 221 polyhedralCone = gfan::ZCone(inequalities,equations); 222 polyhedralCone.canonicalize(); 189 223 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 190 224 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); … … 205 239 { 206 240 poly g = inI->m[i]; 207 p_GetExpV(g,expv,r); 208 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 209 for (pIter(g); g; pIter(g)) 241 if (g) 210 242 { 211 243 p_GetExpV(g,expv,r); 212 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 213 equations.appendRow(leadexpv-tailexpv); 244 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 245 for (pIter(g); g; pIter(g)) 246 { 247 p_GetExpV(g,expv,r); 248 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 249 equations.appendRow(leadexpv-tailexpv); 250 } 214 251 } 215 252 } … … 218 255 { 219 256 poly g = I->m[i]; 220 p_GetExpV(g,expv,r); 221 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 222 for (pIter(g); g; pIter(g)) 257 if (g) 223 258 { 224 259 p_GetExpV(g,expv,r); 225 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 226 inequalities.appendRow(leadexpv-tailexpv); 260 gfan::ZVector leadexpv = intStar2ZVector(n,expv); 261 for (pIter(g); g; pIter(g)) 262 { 263 p_GetExpV(g,expv,r); 264 gfan::ZVector tailexpv = intStar2ZVector(n,expv); 265 inequalities.appendRow(leadexpv-tailexpv); 266 } 227 267 } 228 268 } 229 269 omFreeSize(expv,(n+1)*sizeof(int)); 270 if (currentStrategy->restrictToLowerHalfSpace()) 271 { 272 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 273 lowerHalfSpaceCondition[0] = -1; 274 inequalities.appendRow(lowerHalfSpaceCondition); 275 } 230 276 231 277 polyhedralCone = gfan::ZCone(inequalities,equations); 278 polyhedralCone.canonicalize(); 232 279 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 233 280 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); … … 277 324 gfan::ZVector groebnerCone::tropicalPoint() const 278 325 { 326 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 279 327 ideal I = polynomialIdeal; 280 328 ring r = polynomialRing; 281 gfan::ZCone zc = polyhedralCone; 282 gfan::Z Matrix R = zc.extremeRays();283 assume(checkOrderingAndCone(r,zc));329 330 gfan::ZCone coneToCheck = polyhedralCone; 331 gfan::ZMatrix R = coneToCheck.extremeRays(); 284 332 for (int i=0; i<R.getHeight(); i++) 285 333 { 286 ideal inI = initial(I,r,R[i]); 287 poly s = checkForMonomialViaSuddenSaturation(inI,r); 288 if (s == NULL) 289 { 290 id_Delete(&inI,r); 334 assume(!currentStrategy->restrictToLowerHalfSpace() || R[i][0].sign()<=0); 335 poly s = currentStrategy->checkInitialIdealForMonomial(I,r,R[i]); 336 if (s==NULL) 337 { 291 338 p_Delete(&s,r); 292 339 return R[i]; 293 340 } 294 id_Delete(&inI,r);295 p_Delete(&s,r);296 341 } 297 342 return gfan::ZVector(); … … 346 391 * to obtain an initial form with respect to interiorPoint+e*facetNormal, 347 392 * for e>0 sufficiently small */ 348 std::pair<ideal,ring> flipped = flip(polynomialIdeal,polynomialRing,interiorPoint,facetNormal,*currentStrategy); 393 std::pair<ideal,ring> flipped = currentStrategy->flip(polynomialIdeal,polynomialRing,interiorPoint,facetNormal); 394 std::cout << "finished flip" << std::endl; 349 395 assume(checkPolynomialInput(flipped.first,flipped.second)); 350 396 groebnerCone flippedCone(flipped.first, flipped.second, interiorPoint, facetNormal, *currentStrategy); … … 417 463 groebnerCones neighbours; 418 464 for (int i=0; i<interiorPoints.getHeight(); i++) 465 { 466 std::cout << "performing flip " << i << " out of " << interiorPoints.getHeight() << std::endl; 419 467 neighbours.insert(this->flipCone(interiorPoints[i],facetNormals[i])); 420 468 } 421 469 return neighbours; 422 470 } … … 477 525 for (int i=0; i<interiorPoints.getHeight(); i++) 478 526 { 479 ideal initialIdeal = initial(polynomialIdeal,polynomialRing,interiorPoints[i]); 480 std::set<gfan::ZVector> rays = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],*currentStrategy); 481 for (std::set<gfan::ZVector>::iterator ray = rays.begin(); ray!=rays.end(); ray++) 482 neighbours.insert(this->flipCone(interiorPoints[i],*ray)); 527 if (!(currentStrategy->restrictToLowerHalfSpace() && interiorPoints[i][0].sign()==0)) 528 { 529 ideal initialIdeal = initial(polynomialIdeal,polynomialRing,interiorPoints[i]); 530 std::set<gfan::ZVector> rays = raysOfTropicalStar(initialIdeal,polynomialRing,interiorPoints[i],*currentStrategy); 531 for (std::set<gfan::ZVector>::iterator ray = rays.begin(); ray!=rays.end(); ray++) 532 neighbours.insert(this->flipCone(interiorPoints[i],*ray)); 533 } 483 534 } 484 535 return neighbours; -
Singular/dyn_modules/gfanlib/groebnerCone.h
r78abc7 reacb781 40 40 gfan::ZCone polyhedralCone; 41 41 gfan::ZVector interiorPoint; 42 gfan::ZVector negativePointInLineality; 42 43 const tropicalStrategy* currentStrategy; 43 44 … … 69 70 gfan::ZCone getPolyhedralCone() const { return polyhedralCone; }; 70 71 gfan::ZVector getInteriorPoint() const { return interiorPoint; }; 72 gfan::ZVector getNegativePointInLineality() const { return negativePointInLineality; }; 71 73 const tropicalStrategy* getTropicalStrategy() const {return currentStrategy; }; 72 74 -
Singular/dyn_modules/gfanlib/initial.cc
r78abc7 reacb781 128 128 ideal initial(const ideal I, const ring r, const gfan::ZVector w) 129 129 { 130 idSkipZeroes(I); 130 131 int k = idSize(I); ideal inI = idInit(k); 131 132 for (int i=0; i<k; i++) -
Singular/dyn_modules/gfanlib/neighbours.cc
r78abc7 reacb781 178 178 gfan::ZMatrix interiorPoints = facetInteriorPoints(zc); 179 179 groebnerCones neighbours; 180 bool (*red)(ideal I, ring r, number p);181 red = currentCase.reduce;182 number p = currentCase.uniformizingParameter;183 180 184 181 for (int i=0; i<interiorPoints.getHeight(); i++) … … 196 193 ideal I = flipped.first; 197 194 ring r = flipped.second; 198 red(I,r,p);195 currentCase->reduce(I,r); 199 196 gfan::ZCone c = sloppyGroebnerCone(I,r,*ray); 200 197 gfan::ZVector p = c.getRelativeInteriorPoint(); -
Singular/dyn_modules/gfanlib/ppinitialReduction.cc
r78abc7 reacb781 21 21 if (g==NULL) 22 22 return false; 23 p_Test(g,r); 23 24 24 25 poly toBeChecked = pNext(g); … … 43 44 if (n_DivBy(p_GetCoeff(toBeChecked,r),p,r->cf)) 44 45 { 46 power=1; 45 47 coeff=n_Div(p_GetCoeff(toBeChecked,r),p,r->cf); 46 power=1;47 48 while (n_DivBy(coeff,p,r->cf)) 48 49 { 49 coeff=n_Div(p_GetCoeff(pNext(g),r),p,r->cf);50 50 power++; 51 number coeff0 = n_Div(coeff,p,r->cf); 52 n_Delete(&coeff,r->cf); 53 coeff = coeff0; 54 coeff0 = NULL; 51 55 if (power<1) 52 56 { … … 68 72 pIter(gEnd); pIter(toBeChecked); 69 73 pNext(gEnd)=NULL; 74 p_Test(g,r); 70 75 } 71 76 } … … 193 198 n=j; 194 199 } while(n); 195 for (int i= 1; i<m; i++)200 for (int i=0; i<m; i++) 196 201 if (pReduce(I->m[i],p,r)) return true; 197 202 … … 257 262 bool ppreduceInitially(ideal I, const number p, const poly g, const ring r) 258 263 { 264 idInsertPoly(I,g); 259 265 int n=idSize(I); 260 idInsertPoly(I,g);261 266 int j; 262 for (j=n ; j>0; j--)267 for (j=n-1; j>0; j--) 263 268 { 264 269 if (p_LmCmp(I->m[j], I->m[j-1],r)>0) … … 370 375 { 371 376 g=T->m[i-1]; 372 T->m[i-1]= I->m[i];377 T->m[i-1]=T->m[i]; 373 378 T->m[i]=g; 374 379 j = i; … … 389 394 if (i<k) 390 395 { 391 g = p_ Init(r);396 g = p_One(r); 392 397 for (int j=2; j<=r->N; j++) 393 398 p_SetExp(g,j,p_GetExp(pNext(T->m[0]),j,r)-p_GetExp(G->m[i],j,r),r); 394 p_Set Coeff(g,n_Init(1,r->cf),r); p_Setm(g,r);399 p_Setm(g,r); 395 400 g = p_Mult_q(g,p_Copy(G->m[i],r),r); 396 401 ppreduceInitially(I,p,g,r); … … 504 509 for (int i=0; i<n; i++) 505 510 { 511 I->m[i] = p_Cleardenom(I->m[i],r); 506 512 long d = 0; 507 513 for (int j=2; j<=r->N; j++) -
Singular/dyn_modules/gfanlib/startingCone.cc
r78abc7 reacb781 11 11 #include <tropicalVarietyOfPolynomials.h> 12 12 #include <tropicalVariety.h> 13 #include <tropicalStrategy.h> 13 14 14 15 … … 23 24 ideal I = sigma.getPolynomialIdeal(); 24 25 ring r = sigma.getPolynomialRing(); 25 ideal inI = sloppyInitial(I,r,w); 26 poly s = checkForMonomialViaSuddenSaturation(inI,r); 27 id_Delete(&inI,r); 26 const tropicalStrategy* currentStrategy = sigma.getTropicalStrategy(); 27 poly s = currentStrategy->checkInitialIdealForMonomial(I,r,w); 28 28 if (s) 29 29 { … … 44 44 45 45 46 /** *47 * Computes a starting point by traversing the Groebner fan,46 /** 47 * Computes a starting point outside the lineatliy space by traversing the Groebner fan, 48 48 * checking each cone whether it contains a ray in the tropical variety. 49 * Returns a point in the tropical variety and a maximal Groebner cone 50 * containing the point. 49 * Returns a point in the tropical variety and a maximal Groebner cone containing the point. 51 50 **/ 52 51 std::pair<gfan::ZVector,groebnerCone> tropicalStartingDataViaGroebnerFan(const ideal I, const ring r, const tropicalStrategy& currentStrategy) 53 52 { 54 std::cout << "computing starting cone" << std::endl; 55 currentStrategy.reduce(I,r); 56 std::cout << "finished reduction" << std::endl; 57 53 // start by computing a maximal Groebner cone and 54 // check whether one of its rays lies in the tropical variety 58 55 const groebnerCone sigma(I,r,currentStrategy); 59 std::cout << "finished first maximal Groebner cone" << std::endl;60 56 gfan::ZVector startingPoint = sigma.tropicalPoint(); 61 57 if (startingPoint.size() > 0) 62 58 return std::make_pair(startingPoint,sigma); 59 60 // if not, traverse the groebnerFan and until such a cone is found 61 // and return the maximal cone together with a point in its ray 63 62 groebnerCones groebnerFan; 64 63 groebnerCones workingList; 65 64 workingList.insert(sigma); 66 67 65 while (!workingList.empty()) 68 66 { 69 std::cout << "traversing groebner fan..." << std::endl;70 67 const groebnerCone sigma = *(workingList.begin()); 71 68 groebnerCones neighbours = sigma.groebnerNeighbours(); … … 86 83 workingList.erase(sigma); 87 84 } 85 86 // return some trivial output, if such a cone cannot be found 88 87 gfan::ZVector emptyVector = gfan::ZVector(0); 89 88 groebnerCone emptyCone = groebnerCone(); … … 264 263 } 265 264 gfan::ZCone C0 = currentStrategy.getHomogeneitySpace(); 266 if (C0.dimension()==currentStrategy.get DimensionOfIdeal())265 if (C0.dimension()==currentStrategy.getExpectedDimension()) 267 266 { 268 267 gfan::ZMatrix lin = C0.generatorsOfLinealitySpace(); … … 293 292 { 294 293 poly g = I->m[i]; 295 p_GetExpV(g,expv,r); 296 gfan::ZVector leadexp = intStar2ZVector(n,expv); 297 for (pIter(g); g; pIter(g)) 294 if (g) 298 295 { 299 296 p_GetExpV(g,expv,r); 300 equations.appendRow(leadexp-intStar2ZVector(n,expv)); 297 gfan::ZVector leadexp = intStar2ZVector(n,expv); 298 for (pIter(g); g; pIter(g)) 299 { 300 p_GetExpV(g,expv,r); 301 equations.appendRow(leadexp-intStar2ZVector(n,expv)); 302 } 301 303 } 302 304 } … … 304 306 return gfan::ZCone(gfan::ZMatrix(0,n),equations); 305 307 } 306 307 308 308 309 /*** 309 310 * Computes a starting cone in the tropical variety. 310 311 **/ 311 groebnerCone tropicalStartingCone(const ideal I, const ring r, const tropicalStrategy& currentStrategy) 312 { 313 ring s = rCopy(r); 314 int k = idSize(I); ideal inI = idInit(k); 315 nMapFunc identityMap = n_SetMap(r->cf,s->cf); 316 for (int i=0; i<k; i++) 317 inI->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0); 318 319 gfan::ZCone zc = linealitySpaceOfGroebnerFan(inI,s); 320 gfan::ZVector startingPoint; groebnerCone ambientMaximalCone; 321 while (zc.dimension()<currentStrategy.getDimensionOfIdeal()) 322 { 312 groebnerCone tropicalStartingCone(const tropicalStrategy& currentStrategy) 313 { 314 ring r = currentStrategy.getStartingRing(); 315 ideal I = currentStrategy.getStartingIdeal(); 316 if (currentStrategy.isConstantCoefficientCase()) 317 { 318 // copy the data, so that it be deleted when passed to the loop 319 // s <- r 320 // inI <- I 321 ring s = rCopy(r); 322 int k = idSize(I); ideal inI = idInit(k); 323 nMapFunc identityMap = n_SetMap(r->cf,s->cf); 324 for (int i=0; i<k; i++) 325 inI->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0); 326 327 // repeatedly computes a point in the tropical variety outside the lineality space, 328 // take the initial ideal with respect to it 329 // and check whether the dimension of its homogeneity space 330 // equals the dimension of the tropical variety 331 gfan::ZCone zc = linealitySpaceOfGroebnerFan(inI,s); 332 gfan::ZVector startingPoint; groebnerCone ambientMaximalCone; 333 while (zc.dimension()<currentStrategy.getExpectedDimension()) 334 { 335 // compute a point in the tropical variety outside the lineality space 336 std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inI,s,currentStrategy); 337 startingPoint = startingData.first; 338 ambientMaximalCone = groebnerCone(startingData.second); 339 340 id_Delete(&inI,s); rDelete(s); 341 inI = ambientMaximalCone.getPolynomialIdeal(); 342 s = ambientMaximalCone.getPolynomialRing(); 343 344 // compute the initial ideal with respect to the weight 345 inI = sloppyInitial(inI,s,startingPoint); 346 zc = linealitySpaceOfGroebnerFan(inI,s); 347 } 348 349 // once the dimension of the homogeneity space equals that of the tropical variety 350 // we know that we have an initial ideal with respect to a weight 351 // in the relative interior of a maximal cone in the tropical variety 352 // from this we can read of the inequalities and equations 353 354 // but before doing so, we must lift the generating set of inI 355 // to a generating set of I 356 ideal J = lift(I,r,inI,s); 357 groebnerCone startingCone(J,inI,s,currentStrategy); 358 id_Delete(&inI,s); 359 id_Delete(&J,s); 360 361 assume(checkContainmentInTropicalVariety(startingCone)); 362 return startingCone; 363 } 364 else 365 { 366 // copy the data, so that it be deleted when passed to the loop 367 // s <- r 368 // inI <- I 369 ring s = rCopy(r); 370 int k = idSize(I); ideal inI = idInit(k); 371 nMapFunc identityMap = n_SetMap(r->cf,s->cf); 372 for (int i=0; i<k; i++) 373 inI->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0); 374 375 // and check whether the dimension of its homogeneity space 376 // equals the dimension of the tropical variety 377 gfan::ZCone zc = linealitySpaceOfGroebnerFan(inI,s); 378 if (zc.dimension()==currentStrategy.getExpectedDimension()) 379 { // this shouldn't happen as trivial cases should be caught beforehand 380 // this is the case that the tropical variety consists soely out of the lineality space 381 groebnerCone startingCone(I,inI,s,currentStrategy); 382 id_Delete(&inI,s); 383 rDelete(s); 384 return startingCone; 385 } 386 387 // compute a point in the tropical variety outside the lineality space 388 // compute the initial ideal with respect to the weight 323 389 std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inI,s,currentStrategy); 324 startingPoint = startingData.first; 325 ambientMaximalCone = groebnerCone(startingData.second); 326 390 gfan::ZVector startingPoint = startingData.first; 391 groebnerCone ambientMaximalCone = groebnerCone(startingData.second); 327 392 id_Delete(&inI,s); rDelete(s); 328 393 inI = ambientMaximalCone.getPolynomialIdeal(); 329 394 s = ambientMaximalCone.getPolynomialRing(); 330 331 395 inI = sloppyInitial(inI,s,startingPoint); 332 396 zc = linealitySpaceOfGroebnerFan(inI,s); 333 } 334 335 ideal J = lift(I,r,inI,s); 336 groebnerCone tropicalStartingCone(J,inI,s,currentStrategy); 337 id_Delete(&inI,s); 338 id_Delete(&J,s); 339 340 assume(checkContainmentInTropicalVariety(tropicalStartingCone)); 341 assume(checkOneCodimensionalLinealitySpace(tropicalStartingCone)); 342 return tropicalStartingCone; 343 } 344 397 398 // and check whether the dimension of its homogeneity space 399 // equals the dimension of the tropical variety 400 if (zc.dimension()==currentStrategy.getExpectedDimension()) 401 { // this case shouldn't happen as trivial cases should be caught beforehand 402 // this is the case that the tropical variety has a one-codimensional lineality space 403 ideal J = lift(I,r,inI,s); 404 groebnerCone startingCone(J,inI,s,currentStrategy); 405 id_Delete(&inI,s); 406 id_Delete(&J,s); 407 return startingCone; 408 } 409 410 // from this point on, inI contains the uniformizing parameter, 411 // hence it contains a monomial if and only if its residue over the residue field does. 412 // so we will switch to the residue field 413 ring rShortcut = rCopy0(r); 414 nKillChar(rShortcut->cf); 415 rShortcut->cf = nCopyCoeff((currentStrategy.getShortcutRing())->cf); 416 rComplete(rShortcut); 417 rTest(rShortcut); 418 k = idSize(inI); 419 ideal inIShortcut = idInit(k); 420 nMapFunc takingResidues = n_SetMap(s->cf,rShortcut->cf); 421 for (int i=0; i<k; i++) 422 inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,s,rShortcut,takingResidues,NULL,0); 423 idSkipZeroes(inIShortcut); 424 id_Delete(&inI,s); 425 426 // we are interested in a maximal cone of the tropical variety of inIShortcut 427 // this basically equivalent to the case without valuation (or constant coefficient case) 428 // except that our ideal is still only homogeneous in the later variables, 429 // hence we set the optional parameter completelyHomogeneous as 'false' 430 tropicalStrategy shortcutStrategy(inIShortcut,rShortcut,false); 431 groebnerCone startingConeShortcut = tropicalStartingCone(shortcutStrategy); 432 id_Delete(&inIShortcut,rShortcut); rDelete(rShortcut); 433 434 // now we need to obtain the initial of the residue of inI 435 // with respect to a weight in the tropical cone, 436 // and obtain the initial of inI with respect to the same weight 437 ring sShortcut = startingConeShortcut.getPolynomialRing(); 438 inIShortcut = startingConeShortcut.getPolynomialIdeal(); 439 gfan::ZCone zd = startingConeShortcut.getPolyhedralCone(); 440 gfan::ZVector interiorPoint = startingConeShortcut.getInteriorPoint(); 441 inIShortcut = sloppyInitial(inIShortcut,sShortcut,interiorPoint); 442 443 s = rCopy0(sShortcut); // s will be a ring over the valuation ring 444 nKillChar(s->cf); // with the same ordering as sShortcut 445 s->cf = nCopyCoeff(r->cf); 446 rComplete(s); 447 rTest(s); 448 449 k = idSize(inIShortcut); // inI will be overwritten with initial of inI 450 inI = idInit(k+1); 451 inI->m[0] = p_One(s); // with respect to that weight 452 identityMap = n_SetMap(r->cf,s->cf); // first element will obviously be p 453 p_SetCoeff(inI->m[0],identityMap(currentStrategy.getUniformizingParameter(),r->cf,s->cf),s); 454 nMapFunc findingRepresentatives = n_SetMap(sShortcut->cf,s->cf); 455 for (int i=0; i<k; i++) // and then come the rest 456 inI->m[i+1] = p_PermPoly(inIShortcut->m[i],NULL,sShortcut,s,findingRepresentatives,NULL,0); 457 458 ideal J = lift(I,r,inI,s); 459 groebnerCone startingCone(J,inI,s,currentStrategy); 460 id_Delete(&inI,s); 461 id_Delete(&J,s); 462 rDelete(s); 463 464 return startingCone; 465 } 466 } 345 467 346 468 BOOLEAN tropicalStartingCone(leftv res, leftv args) … … 357 479 if (w==NULL) 358 480 { 359 tropicalStrategy valuedCase(I,p,currRing); 360 groebnerCone sigma = tropicalStartingCone(I,currRing,valuedCase); 481 tropicalStrategy currentStrategy(I,p,currRing); 482 groebnerCone sigma = tropicalStartingCone(currentStrategy); 483 gfan::ZCone* startingCone = new gfan::ZCone(sigma.getPolyhedralCone()); 484 res->rtyp = coneID; 485 res->data = (char*) startingCone; 486 return FALSE; 487 } 488 } 489 else 490 { 491 if (v==NULL) 492 { 493 tropicalStrategy currentStrategy(I,currRing); 494 groebnerCone sigma = tropicalStartingCone(currentStrategy); 361 495 res->rtyp = coneID; 362 496 res->data = (char*) new gfan::ZCone(sigma.getPolyhedralCone()); … … 364 498 } 365 499 } 366 else367 {368 if (v==NULL)369 {370 tropicalStrategy nonValuedCase(I,currRing);371 groebnerCone sigma = tropicalStartingCone(I,currRing,nonValuedCase);372 res->rtyp = coneID;373 res->data = (char*) new gfan::ZCone(sigma.getPolyhedralCone());374 return FALSE;375 }376 }377 500 } 378 501 WerrorS("tropicalStartingCone: unexpected parameters"); -
Singular/dyn_modules/gfanlib/startingCone.h
r78abc7 reacb781 5 5 #include <tropicalStrategy.h> 6 6 7 groebnerCone tropicalStartingCone(const ideal I, const ring r, consttropicalStrategy& currentCase);7 groebnerCone tropicalStartingCone(const tropicalStrategy& currentCase); 8 8 9 9 BOOLEAN tropicalStartingPoint(leftv res, leftv args); -
Singular/dyn_modules/gfanlib/tropical.cc
r78abc7 reacb781 27 27 for (int i=0; i<IDELEMS(I); i++) 28 28 { 29 g = (poly) I->m[i]; pGetExpV(g,leadexpv); 30 leadexpw = intStar2ZVector(n, leadexpv); 31 pIter(g); 32 while (g != NULL) 33 { 34 pGetExpV(g,tailexpv); 35 tailexpw = intStar2ZVector(n, tailexpv); 36 equations.appendRow(leadexpw-tailexpw); 29 g = (poly) I->m[i]; 30 if (g) 31 { 32 p_GetExpV(g,leadexpv,r); 33 leadexpw = intStar2ZVector(n,leadexpv); 37 34 pIter(g); 35 while (g) 36 { 37 p_GetExpV(g,tailexpv,r); 38 tailexpw = intStar2ZVector(n,tailexpv); 39 equations.appendRow(leadexpw-tailexpw); 40 pIter(g); 41 } 38 42 } 39 43 } -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
r78abc7 reacb781 100 100 101 101 /* complete the ring and return it */ 102 rComplete(s,1); 102 rComplete(s); 103 rTest(s); 103 104 return s; 104 105 } … … 114 115 { 115 116 int k = idSize(inI); 116 int d = currentStrategy.get DimensionOfIdeal();117 int d = currentStrategy.getExpectedDimension(); 117 118 118 119 /* Compute the common refinement over all tropical varieties … … 168 169 std::set<gfan::ZCone> C = tropicalStar(I,r,u,currentStrategy); 169 170 std::set<gfan::ZVector> raysOfC; 170 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++) 171 { 172 assume(zc->dimensionOfLinealitySpace()+1 == zc->dimension()); 173 raysOfC.insert(zc->semiGroupGeneratorOfRay()); 171 if (!currentStrategy.restrictToLowerHalfSpace()) 172 { 173 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++) 174 { 175 assume(zc->dimensionOfLinealitySpace()+1 == zc->dimension()); 176 raysOfC.insert(zc->semiGroupGeneratorOfRay()); 177 } 178 } 179 else 180 { 181 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++) 182 { 183 assume(zc->dimensionOfLinealitySpace()+2 == zc->dimension()); 184 raysOfC.insert(zc->getRelativeInteriorPoint()); 185 } 174 186 } 175 187 return raysOfC; -
Singular/dyn_modules/gfanlib/tropicalStrategy.cc
r78abc7 reacb781 49 49 *g 50 50 */ 51 tropicalStrategy::tropicalStrategy(ideal I, ring r): 51 tropicalStrategy::tropicalStrategy(const ideal I, const ring r, 52 const bool completelyHomogeneous, 53 const bool completeSpace): 52 54 originalRing(rCopy(r)), 53 55 originalIdeal(id_Copy(I,r)), 54 dimensionOfIdeal(dim(originalIdeal,originalRing)),56 expectedDimension(dim(originalIdeal,originalRing)), 55 57 linealitySpace(homogeneitySpace(originalIdeal,originalRing)), 56 58 startingRing(rCopy(originalRing)), … … 63 65 extraReductionAlgorithm(noExtraReduction) 64 66 { 65 assume(rField_is_Q(r)); 67 assume(rField_is_Q(r) || rField_is_Zp(r)); 68 if (!completelyHomogeneous) 69 { 70 weightAdjustingAlgorithm1 = valued_adjustWeightForHomogeneity; 71 weightAdjustingAlgorithm2 = valued_adjustWeightUnderHomogeneity; 72 } 73 if (!completeSpace) 74 onlyLowerHalfSpace = true; 66 75 } 67 76 … … 101 110 102 111 rComplete(s); 112 rTest(s); 103 113 return s; 104 114 } … … 111 121 ring s = rCopy0(r,FALSE,TRUE); 112 122 rComplete(s); 123 rTest(s); 113 124 return s; 114 125 } … … 123 134 originalRing(rCopy(s)), 124 135 originalIdeal(id_Copy(J,s)), 125 dimensionOfIdeal(dim(originalIdeal,originalRing)),126 linealitySpace( homogeneitySpace(originalIdeal,originalRing)),127 startingRing( rCopy(originalRing)),128 startingIdeal( id_Copy(originalIdeal,originalRing)),129 uniformizingParameter(NULL), 130 shortcutRing( rCopy(originalRing)),131 onlyLowerHalfSpace( false),132 weightAdjustingAlgorithm1( nonvalued_adjustWeightForHomogeneity),133 weightAdjustingAlgorithm2( nonvalued_adjustWeightUnderHomogeneity),134 extraReductionAlgorithm( noExtraReduction)136 expectedDimension(dim(originalIdeal,originalRing)+1), 137 linealitySpace(gfan::ZCone()), // to come, see below 138 startingRing(NULL), // to come, see below 139 startingIdeal(NULL), // to come, see below 140 uniformizingParameter(NULL), // to come, see below 141 shortcutRing(NULL), // to come, see below 142 onlyLowerHalfSpace(true), 143 weightAdjustingAlgorithm1(valued_adjustWeightForHomogeneity), 144 weightAdjustingAlgorithm2(valued_adjustWeightUnderHomogeneity), 145 extraReductionAlgorithm(ppreduceInitially) 135 146 { 136 147 /* assume that the ground field of the originalRing is Q */ … … 164 175 omFreeSize(shiftByOne,(n+1)*sizeof(int)); 165 176 177 linealitySpace = homogeneitySpace(startingIdeal,startingRing); 178 166 179 /* construct the shorcut ring */ 167 180 shortcutRing = rCopy0(startingRing); … … 169 182 shortcutRing->cf = nInitChar(n_Zp,(void*)(long)IsPrime(n_Int(uniformizingParameter,startingRing->cf))); 170 183 rComplete(shortcutRing); 171 172 /* compute the dimension of the ideal in the original ring */ 173 dimensionOfIdeal = dim(J,s); 174 175 /* set the flag that convex computations only occur in the lower half space to true */ 176 onlyLowerHalfSpace = true; 177 178 /* set the function pointers to the appropiate functions */ 179 weightAdjustingAlgorithm1 = valued_adjustWeightForHomogeneity; 180 weightAdjustingAlgorithm2 = valued_adjustWeightUnderHomogeneity; 181 extraReductionAlgorithm = ppreduceInitially; 184 rTest(shortcutRing); 182 185 } 183 186 184 187 tropicalStrategy::tropicalStrategy(const tropicalStrategy& currentStrategy): 185 188 originalRing(rCopy(currentStrategy.getOriginalRing())), 189 originalIdeal(id_Copy(currentStrategy.getOriginalIdeal(),currentStrategy.getOriginalRing())), 190 expectedDimension(currentStrategy.getExpectedDimension()), 191 linealitySpace(currentStrategy.getHomogeneitySpace()), 186 192 startingRing(rCopy(currentStrategy.getStartingRing())), 193 startingIdeal(id_Copy(currentStrategy.getStartingIdeal(),currentStrategy.getStartingRing())), 187 194 uniformizingParameter(n_Copy(currentStrategy.getUniformizingParameter(),startingRing->cf)), 188 startingIdeal(id_Copy(currentStrategy.getStartingIdeal(),startingRing)), 189 dimensionOfIdeal(currentStrategy.getDimensionOfIdeal()), 195 shortcutRing(rCopy(currentStrategy.getShortcutRing())), 190 196 onlyLowerHalfSpace(currentStrategy.restrictToLowerHalfSpace()), 191 197 weightAdjustingAlgorithm1(currentStrategy.weightAdjustingAlgorithm1), … … 193 199 extraReductionAlgorithm(currentStrategy.extraReductionAlgorithm) 194 200 { 201 if (originalRing) rTest(originalRing); 202 if (originalIdeal) id_Test(originalIdeal,originalRing); 195 203 if (startingRing) rTest(startingRing); 196 204 if (startingIdeal) id_Test(startingIdeal,startingRing); 205 if (uniformizingParameter) n_Test(uniformizingParameter,startingRing->cf); 206 if (shortcutRing) rTest(shortcutRing); 197 207 } 198 208 199 209 tropicalStrategy::~tropicalStrategy() 200 210 { 211 if (originalRing) rTest(originalRing); 212 if (originalIdeal) id_Test(originalIdeal,originalRing); 201 213 if (startingRing) rTest(startingRing); 202 214 if (startingIdeal) id_Test(startingIdeal,startingRing); 203 215 if (uniformizingParameter) n_Test(uniformizingParameter,startingRing->cf); 216 if (shortcutRing) rTest(shortcutRing); 217 218 id_Delete(&originalIdeal,originalRing); 219 rDelete(originalRing); 204 220 id_Delete(&startingIdeal,startingRing); 205 221 n_Delete(&uniformizingParameter,startingRing->cf); 206 rDelete(originalRing);207 222 rDelete(startingRing); 223 rDelete(shortcutRing); 208 224 } 209 225 … … 211 227 { 212 228 originalRing = rCopy(currentStrategy.getOriginalRing()); 229 originalIdeal = id_Copy(currentStrategy.getOriginalIdeal(),currentStrategy.getOriginalRing()); 230 expectedDimension = currentStrategy.getExpectedDimension(); 213 231 startingRing = rCopy(currentStrategy.getStartingRing()); 232 startingIdeal = id_Copy(currentStrategy.getStartingIdeal(),currentStrategy.getStartingRing()); 214 233 uniformizingParameter = n_Copy(currentStrategy.getUniformizingParameter(),startingRing->cf); 215 startingIdeal = id_Copy(currentStrategy.getStartingIdeal(),startingRing); 216 dimensionOfIdeal = currentStrategy.getDimensionOfIdeal(); 234 shortcutRing = rCopy(currentStrategy.getShortcutRing()); 217 235 onlyLowerHalfSpace = currentStrategy.restrictToLowerHalfSpace(); 218 236 weightAdjustingAlgorithm1 = currentStrategy.weightAdjustingAlgorithm1; … … 220 238 extraReductionAlgorithm = currentStrategy.extraReductionAlgorithm; 221 239 240 if (originalRing) rTest(originalRing); 241 if (originalIdeal) id_Test(originalIdeal,originalRing); 222 242 if (startingRing) rTest(startingRing); 223 243 if (startingIdeal) id_Test(startingIdeal,startingRing); 244 if (uniformizingParameter) n_Test(uniformizingParameter,startingRing->cf); 245 if (shortcutRing) rTest(shortcutRing); 224 246 225 247 return *this; -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
r78abc7 reacb781 5 5 #include <gfanlib/gfanlib_zcone.h> 6 6 #include <libpolys/polys/simpleideals.h> 7 #include <kernel/ideals.h> // for idSize 7 8 #include <set> 9 #include <callgfanlib_conversion.h> 10 #include <containsMonomial.h> 11 #include <flip.h> 12 #include <initial.h> 8 13 9 14 /** \file … … 33 38 ideal originalIdeal; 34 39 /** 35 * dimension of the input ideal 36 */ 37 int dimensionOfIdeal; 40 * the expected Dimension of the polyhedral output, 41 * i.e. the dimension of the ideal if trivial valuation 42 * or the dimension of the ideal plus one if non-trivial valuation 43 * (as the output is supposed to be intersected with a hyperplane) 44 */ 45 int expectedDimension; 38 46 /** 39 47 * the homogeneity space of the Grobner fan … … 87 95 * Constructor for the trivial valuation case 88 96 */ 89 tropicalStrategy(const ideal I, const ring r );97 tropicalStrategy(const ideal I, const ring r, const bool completelyHomogeneous=true, const bool completeSpace=true); 90 98 /** 91 99 * Constructor for the non-trivial valuation case … … 106 114 tropicalStrategy& operator=(const tropicalStrategy& currentStrategy); 107 115 116 bool isConstantCoefficientCase() const 117 { 118 bool b = (uniformizingParameter==NULL); 119 return b; 120 } 108 121 109 122 /** … … 117 130 118 131 /** 132 * returns the input ideal over the field with valuation 133 */ 134 ideal getOriginalIdeal() const 135 { 136 if (originalIdeal) id_Test(originalIdeal,originalRing); 137 return originalIdeal; 138 } 139 140 /** 119 141 * returns the polynomial ring over the valuation ring 120 142 */ … … 130 152 ideal getStartingIdeal() const 131 153 { 132 i d_Test(startingIdeal,startingRing);154 if (startingIdeal) id_Test(startingIdeal,startingRing); 133 155 return startingIdeal; 134 156 } 135 157 136 158 /** 137 * returns the dimension of the input ideal138 */ 139 int get DimensionOfIdeal() const140 { 141 return dimensionOfIdeal;159 * returns the expected Dimension of the polyhedral output 160 */ 161 int getExpectedDimension() const 162 { 163 return expectedDimension; 142 164 } 143 165 … … 147 169 number getUniformizingParameter() const 148 170 { 171 if (uniformizingParameter) n_Test(uniformizingParameter,startingRing->cf); 149 172 return uniformizingParameter; 173 } 174 175 ring getShortcutRing() const 176 { 177 rTest(shortcutRing); 178 return shortcutRing; 150 179 } 151 180 … … 198 227 * the inequalities and equations of the Groebner cone can be read off. 199 228 */ 200 bool reduce(ideal I, ring r) const229 bool reduce(ideal I, const ring r) const 201 230 { 202 231 rTest(r); id_Test(I,r); … … 212 241 * returns false otherwise. 213 242 **/ 214 bool containsMonomial(ideal I, ring r) const 215 { 216 ring rFinite = rCopy0(r); 217 nKillChar(rFinite.coeffs()); 218 rFinite->cf = 243 poly checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector w) const 244 { 245 gfan::ZVector v = adjustWeightForHomogeneity(w); 246 if (isConstantCoefficientCase()) 247 { 248 ring rShortcut = rCopy0(r); 249 bool overflow; 250 /** 251 * prepend extra weight vector for homogeneity 252 */ 253 int* order = rShortcut->order; 254 int* block0 = rShortcut->block0; 255 int* block1 = rShortcut->block1; 256 int** wvhdl = rShortcut->wvhdl; 257 int h = rBlocks(r); int n = rVar(r); 258 rShortcut->order = (int*) omAlloc0((h+1)*sizeof(int)); 259 rShortcut->block0 = (int*) omAlloc0((h+1)*sizeof(int)); 260 rShortcut->block1 = (int*) omAlloc0((h+1)*sizeof(int)); 261 rShortcut->wvhdl = (int**) omAlloc0((h+1)*sizeof(int*)); 262 rShortcut->order[0] = ringorder_a; 263 rShortcut->block0[0] = 1; 264 rShortcut->block1[0] = n; 265 rShortcut->wvhdl[0] = ZVectorToIntStar(v,overflow); 266 for (int i=1; i<=h; i++) 267 { 268 rShortcut->order[i] = order[i-1]; 269 rShortcut->block0[i] = block0[i-1]; 270 rShortcut->block1[i] = block1[i-1]; 271 rShortcut->wvhdl[i] = wvhdl[i-1]; 272 } 273 rComplete(rShortcut); 274 rTest(rShortcut); 275 omFree(order); 276 omFree(block0); 277 omFree(block1); 278 omFree(wvhdl); 279 280 ideal inI = initial(I,r,w); 281 int k = idSize(inI); 282 ideal inIShortcut = idInit(k); 283 nMapFunc identity = n_SetMap(r->cf,rShortcut->cf); 284 for (int i=0; i<k; i++) 285 inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,identity,NULL,0); 286 287 poly p = checkForMonomialViaSuddenSaturation(inIShortcut,rShortcut); 288 poly monomial = NULL; 289 if (p!=NULL) 290 { 291 monomial=p_One(r); 292 for (int i=1; i<n; i++) 293 p_SetExp(monomial,i,p_GetExp(p,i,rShortcut),r); 294 p_Delete(&p,rShortcut); 295 } 296 id_Delete(&inI,r); 297 id_Delete(&inIShortcut,rShortcut); 298 rDelete(rShortcut); 299 return monomial; 300 } 301 else 302 { 303 ring rShortcut = rCopy0(r); 304 bool overflow; 305 /** 306 * prepend extra weight vector for homogeneity 307 */ 308 int* order = rShortcut->order; 309 int* block0 = rShortcut->block0; 310 int* block1 = rShortcut->block1; 311 int** wvhdl = rShortcut->wvhdl; 312 int h = rBlocks(r); int n = rVar(r); 313 rShortcut->order = (int*) omAlloc0((h+1)*sizeof(int)); 314 rShortcut->block0 = (int*) omAlloc0((h+1)*sizeof(int)); 315 rShortcut->block1 = (int*) omAlloc0((h+1)*sizeof(int)); 316 rShortcut->wvhdl = (int**) omAlloc0((h+1)*sizeof(int*)); 317 rShortcut->order[0] = ringorder_a; 318 rShortcut->block0[0] = 1; 319 rShortcut->block1[0] = n; 320 rShortcut->wvhdl[0] = ZVectorToIntStar(v,overflow); 321 for (int i=1; i<=h; i++) 322 { 323 rShortcut->order[i] = order[i-1]; 324 rShortcut->block0[i] = block0[i-1]; 325 rShortcut->block1[i] = block1[i-1]; 326 rShortcut->wvhdl[i] = wvhdl[i-1]; 327 } 328 omFree(order); 329 omFree(block0); 330 omFree(block1); 331 omFree(wvhdl); 332 /** 333 * change ground domain into finite field 334 */ 335 nKillChar(rShortcut->cf); 336 rShortcut->cf = nCopyCoeff(shortcutRing->cf); 337 rComplete(rShortcut); 338 rTest(rShortcut); 339 340 ideal inI = initial(I,r,w); 341 int k = idSize(inI); 342 ideal inIShortcut = idInit(k); 343 nMapFunc takingResidues = n_SetMap(r->cf,rShortcut->cf); 344 for (int i=0; i<k; i++) 345 inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,takingResidues,NULL,0); 346 347 idSkipZeroes(inIShortcut); 348 poly p = checkForMonomialViaSuddenSaturation(inIShortcut,rShortcut); 349 poly monomial = NULL; 350 if (p!=NULL) 351 { 352 monomial=p_One(r); 353 for (int i=1; i<n; i++) 354 p_SetExp(monomial,i,p_GetExp(p,i,rShortcut),r); 355 p_Delete(&p,rShortcut); 356 } 357 id_Delete(&inI,r); 358 id_Delete(&inIShortcut,rShortcut); 359 rDelete(rShortcut); 360 return monomial; 361 } 362 } 363 std::pair<ideal,ring> flip(const ideal I, const ring r, 364 const gfan::ZVector interiorPoint, 365 const gfan::ZVector facetNormal) const 366 { 367 gfan::ZVector adjustedInteriorPoint = adjustWeightForHomogeneity(interiorPoint); 368 gfan::ZVector adjustedFacetNormal = adjustWeightUnderHomogeneity(facetNormal,adjustedInteriorPoint); 369 return flip0(I,r,interiorPoint,facetNormal,adjustedInteriorPoint,adjustedFacetNormal); 219 370 } 220 371 }; -
Singular/dyn_modules/gfanlib/tropicalVariety.cc
r78abc7 reacb781 37 37 { 38 38 tropicalStrategy currentStrategy(I,currRing); 39 setOptionRedSB(); 39 40 gfan::ZFan* tropI = tropicalVariety(currentStrategy); 41 undoSetOptionRedSB(); 40 42 res->rtyp = fanID; 41 43 res->data = (char*) tropI; … … 46 48 number p = (number) v->CopyD(); 47 49 tropicalStrategy currentStrategy(I,p,currRing); 48 setOptionRedSB();49 50 gfan::ZFan* tropI = tropicalVariety(currentStrategy); 50 undoSetOptionRedSB();51 51 res->rtyp = fanID; 52 52 res->data = (char*) tropI; -
Singular/dyn_modules/gfanlib/tropicalVarietyOfIdeals.cc
r78abc7 reacb781 7 7 ideal I = currentStrategy.getStartingIdeal(); 8 8 ring r = currentStrategy.getStartingRing(); 9 groebnerCone startingCone = tropicalStartingCone( I,r,currentStrategy);9 groebnerCone startingCone = tropicalStartingCone(currentStrategy); 10 10 groebnerCones tropicalVariety = tropicalTraversal(startingCone); 11 11 return toFanStar(tropicalVariety); -
Singular/dyn_modules/gfanlib/witness.cc
r78abc7 reacb781 17 17 { 18 18 ring origin = currRing; 19 rComplete(r);20 19 if (origin != r) rChangeCurrRing(r); 21 20 ideal F = idInit(1); F->m[0]=f; 22 ideal m = idLift(G,F,NULL,FALSE,FALSE); 21 ideal m = idLift(G,F); 22 // ideal m = idLift(G,F,NULL,FALSE,TRUE); 23 23 F->m[0]=NULL; id_Delete(&F, currRing); 24 24 matrix Q = id_Module2formatedMatrix(m,IDELEMS(G),1,currRing); … … 53 53 poly witness(const poly m, const ideal I, const ideal inI, const ring r) 54 54 { 55 assume(idSize(I)==idSize(inI)); 55 56 matrix Q = divisionDiscardingRemainder(m,inI,r); 56 57
Note: See TracChangeset
for help on using the changeset viewer.