Changeset 7723d00 in git
- Timestamp:
- Feb 4, 2015, 12:36:21 PM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 08b7c2ac6141d36536d3eb58dd62e9ad4be529da
- Parents:
- f16226e1d8662eca29be06420a230cd92d756ff3
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-04 12:36:21+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:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/groebnerCone.cc
rf16226 r7723d00 98 98 /* check whether facet normal points outwards */ 99 99 gfan::ZCone dual = polyhedralCone.dualCone(); 100 if(dual.contains (facetNormal))100 if(dual.containsRelatively(facetNormal)) 101 101 { 102 102 std::cout << "ERROR: facetNormal is not pointing outwards!" << std::endl … … 126 126 { 127 127 assume(checkPolynomialInput(I,r)); 128 if (I) polynomialIdeal = id_Copy(I,r);129 128 if (r) polynomialRing = rCopy(r); 130 ideal redI = id_Copy(polynomialIdeal,polynomialRing); 131 currentCase.pReduce(redI,polynomialRing); 132 currentCase.reduce(redI,polynomialRing); 129 if (I) 130 { 131 polynomialIdeal = id_Copy(I,r); 132 currentCase.pReduce(polynomialIdeal,polynomialRing); 133 currentCase.reduce(polynomialIdeal,polynomialRing); 134 } 133 135 134 136 int n = rVar(polynomialRing); … … 139 141 gfan::ZVector tailexpw = gfan::ZVector(n); 140 142 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 141 for (int i=0; i<idSize( redI); i++)142 { 143 g = redI->m[i];143 for (int i=0; i<idSize(polynomialIdeal); i++) 144 { 145 g = polynomialIdeal->m[i]; 144 146 if (g) 145 147 { … … 169 171 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 170 172 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 171 id_Delete(&redI,polynomialRing);172 173 } 173 174 … … 178 179 { 179 180 assume(checkPolynomialInput(I,r)); 180 if (I) polynomialIdeal = id_Copy(I,r);181 181 if (r) polynomialRing = rCopy(r); 182 ideal redI = id_Copy(polynomialIdeal,polynomialRing); 183 currentCase.pReduce(redI,polynomialRing); 184 currentCase.reduce(redI,polynomialRing); 182 if (I) 183 { 184 polynomialIdeal = id_Copy(I,r); 185 currentCase.pReduce(polynomialIdeal,polynomialRing); 186 currentCase.reduce(polynomialIdeal,polynomialRing); 187 } 185 188 186 189 int n = rVar(polynomialRing); … … 188 191 gfan::ZMatrix equations = gfan::ZMatrix(0,n); 189 192 int* expv = (int*) omAlloc((n+1)*sizeof(int)); 190 for (int i=0; i<idSize( redI); i++)191 { 192 poly g = redI->m[i];193 for (int i=0; i<idSize(polynomialIdeal); i++) 194 { 195 poly g = polynomialIdeal->m[i]; 193 196 if (g) 194 197 { … … 222 225 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 223 226 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 224 id_Delete(&redI,polynomialRing);225 227 } 226 228 … … 235 237 { 236 238 assume(checkPolynomialInput(I,r)); 237 if (I) polynomialIdeal = id_Copy(I,r);238 239 if (r) polynomialRing = rCopy(r); 239 ideal redI = id_Copy(polynomialIdeal,polynomialRing); 240 currentCase.pReduce(redI,polynomialRing); 241 currentCase.reduce(redI,polynomialRing); 240 if (I) 241 { 242 polynomialIdeal = id_Copy(I,r); 243 currentCase.pReduce(polynomialIdeal,polynomialRing); 244 currentCase.reduce(polynomialIdeal,polynomialRing); 245 } 242 246 243 247 int n = rVar(polynomialRing); … … 245 249 gfan::ZMatrix equations = gfan::ZMatrix(0,n); 246 250 int* expv = (int*) omAlloc((n+1)*sizeof(int)); 247 for (int i=0; i<idSize( redI); i++)248 { 249 poly g = redI->m[i];251 for (int i=0; i<idSize(polynomialIdeal); i++) 252 { 253 poly g = polynomialIdeal->m[i]; 250 254 if (g) 251 255 { … … 280 284 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 281 285 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 282 id_Delete(&redI,polynomialRing);283 286 } 284 287 … … 292 295 assume(checkPolynomialInput(inI,r)); 293 296 294 ideal redI = id_Copy(polynomialIdeal,polynomialRing); 295 currentCase.pReduce(redI,polynomialRing); 296 currentCase.reduce(redI,polynomialRing); 297 currentCase.pReduce(polynomialIdeal,polynomialRing); 298 currentCase.reduce(polynomialIdeal,polynomialRing); 297 299 298 300 int n = rVar(r); … … 315 317 } 316 318 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 317 for (int i=0; i<idSize( redI); i++)318 { 319 poly g = redI->m[i];319 for (int i=0; i<idSize(polynomialIdeal); i++) 320 { 321 poly g = polynomialIdeal->m[i]; 320 322 if (g) 321 323 { … … 342 344 interiorPoint = polyhedralCone.getRelativeInteriorPoint(); 343 345 assume(checkOrderingAndCone(polynomialRing,polyhedralCone)); 344 id_Delete(&redI,polynomialRing);345 346 } 346 347 … … 558 559 gfan::ZFan* zf = new gfan::ZFan(sigma->getPolyhedralCone().ambientDimension()); 559 560 for (; sigma!=setOfCones.end(); sigma++) 560 zf->insert(sigma->getPolyhedralCone()); 561 { 562 gfan::ZCone zc = sigma->getPolyhedralCone(); 563 assume(isCompatible(zf,&zc)); 564 zf->insert(zc); 565 } 561 566 return zf; 562 567 } -
Singular/dyn_modules/gfanlib/initial.cc
rf16226 r7723d00 41 41 { 42 42 p_Delete(&q0,r); 43 q0 = p_Head( p,r);43 q0 = p_Head(currentTerm,r); 44 44 q1 = q0; 45 45 d = e; -
Singular/dyn_modules/gfanlib/ppinitialReduction.h
rf16226 r7723d00 11 11 void pReduce(ideal &I, const number p, const ring r); 12 12 bool ppreduceInitially(ideal I, const ring r, const number p); 13 BOOLEAN ppreduceInitially(leftv res, leftv args); 13 /* BOOLEAN ppreduceInitially(leftv res, leftv args); */ 14 14 15 15 #ifndef NDEBUG -
Singular/dyn_modules/gfanlib/tropical.cc
rf16226 r7723d00 67 67 68 68 69 gfan::ZCone groebnerCone(const ideal I, const ring r, const gfan::ZVector &w) 70 { 71 int n = rVar(r); 72 poly g = NULL; 73 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int)); 74 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int)); 75 gfan::ZVector leadexpw = gfan::ZVector(n); 76 gfan::ZVector tailexpw = gfan::ZVector(n); 77 78 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 79 for (int i=0; i<idSize(I); i++) 80 { 81 g = (poly) I->m[i]; 82 if (g!=NULL) 83 { 84 p_GetExpV(g,leadexpv,currRing); 85 leadexpw = intStar2ZVector(n, leadexpv); 86 pIter(g); 87 while (g!=NULL) 88 { 89 pGetExpV(g,tailexpv); 90 tailexpw = intStar2ZVector(n, tailexpv); 91 inequalities.appendRow(leadexpw-tailexpw); 92 pIter(g); 93 } 94 } 95 } 96 97 ideal inI = initial(I,currRing,w); 98 gfan::ZMatrix equations = gfan::ZMatrix(0,n); 99 for (int i=0; i<idSize(I); i++) 100 { 101 g = (poly) inI->m[i]; 102 if (g!=NULL) 103 { 104 p_GetExpV(g,leadexpv,currRing); 105 leadexpw = intStar2ZVector(n, leadexpv); 106 pIter(g); 107 while (g!=NULL) 108 { 109 pGetExpV(g,tailexpv); 110 tailexpw = intStar2ZVector(n, tailexpv); 111 equations.appendRow(leadexpw-tailexpw); 112 pIter(g); 113 } 114 } 115 } 116 117 omFreeSize(leadexpv,(n+1)*sizeof(int)); 118 omFreeSize(tailexpv,(n+1)*sizeof(int)); 119 id_Delete(&inI,currRing); 120 return gfan::ZCone(inequalities,equations); 121 } 122 123 69 124 BOOLEAN groebnerCone(leftv res, leftv args) 70 125 { … … 73 128 { 74 129 leftv v = u->next; 75 if (v == NULL) 76 { 77 int n = currRing->N; 130 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) 131 { 78 132 ideal I = (ideal) u->Data(); 79 poly g = NULL; 80 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int)); 81 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int)); 82 gfan::ZVector leadexpw = gfan::ZVector(n); 83 gfan::ZVector tailexpw = gfan::ZVector(n); 84 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 85 gfan::ZMatrix equations = gfan::ZMatrix(0,n); 86 long d; 87 for (int i=0; i<IDELEMS(I); i++) 88 { 89 g = (poly) I->m[i]; pGetExpV(g,leadexpv); 90 leadexpw = intStar2ZVector(n, leadexpv); 91 pIter(g); 92 d = p_Deg(g,currRing); 93 while ((g != NULL) && (p_Deg(g,currRing) == d)) 94 { 95 pGetExpV(g,tailexpv); 96 tailexpw = intStar2ZVector(n, tailexpv); 97 equations.appendRow(leadexpw-tailexpw); 98 pIter(g); 99 } 100 101 if (g != NULL) 102 { 103 while (g != NULL) 104 { 105 pGetExpV(g,tailexpv); 106 tailexpw = intStar2ZVector(n, tailexpv); 107 inequalities.appendRow(leadexpw-tailexpw); 108 pIter(g); 109 } 110 } 111 } 112 gfan::ZCone* gCone = new gfan::ZCone(inequalities,equations); 113 omFreeSize(leadexpv,(n+1)*sizeof(int)); 114 omFreeSize(tailexpv,(n+1)*sizeof(int)); 115 133 gfan::ZVector* weightVector; 134 if (v->Typ() == INTVEC_CMD) 135 { 136 intvec* w0 = (intvec*) v->Data(); 137 bigintmat* w1 = iv2bim(w0,coeffs_BIGINT); 138 w1->inpTranspose(); 139 weightVector = bigintmatToZVector(*w1); 140 delete w1; 141 } 142 else 143 { 144 bigintmat* w1 = (bigintmat*) v->Data(); 145 weightVector = bigintmatToZVector(*w1); 146 } 116 147 res->rtyp = coneID; 117 res->data = (void*) gCone; 148 res->data = (void*) new gfan::ZCone(groebnerCone(I,currRing,*weightVector)); 149 delete weightVector; 118 150 return FALSE; 119 151 } … … 124 156 125 157 126 gfan::ZCone * maximalGroebnerCone(const ring &r, const ideal &I)158 gfan::ZCone maximalGroebnerCone(const ideal &I, const ring &r) 127 159 { 128 160 int n = rVar(r); … … 148 180 omFreeSize(leadexpv,(n+1)*sizeof(int)); 149 181 omFreeSize(tailexpv,(n+1)*sizeof(int)); 150 return newgfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth()));182 return gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth())); 151 183 } 152 184 … … 162 194 ideal I = (ideal) u->Data(); 163 195 res->rtyp = coneID; 164 res->data = (void*) maximalGroebnerCone(currRing, I);196 res->data = (void*) new gfan::ZCone(maximalGroebnerCone(I,currRing)); 165 197 return FALSE; 166 198 } … … 277 309 // p->iiAddCproc("","ppreduceInitially",FALSE,ppreduceInitially); 278 310 // p->iiAddCproc("","ttreduceInitially",FALSE,ttreduceInitially); 279 p->iiAddCproc("","homogeneitySpace",FALSE,homogeneitySpace); 280 } 311 } -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
rf16226 r7723d00 150 150 151 151 poly mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,w); 152 if (mons) 153 { 154 // std::cout << "computing witness in tropical star!" << std::endl; 155 poly gs = witness(mons,inIsSTD,ininIs,s); 152 if (mons!=NULL) 153 { 154 poly gs; 155 if (pNext(mons)==NULL) 156 gs = witness(mons,inIsSTD,ininIs,s); 157 else 158 gs = p_Copy(mons,s); 156 159 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d); 157 160 nMapFunc mMap = n_SetMap(s->cf,r->cf); … … 190 193 191 194 mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,wNeg); 192 if (mons) 193 { 194 poly gs = witness(mons,inIsSTD,ininIs,s); 195 if (mons!=NULL) 196 { 197 poly gs; 198 if (pNext(mons)==NULL) 199 gs = witness(mons,inIsSTD,ininIs,s); 200 else 201 gs = p_Copy(mons,s); 195 202 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d); 196 203 nMapFunc mMap = n_SetMap(s->cf,r->cf); … … 231 238 for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++) 232 239 { 233 assume(zc->dimensionOfLinealitySpace()+1 == zc->dimension()); 234 gfan::ZMatrix ray = zc->extremeRays(); 235 raysOfC.appendRow(ray[0]); 240 assume(zc->dimensionOfLinealitySpace()+1 >= zc->dimension()); 241 if (zc->dimensionOfLinealitySpace()+1 >= zc->dimension()) 242 raysOfC.appendRow(zc->getRelativeInteriorPoint()); 243 else 244 { 245 gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint(); 246 if (!currentStrategy->homogeneitySpaceContains(interiorPoint)) 247 { 248 raysOfC.appendRow(interiorPoint); 249 raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint)); 250 } 251 else 252 { 253 gfan::ZMatrix zm = zc->generatorsOfLinealitySpace(); 254 for (int i=0; i<zm.getHeight(); i++) 255 { 256 gfan::ZVector point = zm[i]; 257 if (currentStrategy->homogeneitySpaceContains(point)) 258 { 259 raysOfC.appendRow(point); 260 raysOfC.appendRow(currentStrategy->negateWeight(point)); 261 break; 262 } 263 } 264 } 265 } 236 266 } 237 267 } … … 240 270 for (ZConesSortedByDimension::iterator zc=C.begin(); zc!=C.end(); zc++) 241 271 { 242 assume(zc->dimensionOfLinealitySpace()+2 == zc->dimension()); 243 raysOfC.appendRow(zc->getRelativeInteriorPoint()); 272 assume(zc->dimensionOfLinealitySpace()+2 >= zc->dimension()); 273 if (zc->dimensionOfLinealitySpace()+2 == zc->dimension()) 274 raysOfC.appendRow(zc->getRelativeInteriorPoint()); 275 else 276 { 277 gfan::ZVector interiorPoint = zc->getRelativeInteriorPoint(); 278 if (!currentStrategy->homogeneitySpaceContains(interiorPoint)) 279 { 280 raysOfC.appendRow(interiorPoint); 281 raysOfC.appendRow(currentStrategy->negateWeight(interiorPoint)); 282 } 283 else 284 { 285 gfan::ZMatrix zm = zc->generatorsOfLinealitySpace(); 286 for (int i=0; i<zm.getHeight(); i++) 287 { 288 gfan::ZVector point = zm[i]; 289 if (currentStrategy->homogeneitySpaceContains(point)) 290 { 291 raysOfC.appendRow(point); 292 raysOfC.appendRow(currentStrategy->negateWeight(point)); 293 break; 294 } 295 } 296 } 297 } 244 298 } 245 299 } -
Singular/dyn_modules/gfanlib/tropicalStrategy.cc
rf16226 r7723d00 458 458 poly tropicalStrategy::checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector w) const 459 459 { 460 int k = idSize(I); 461 for (int i=0; i<k; i++) 462 { 463 poly g = I->m[i]; 464 if (pNext(g)==NULL && (isValuationTrivial() || n_IsOne(p_GetCoeff(g,r),r->cf))) 465 { 466 poly monomial = p_Copy(g,r); 467 return monomial; 468 } 469 } 460 470 // prepend extra weight for homogeneity 461 471 // switch to residue field if valuation is non trivial … … 465 475 // if switched to residue field, remove possibly 0 elements 466 476 ideal inI = initial(I,r,w); 467 int k = idSize(inI);468 477 ideal inIShortcut = idInit(k); 469 478 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf); -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
rf16226 r7723d00 232 232 233 233 /** 234 * returns true, if v is contained in the homogeneity space; false otherwise 235 */ 236 bool homogeneitySpaceContains(const gfan::ZVector &v) const 237 { 238 return linealitySpace.contains(v); 239 } 240 241 /** 234 242 * returns true, if valuation non-trivial, false otherwise 235 243 */
Note: See TracChangeset
for help on using the changeset viewer.