Changeset 08b7c2a in git
- Timestamp:
- Feb 4, 2015, 11:29:46 PM (9 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 7cb46755d168b8a6622fc01364fe4ca055f20f4b
- Parents:
- 7723d00a58aba67b90f5f607a5018d386f4f8465
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-04 23:29:46+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:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/groebnerCone.cc
r7723d00 r08b7c2a 408 408 if (currentStrategy->restrictToLowerHalfSpace() && R[i][0].sign()==0) 409 409 continue; 410 poly s = currentStrategy->checkInitialIdealForMonomial(I,r,R[i]); 411 if (s==NULL) 412 { 413 p_Delete(&s,r); 410 std::pair<poly,int> s = currentStrategy->checkInitialIdealForMonomial(I,r,R[i]); 411 if (s.first==NULL) 412 { 413 if (s.second<0) 414 // if monomial was initialized, delete it 415 p_Delete(&s.first,r); 414 416 return R[i]; 415 417 } -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
r7723d00 r08b7c2a 147 147 148 148 ideal inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog); 149 id_Delete(&inIs,s); 149 150 ideal ininIs = initial(inIsSTD,s,w,W); 150 151 151 poly mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s,w); 152 if (mons!=NULL) 152 std::pair<poly,int> mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s); 153 154 if (mons.first!=NULL) 153 155 { 154 156 poly gs; 155 if (pNext(mons)==NULL) 156 gs = witness(mons,inIsSTD,ininIs,s); 157 if (mons.second>=0) 158 // cheap way out, ininIsSTD already contains a monomial in its generators 159 gs = inIsSTD->m[mons.second]; 157 160 else 158 gs = p_Copy(mons,s); 161 // compute witness 162 gs = witness(mons.first,inIsSTD,ininIs,s); 163 159 164 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d); 160 165 nMapFunc mMap = n_SetMap(s->cf,r->cf); … … 162 167 idInsertPoly(inI,gr); 163 168 k++; 164 p_Delete(&mons,s); 165 p_Delete(&gs,s); 166 zc = C.begin(); 167 // gfan::ZFan* zf = toFanStar(C); 168 // std::cout << zf->toString(2+4+8+128) << std::endl; 169 // delete zf; 170 id_Delete(&inIs,s); 169 170 if (mons.second<0) 171 { 172 // if necessary, cleanup mons and gs 173 p_Delete(&mons.first,s); 174 p_Delete(&gs,s); 175 } 176 // cleanup rest, reset zc 171 177 id_Delete(&inIsSTD,s); 172 178 id_Delete(&ininIs,s); 173 179 rDelete(s); 180 zc = C.begin(); 174 181 } 175 182 else 176 183 { 177 id_Delete(&inIs,s);184 // cleanup remaining data of first stage 178 185 id_Delete(&inIsSTD,s); 179 186 id_Delete(&ininIs,s); … … 190 197 191 198 inIsSTD = gfanlib_kStd_wrapper(inIs,s,isHomog); 199 id_Delete(&inIs,s); 192 200 ininIs = initial(inIsSTD,s,wNeg,W); 193 201 194 mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s ,wNeg);195 if (mons !=NULL)202 mons = currentStrategy->checkInitialIdealForMonomial(ininIs,s); 203 if (mons.first!=NULL) 196 204 { 197 205 poly gs; 198 if (pNext(mons)==NULL) 199 gs = witness(mons,inIsSTD,ininIs,s); 206 if (mons.second>=0) 207 // cheap way out, ininIsSTD already contains a monomial in its generators 208 gs = inIsSTD->m[mons.second]; 200 209 else 201 gs = p_Copy(mons,s); 210 // compute witness 211 gs = witness(mons.first,inIsSTD,ininIs,s); 212 202 213 C = intersect(C,tropicalVarietySortedByDimension(gs,s,currentStrategy),d); 203 214 nMapFunc mMap = n_SetMap(s->cf,r->cf); … … 205 216 idInsertPoly(inI,gr); 206 217 k++; 207 p_Delete(&mons,s); 208 p_Delete(&gs,s); 218 219 if (mons.second<0) 220 { 221 // if necessary, cleanup mons and gs 222 p_Delete(&mons.first,s); 223 p_Delete(&gs,s); 224 } 225 // reset zc 209 226 zc = C.begin(); 210 // gfan::ZFan* zf = toFanStar(C);211 // std::cout << zf->toString();212 // delete zf;213 227 } 214 228 else 215 229 zc++; 216 id_Delete(&inIs,s);230 // cleanup remaining data of second stage 217 231 id_Delete(&inIsSTD,s); 218 232 id_Delete(&ininIs,s); -
Singular/dyn_modules/gfanlib/tropicalStrategy.cc
r7723d00 r08b7c2a 456 456 } 457 457 458 poly tropicalStrategy::checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector w) const 459 { 458 std::pair<poly,int> tropicalStrategy::checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w) const 459 { 460 // quick check whether I already contains an ideal 460 461 int k = idSize(I); 461 462 for (int i=0; i<k; i++) … … 463 464 poly g = I->m[i]; 464 465 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 } 470 // prepend extra weight for homogeneity 471 // switch to residue field if valuation is non trivial 472 ring rShortcut = getShortcutRingPrependingWeight(r,w); 473 474 // compute the initial ideal and map it into the constructed ring 475 // if switched to residue field, remove possibly 0 elements 476 ideal inI = initial(I,r,w); 477 ideal inIShortcut = idInit(k); 478 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf); 479 for (int i=0; i<k; i++) 480 inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,intoShortcut,NULL,0); 481 if (isValuationNonTrivial()) 482 idSkipZeroes(inIShortcut); 466 return std::pair<poly,int>(g,i); 467 } 468 469 ring rShortcut; 470 ideal inIShortcut; 471 if (w.size()>0) 472 { 473 // if needed, prepend extra weight for homogeneity 474 // switch to residue field if valuation is non trivial 475 rShortcut = getShortcutRingPrependingWeight(r,w); 476 477 // compute the initial ideal and map it into the constructed ring 478 // if switched to residue field, remove possibly 0 elements 479 ideal inI = initial(I,r,w); 480 inIShortcut = idInit(k); 481 nMapFunc intoShortcut = n_SetMap(r->cf,rShortcut->cf); 482 for (int i=0; i<k; i++) 483 inIShortcut->m[i] = p_PermPoly(inI->m[i],NULL,r,rShortcut,intoShortcut,NULL,0); 484 if (isValuationNonTrivial()) 485 idSkipZeroes(inIShortcut); 486 id_Delete(&inI,r); 487 } 488 else 489 { 490 rShortcut = r; 491 inIShortcut = I; 492 } 483 493 484 494 // check initial ideal for monomial and 485 495 // if it exsists, return a copy of the monomial in the input ring 486 496 poly p = checkForMonomialViaSuddenSaturation(inIShortcut,rShortcut); 487 poly monomial = NULL; int n = rVar(r);497 poly monomial = NULL; 488 498 if (p!=NULL) 489 499 { 490 500 monomial=p_One(r); 491 for (int i=1; i<= n; i++)501 for (int i=1; i<=rVar(r); i++) 492 502 p_SetExp(monomial,i,p_GetExp(p,i,rShortcut),r); 493 503 p_Delete(&p,rShortcut); 494 504 } 495 id_Delete(&inI,r); 496 id_Delete(&inIShortcut,rShortcut); 497 rDelete(rShortcut); 498 return monomial; 505 506 507 if (w.size()>0) 508 { 509 // if needed, cleanup 510 id_Delete(&inIShortcut,rShortcut); 511 rDelete(rShortcut); 512 } 513 return std::pair<poly,int>(monomial,-1); 499 514 } 500 515 -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
r7723d00 r08b7c2a 306 306 * In both cases returns a monomial, if it contains one, returns NULL otherwise. 307 307 **/ 308 poly checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVectorw=0) const;308 std::pair<poly,int> checkInitialIdealForMonomial(const ideal I, const ring r, const gfan::ZVector &w=0) const; 309 309 310 310 /** -
Singular/dyn_modules/gfanlib/tropicalTraversal.cc
r7723d00 r08b7c2a 48 48 workingList.insert(startingCone); 49 49 const tropicalStrategy* currentStrategy=startingCone.getTropicalStrategy(); 50 // std::cout << "starting traversal" << std::endl;51 50 while(!workingList.empty()) 52 51 { … … 54 53 * Pick an element the working list and compute interior points on its facets 55 54 */ 56 // std::cout << "picking cone and computing interior facet points..." << std::endl;57 55 groebnerCone sigma=*(workingList.begin()); 58 56 gfan::ZMatrix interiorPoints = interiorPointsOfFacets(sigma.getPolyhedralCone()); … … 67 65 { 68 66 ideal inI = initial(sigma.getPolynomialIdeal(),sigma.getPolynomialRing(),interiorPoint); 69 // std::cout << "picking interiorPoint and computing rays of tropical star..." << std::endl;70 67 gfan::ZMatrix normalVectors = raysOfTropicalStar(inI, 71 68 sigma.getPolynomialRing(), … … 74 71 id_Delete(&inI,sigma.getPolynomialRing()); 75 72 76 // std::cout << "checking for th neccessity to flip..." << std::endl;77 73 std::vector<bool> needToFlip = checkNecessaryFlips(tropicalVariety,workingList,interiorPoint,normalVectors); 78 74 for (int j=0; j<normalVectors.getHeight(); j++) … … 80 76 if (needToFlip[j]) 81 77 { 82 // std::cout << "flipping cone..." << std::endl;83 78 groebnerCone neighbour = sigma.flipCone(interiorPoint,normalVectors[j]); 84 79 workingList.insert(neighbour); … … 114 109 tropicalVariety.insert(sigma); 115 110 workingList.erase(sigma); 116 //std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl;117 //std::cout << "workingList.size():" << workingList.size() << std::endl;111 std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl; 112 std::cout << "workingList.size():" << workingList.size() << std::endl; 118 113 } 119 114 return tropicalVariety;
Note: See TracChangeset
for help on using the changeset viewer.