Changeset dffd154 in git
- Timestamp:
- Sep 20, 2014, 1:53:38 AM (9 years ago)
- Branches:
- (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
- Children:
- 4664b33f793e7e511d9722557720dd523ec89856
- Parents:
- b71400abefd0c9c66c0009063f40ddd5b1f1c4c7
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2014-09-20 01:53:38+02:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:05+01:00
- Location:
- Singular/dyn_modules/gfanlib
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/groebnerCone.cc
rb71400a rdffd154 31 31 static bool checkOrderingAndCone(const ring r, const gfan::ZCone zc) 32 32 { 33 return true; 33 34 if (r) 34 35 { … … 175 176 } 176 177 omFreeSize(expv,(n+1)*sizeof(int)); 177 if (currentStrategy->restrictToLowerHalfSpace())178 {179 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);180 lowerHalfSpaceCondition[0] = -1;181 inequalities.appendRow(lowerHalfSpaceCondition);182 }178 // if (currentStrategy->restrictToLowerHalfSpace()) 179 // { 180 // gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 181 // lowerHalfSpaceCondition[0] = -1; 182 // inequalities.appendRow(lowerHalfSpaceCondition); 183 // } 183 184 184 185 polyhedralCone = gfan::ZCone(inequalities,equations); … … 238 239 } 239 240 omFreeSize(expv,(n+1)*sizeof(int)); 240 if (currentStrategy->restrictToLowerHalfSpace())241 {242 gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);243 lowerHalfSpaceCondition[0] = -1;244 inequalities.appendRow(lowerHalfSpaceCondition);245 }241 // if (currentStrategy->restrictToLowerHalfSpace()) 242 // { 243 // gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n); 244 // lowerHalfSpaceCondition[0] = -1; 245 // inequalities.appendRow(lowerHalfSpaceCondition); 246 // } 246 247 247 248 polyhedralCone = gfan::ZCone(inequalities,equations); … … 439 440 * to obtain an initial form with respect to interiorPoint+e*facetNormal, 440 441 * for e>0 sufficiently small */ 441 std::pair<ideal,ring> flipped = currentStrategy->getFlip( polynomialIdeal,reducedPolynomialIdeal,polynomialRing,interiorPoint,facetNormal);442 std::pair<ideal,ring> flipped = currentStrategy->getFlip(reducedPolynomialIdeal,polynomialRing,interiorPoint,facetNormal); 442 443 assume(checkPolynomialInput(flipped.first,flipped.second)); 443 444 groebnerCone flippedCone(flipped.first, flipped.second, interiorPoint, facetNormal, *currentStrategy); -
Singular/dyn_modules/gfanlib/ppinitialReduction.cc
rb71400a rdffd154 29 29 * with respect to p-t 30 30 **/ 31 staticbool pReduce(poly &g, const number p, const ring r)31 bool pReduce(poly &g, const number p, const ring r) 32 32 { 33 33 if (g==NULL) … … 92 92 } 93 93 94 void ptNormalize(poly* gStar, const number p, const ring r) 95 { 96 poly g = *gStar; 97 if (g==NULL || n_DivBy(p_GetCoeff(g,r),p,r->cf)) 98 return; 99 p_Test(g,r); 100 101 // create p-t 102 poly pt = p_Init(r); 103 p_SetCoeff(pt,n_Copy(p,r->cf),r); 104 105 pNext(pt) = p_Init(r); 106 p_SetExp(pNext(pt),1,1,r); 107 p_Setm(pNext(pt),r); 108 p_SetCoeff(pNext(pt),n_Init(-1,r->cf),r); 109 110 // make g monic with the help of p-t 111 number a,b; 112 number gcd = n_ExtGcd(p_GetCoeff(g,r),p,&a,&b,r->cf); 113 assume(n_IsUnit(gcd,r->cf)); 114 // now a*leadcoef(g)+b*p = gcd with gcd being a unit 115 // so a*g+b*(p-t)*leadmonom(g) should have a unit as leading coefficient 116 // but first check whether b is 0, 117 // since p_Mult_nn doesn't allow 0 as number input 118 if (n_IsZero(b,r->cf)) 119 { 120 n_Delete(&a,r->cf); 121 n_Delete(&b,r->cf); 122 n_Delete(&gcd,r->cf); 123 p_Delete(&pt,r); 124 return; 125 } 126 poly m = p_Head(g,r); 127 p_SetCoeff(m,n_Init(1,r->cf),r); 128 g = p_Add_q(p_Mult_nn(g,a,r),p_Mult_nn(p_Mult_mm(pt,m,r),b,r),r); 129 n_Delete(&a,r->cf); 130 n_Delete(&b,r->cf); 131 n_Delete(&gcd,r->cf); 132 p_Delete(&m,r); 133 134 p_Test(g,r); 135 return; 136 } 137 138 void ptNormalize(ideal I, const number p, const ring r) 139 { 140 for (int i=0; i<idSize(I); i++) 141 ptNormalize(&(I->m[i]),p,r); 142 return; 143 } 144 94 145 #ifndef NDEBUG 95 146 BOOLEAN pppReduce(leftv res, leftv args) … … 140 191 * assumes that h and g are in pReduced form and homogeneous in x of the same degree 141 192 **/ 142 bool ppreduceInitially(poly &h, const poly g, const ring r) 143 { 193 bool ppreduceInitially(poly* hStar, const poly g, const ring r) 194 { 195 poly h = *hStar; 144 196 if (h==NULL || g==NULL) 145 197 return false; … … 163 215 h = p_Add_q(q1,q2,r); 164 216 p_Test(h,r); 217 hStar = &h; 165 218 return true; 166 219 } … … 183 236 h = (poly) u->CopyD(); 184 237 g = (poly) v->CopyD(); 185 (void)ppreduceInitially( h,g,currRing);238 (void)ppreduceInitially(&h,g,currRing); 186 239 p_Delete(&h,currRing); 187 240 p_Delete(&g,currRing); … … 190 243 h = (poly) u->CopyD(); 191 244 g = (poly) v->CopyD(); 192 (void)ppreduceInitially( h,g,currRing);245 (void)ppreduceInitially(&h,g,currRing); 193 246 p_Delete(&g,currRing); 194 247 res->rtyp = POLY_CMD; … … 233 286 for (int i=0; i<m-1; i++) 234 287 for (int j=i+1; j<m; j++) 235 if (ppreduceInitially( I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;288 if (ppreduceInitially(&I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true; 236 289 237 290 /*** … … 240 293 for (int i=0; i<m-1; i++) 241 294 for (int j=i+1; j<m; j++) 242 if (ppreduceInitially( I->m[i], I->m[j],r) && pReduce(I->m[i],p,r)) return true;295 if (ppreduceInitially(&I->m[i], I->m[j],r) && pReduce(I->m[i],p,r)) return true; 243 296 244 297 /*** … … 309 362 **/ 310 363 for (int i=0; i<j; i++) 311 if (ppreduceInitially( I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true;364 if (ppreduceInitially(&I->m[j], I->m[i], r) && pReduce(I->m[j],p,r)) return true; 312 365 for (int k=j+1; k<n; k++) 313 if (ppreduceInitially( I->m[k], I->m[j], r) && pReduce(I->m[k],p,r)) return true;366 if (ppreduceInitially(&I->m[k], I->m[j], r) && pReduce(I->m[k],p,r)) return true; 314 367 315 368 /*** … … 319 372 for (int i=0; i<j; i++) 320 373 for (int k=j; k<n; k++) 321 if (ppreduceInitially( I->m[i], I->m[k], r) && pReduce(I->m[i],p,r)) return true;374 if (ppreduceInitially(&I->m[i], I->m[k], r) && pReduce(I->m[i],p,r)) return true; 322 375 for (int k=j+1; k<n; k++) 323 if (ppreduceInitially( I->m[j], I->m[k], r) && pReduce(I->m[j],p,r)) return true;376 if (ppreduceInitially(&I->m[j], I->m[k], r) && pReduce(I->m[j],p,r)) return true; 324 377 325 378 /*** … … 376 429 * assumes that the generators of G are homogeneous in x of lesser degree. 377 430 **/ 378 bool ppreduceInitially(ideal H, const number p, const ideal G, const ring r)431 bool ppreduceInitially(ideal &H, const number p, const ideal G, const ring r) 379 432 { 380 433 /*** … … 523 576 static std::vector<int> synchronize(const ideal I, const ideal Hi) 524 577 { 525 int k = idSize( Hi);526 int l = idSize( I);578 int k = idSize(I); 579 int l = idSize(Hi); 527 580 std::vector<int> synch(k); 528 581 int j; … … 532 585 { 533 586 if (I->m[i]==Hi->m[j]) 587 { 534 588 synch[i] = j; 589 break; 590 } 535 591 } 536 592 if (j==l) … … 544 600 for (unsigned i=0; i<synch.size(); i++) 545 601 if (synch[i]>=0) 602 { 546 603 I->m[i] = Hi->m[synch[i]]; 604 std::cout << i << " -> " << synch[i] << std::endl; 605 } 606 } 607 608 void z_Write(number p, ring r) 609 { 610 poly g = p_One(r); 611 p_SetCoeff(g,p,r); 612 p_Write(g,r); 613 return; 547 614 } 548 615 … … 551 618 * assumes that the generators of I are homogeneous in x and that p-t is in I. 552 619 */ 553 bool ppreduceInitially(ideal I, ring r,number p)620 bool ppreduceInitially(ideal I, const ring r, const number p) 554 621 { 555 622 assume(!n_IsUnit(p,r->cf)); … … 585 652 * and all lower components 586 653 **/ 587 std::vector<int> synch = synchronize(I,Hi);654 // std::vector<int> synch = synchronize(I,Hi); 588 655 if (ppreduceInitially(Hi,p,r)) return true; 589 synchronize(I,Hi,synch);656 // synchronize(I,Hi,synch); 590 657 id_Test(Hi,r); 591 658 id_Test(I,r); … … 625 692 break; 626 693 } 694 if (kH==l) 695 break; 627 696 if (p_GetExp(G->m[kG],1,r)>p_GetExp(Hi->m[kH],1,r)) 628 697 G->m[i] = G->m[kG++]; … … 631 700 } 632 701 m += l; IDELEMS(GG) = m; GG->m = &G->m[n-m]; 633 std::vector<int> synch = synchronize(I,it->second);702 // std::vector<int> synch = synchronize(I,it->second); 634 703 if (ppreduceInitially(it->second,p,GG,r)) return true; 635 synchronize(I,it->second,synch);704 // synchronize(I,it->second,synch); 636 705 idShallowDelete(&Hi); Hi = it->second; 637 706 } 638 707 idShallowDelete(&Hi); 639 708 709 ptNormalize(I,p,r); 640 710 omFreeBin((ADDRESS)GG, sip_sideal_bin); idShallowDelete(&G); 641 711 return false; -
Singular/dyn_modules/gfanlib/ppinitialReduction.h
rb71400a rdffd154 19 19 BOOLEAN ppreduceInitially(leftv res, leftv args); 20 20 21 void z_Write(number p, ring r); 22 21 23 #endif -
Singular/dyn_modules/gfanlib/singularWishlist.h
rb71400a rdffd154 69 69 } 70 70 return; 71 71 } 72 72 73 73 #endif -
Singular/dyn_modules/gfanlib/startingCone.cc
rb71400a rdffd154 336 336 { 337 337 ring r = currentStrategy.getStartingRing(); 338 const ideal I = currentStrategy.getStartingIdeal(); 338 ideal I = currentStrategy.getStartingIdeal(); 339 currentStrategy.reduce(I,r); 339 340 if (currentStrategy.isConstantCoefficientCase()) 340 341 { … … 389 390 // copy the data, so that it be deleted when passed to the loop 390 391 // s <- r 391 // in I<- I392 // inJ <- I 392 393 ring s = rCopy(r); 393 int k = idSize(I); ideal in I= idInit(k);394 int k = idSize(I); ideal inJ = idInit(k); 394 395 nMapFunc identityMap = n_SetMap(r->cf,s->cf); 395 396 for (int i=0; i<k; i++) 396 in I->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0);397 inJ->m[i] = p_PermPoly(I->m[i],NULL,r,s,identityMap,NULL,0); 397 398 398 399 // and check whether the dimension of its homogeneity space 399 400 // equals the dimension of the tropical variety 400 gfan::ZCone zc = linealitySpaceOfGroebnerFan(in I,s);401 gfan::ZCone zc = linealitySpaceOfGroebnerFan(inJ,s); 401 402 if (zc.dimension()==currentStrategy.getExpectedDimension()) 402 403 { // this shouldn't happen as trivial cases should be caught beforehand 403 404 // this is the case that the tropical variety consists soely out of the lineality space 404 groebnerCone startingCone(I,in I,s,currentStrategy);405 id_Delete(&in I,s);405 groebnerCone startingCone(I,inJ,s,currentStrategy); 406 id_Delete(&inJ,s); 406 407 rDelete(s); 407 408 return startingCone; … … 410 411 // compute a point in the tropical variety outside the lineality space 411 412 // compute the initial ideal with respect to the weight 412 std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(in I,s,currentStrategy);413 std::pair<gfan::ZVector,groebnerCone> startingData = tropicalStartingDataViaGroebnerFan(inJ,s,currentStrategy); 413 414 gfan::ZVector startingPoint = startingData.first; 414 415 groebnerCone ambientMaximalCone = groebnerCone(startingData.second); 415 id_Delete(&in I,s); rDelete(s);416 in I= ambientMaximalCone.getPolynomialIdeal();416 id_Delete(&inJ,s); rDelete(s); 417 inJ = ambientMaximalCone.getPolynomialIdeal(); 417 418 s = ambientMaximalCone.getPolynomialRing(); 418 inI = sloppyInitial(inI,s,startingPoint); 419 zc = linealitySpaceOfGroebnerFan(inI,s); 419 inJ = sloppyInitial(inJ,s,startingPoint); 420 ideal inI = initial(I,r,startingPoint); 421 zc = linealitySpaceOfGroebnerFan(inJ,s); 420 422 421 423 // and check whether the dimension of its homogeneity space … … 424 426 { // this case shouldn't happen as trivial cases should be caught beforehand 425 427 // this is the case that the tropical variety has a one-codimensional lineality space 426 ideal J = lift(I,r,in I,s);427 groebnerCone startingCone(J,in I,s,currentStrategy);428 id_Delete(&in I,s);428 ideal J = lift(I,r,inJ,s); 429 groebnerCone startingCone(J,inJ,s,currentStrategy); 430 id_Delete(&inJ,s); 429 431 id_Delete(&J,s); 430 432 return startingCone; 431 433 } 432 434 433 // from this point on, in Icontains the uniformizing parameter,435 // from this point on, inJ contains the uniformizing parameter, 434 436 // hence it contains a monomial if and only if its residue over the residue field does. 435 437 // so we will switch to the residue field … … 439 441 rComplete(rShortcut); 440 442 rTest(rShortcut); 441 k = idSize(in I);442 ideal in IShortcut = idInit(k);443 k = idSize(inJ); 444 ideal inJShortcut = idInit(k); 443 445 nMapFunc takingResidues = n_SetMap(s->cf,rShortcut->cf); 444 446 for (int i=0; i<k; i++) 445 in IShortcut->m[i] = p_PermPoly(inI->m[i],NULL,s,rShortcut,takingResidues,NULL,0);446 idSkipZeroes(in IShortcut);447 id_Delete(&in I,s);448 449 // we are interested in a maximal cone of the tropical variety of in IShortcut447 inJShortcut->m[i] = p_PermPoly(inJ->m[i],NULL,s,rShortcut,takingResidues,NULL,0); 448 idSkipZeroes(inJShortcut); 449 id_Delete(&inJ,s); 450 451 // we are interested in a maximal cone of the tropical variety of inJShortcut 450 452 // this basically equivalent to the case without valuation (or constant coefficient case) 451 453 // except that our ideal is still only homogeneous in the later variables, 452 454 // hence we set the optional parameter completelyHomogeneous as 'false' 453 tropicalStrategy shortcutStrategy(in IShortcut,rShortcut,false);455 tropicalStrategy shortcutStrategy(inJShortcut,rShortcut,false); 454 456 groebnerCone startingConeShortcut = tropicalStartingCone(shortcutStrategy); 455 id_Delete(&in IShortcut,rShortcut); rDelete(rShortcut);456 457 // now we need to obtain the initial of the residue of in I457 id_Delete(&inJShortcut,rShortcut); rDelete(rShortcut); 458 459 // now we need to obtain the initial of the residue of inJ 458 460 // with respect to a weight in the tropical cone, 459 // and obtain the initial of in Iwith respect to the same weight461 // and obtain the initial of inJ with respect to the same weight 460 462 ring sShortcut = startingConeShortcut.getPolynomialRing(); 461 in IShortcut = startingConeShortcut.getPolynomialIdeal();463 inJShortcut = startingConeShortcut.getPolynomialIdeal(); 462 464 gfan::ZCone zd = startingConeShortcut.getPolyhedralCone(); 463 465 gfan::ZVector interiorPoint = startingConeShortcut.getInteriorPoint(); 464 inIShortcut = sloppyInitial(inIShortcut,sShortcut,interiorPoint); 466 inJShortcut = sloppyInitial(inJShortcut,sShortcut,interiorPoint); 467 inI = initial(inI,r,interiorPoint); 465 468 466 469 s = rCopy0(sShortcut); // s will be a ring over the valuation ring … … 470 473 rTest(s); 471 474 472 k = idSize(in IShortcut); // inI will be overwritten with initial of inI473 in I= idInit(k+1);474 in I->m[0] = p_One(s); // with respect to that weight475 k = idSize(inJShortcut); // inJ will be overwritten with initial of inJ 476 inJ = idInit(k+1); 477 inJ->m[0] = p_One(s); // with respect to that weight 475 478 identityMap = n_SetMap(r->cf,s->cf); // first element will obviously be p 476 p_SetCoeff(in I->m[0],identityMap(currentStrategy.getUniformizingParameter(),r->cf,s->cf),s);479 p_SetCoeff(inJ->m[0],identityMap(currentStrategy.getUniformizingParameter(),r->cf,s->cf),s); 477 480 nMapFunc findingRepresentatives = n_SetMap(sShortcut->cf,s->cf); 478 481 for (int i=0; i<k; i++) // and then come the rest 479 in I->m[i+1] = p_PermPoly(inIShortcut->m[i],NULL,sShortcut,s,findingRepresentatives,NULL,0);480 481 ideal J = lift(I,r,inI,s);482 inJ->m[i+1] = p_PermPoly(inJShortcut->m[i],NULL,sShortcut,s,findingRepresentatives,NULL,0); 483 484 ideal J = currentStrategy.computeLift(inJ,s,inI,I,r); 482 485 // currentStrategy.reduce(J,s); 483 groebnerCone startingCone(J,in I,s,currentStrategy);484 id_Delete(&in I,s);486 groebnerCone startingCone(J,inJ,s,currentStrategy); 487 id_Delete(&inJ,s); 485 488 id_Delete(&J,s); 486 489 rDelete(s); 490 id_Delete(&inI,r); 487 491 488 492 assume(checkContainmentInTropicalVariety(startingCone)); -
Singular/dyn_modules/gfanlib/std_wrapper.h
rb71400a rdffd154 2 2 #define CALLGFANLIB_STD_WRAPPER_H 3 3 4 #include < kernel/GBEngine/kstd1.h>5 #include <kernel/ polys.h>4 #include <libpolys/polys/simpleideals.h> 5 #include <kernel/structs.h> 6 6 7 7 ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog); -
Singular/dyn_modules/gfanlib/tropicalStrategy.cc
rb71400a rdffd154 9 9 #include <kernel/ideals.h> 10 10 #include <kernel/GBEngine/stairc.h> 11 #include <kernel/GBEngine/kstd1.h> 11 12 #include <Singular/ipshell.h> // for isPrime(int i) 12 13 … … 48 49 * Initializes all relevant structures and information for the trivial valuation case, 49 50 * i.e. computing a tropical variety without any valuation. 50 *g51 51 */ 52 52 tropicalStrategy::tropicalStrategy(const ideal I, const ring r, … … 67 67 { 68 68 assume(rField_is_Q(r) || rField_is_Zp(r)); 69 startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);70 69 if (!completelyHomogeneous) 71 70 { … … 127 126 } 128 127 return rCopy(r); 128 } 129 130 static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing) 131 { 132 // construct p-t 133 poly g = p_One(startingRing); 134 p_SetCoeff(g,uniformizingParameter,startingRing); 135 pNext(g) = p_One(startingRing); 136 p_SetExp(pNext(g),1,1,startingRing); 137 p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing); 138 p_Setm(pNext(g),startingRing); 139 ideal pt = idInit(1); 140 pt->m[0] = g; 141 142 // map originalIdeal from originalRing into startingRing 143 int k = idSize(originalIdeal); 144 ideal J = idInit(k+1); 145 nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf); 146 int n = rVar(originalRing); 147 int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int)); 148 for (int i=1; i<=n; i++) 149 shiftByOne[i]=i+1; 150 for (int i=0; i<k; i++) 151 J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0); 152 omFreeSize(shiftByOne,(n+1)*sizeof(int)); 153 154 ring origin = currRing; 155 rChangeCurrRing(startingRing); 156 ideal startingIdeal = kNF(pt,startingRing->qideal,J); 157 rChangeCurrRing(origin); 158 assume(startingIdeal->m[k]==NULL); 159 startingIdeal->m[k] = pt->m[0]; 160 startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing); 161 162 id_Delete(&J,startingRing); 163 pt->m[0] = NULL; 164 id_Delete(&pt,startingRing); 165 return startingIdeal; 129 166 } 130 167 … … 149 186 /* assume that the ground field of the originalRing is Q */ 150 187 assume(rField_is_Q(s)); 151 originalRing = rCopy(s);152 188 153 189 /* replace Q with Z for the startingRing … … 160 196 161 197 /* map the input ideal into the new polynomial ring */ 162 int k = idSize(J); 163 startingIdeal = idInit(k+1); 164 poly g = p_One(startingRing); 165 p_SetCoeff(g,uniformizingParameter,startingRing); 166 pNext(g) = p_One(startingRing); 167 p_SetExp(pNext(g),1,1,startingRing); 168 p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing); 169 p_Setm(pNext(g),startingRing); 170 startingIdeal->m[0] = g; 171 int n = rVar(originalRing); 172 int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int)); 173 for (int i=1; i<=n; i++) 174 shiftByOne[i]=i+1; 175 for (int i=0; i<k; i++) 176 startingIdeal->m[i+1] = p_PermPoly(J->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0); 177 omFreeSize(shiftByOne,(n+1)*sizeof(int)); 178 startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing); 198 startingIdeal = constructStartingIdeal(J,s,uniformizingParameter,startingRing); 179 199 180 200 linealitySpace = homogeneitySpace(startingIdeal,startingRing); … … 529 549 } 530 550 551 ideal tropicalStrategy::computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const 552 { 553 int k = idSize(inJs); 554 ideal inJr = idInit(k); 555 nMapFunc identitysr = n_SetMap(s->cf,r->cf); 556 for (int i=0; i<k; i++) 557 inJr->m[i] = p_PermPoly(inJs->m[i],NULL,s,r,identitysr,NULL,0); 558 559 ideal Jr = getWitness(inJr,inIr,Ir,r); 560 nMapFunc identityrs = n_SetMap(r->cf,s->cf); 561 ideal Js = idInit(k); 562 for (int i=0; i<k; i++) 563 Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identityrs,NULL,0); 564 return Js; 565 } 566 531 567 static void deleteOrdering(ring r) 532 568 { … … 610 646 } 611 647 612 613 std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal I, const ideal redI, const ring r, 648 std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal Ir, const ring r, 614 649 const gfan::ZVector interiorPoint, 615 650 const gfan::ZVector facetNormal) const 616 651 { 617 652 assume(isValuationTrivial() || interiorPoint[0].sign()<0); 618 assume(checkForUniformizingBinomial(I ,r));653 assume(checkForUniformizingBinomial(Ir,r)); 619 654 620 655 // get a generating system of the initial ideal 621 656 // and compute a standard basis with respect to adjacent ordering 622 ideal inIr = initial( redI,r,interiorPoint);657 ideal inIr = initial(Ir,r,interiorPoint); 623 658 ring sAdjusted = copyAndChangeOrderingWP(r,interiorPoint,facetNormal); 624 659 nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf); 625 int k = idSize(I ); ideal inIsAdjusted = idInit(k);660 int k = idSize(Ir); ideal inIsAdjusted = idInit(k); 626 661 for (int i=0; i<k; i++) 627 662 inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0); … … 636 671 inJr->m[i] = p_PermPoly(inJsAdjusted->m[i],NULL,sAdjusted,r,identity,NULL,0); 637 672 638 ideal Jr = getWitness(inJr,inIr, redI,r);673 ideal Jr = getWitness(inJr,inIr,Ir,r); 639 674 ring s = copyAndChangeOrderingLS(r,interiorPoint,facetNormal); 640 675 identity = n_SetMap(r->cf,s->cf); -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
rb71400a rdffd154 40 40 /** 41 41 * the expected Dimension of the polyhedral output, 42 * i.e. the dimension of the ideal if trivial valuation43 * or the dimension of the ideal plus one if non-trivial valuation42 * i.e. the dimension of the ideal if valuation trivial 43 * or the dimension of the ideal plus one if valuation non-trivial 44 44 * (as the output is supposed to be intersected with a hyperplane) 45 45 */ … … 302 302 ideal getWitness(const ideal inJ, const ideal inI, const ideal I, const ring r) const; 303 303 304 ideal computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const; 305 304 306 /** 305 307 * given generators of the initial ideal, computes its standard basis … … 311 313 * computes the groebner cone adjacent to it 312 314 */ 313 std::pair<ideal,ring> getFlip(const ideal I , const ideal redI, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const;315 std::pair<ideal,ring> getFlip(const ideal Ir, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal) const; 314 316 }; 315 317 -
Singular/dyn_modules/gfanlib/tropicalTraversal.cc
rb71400a rdffd154 8 8 while(!workingList.empty()) 9 9 { 10 //std::cout << "starting traversal" << std::endl;10 std::cout << "starting traversal" << std::endl; 11 11 const groebnerCone sigma=*(workingList.begin()); 12 12 const groebnerCones neighbours = sigma.tropicalNeighbours(); … … 18 18 tropicalVariety.insert(sigma); 19 19 workingList.erase(sigma); 20 //std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl;21 //std::cout << "workingList.size():" << workingList.size() << std::endl;20 std::cout << "tropicalVariety.size():" << tropicalVariety.size() << std::endl; 21 std::cout << "workingList.size():" << workingList.size() << std::endl; 22 22 } 23 23 return tropicalVariety; -
Singular/dyn_modules/gfanlib/tropicalVariety.cc
rb71400a rdffd154 1 1 #include <callgfanlib_conversion.h> 2 #include <std_wrapper.h> 2 3 #include <bbfan.h> 3 4 #include <groebnerCone.h> … … 36 37 if (v==NULL) 37 38 { 39 setOptionRedSB(); 40 if (!hasFlag(u,FLAG_STD)) 41 I = gfanlib_kStd_wrapper(I,currRing); 38 42 tropicalStrategy currentStrategy(I,currRing); 39 setOptionRedSB();40 43 gfan::ZFan* tropI = tropicalVariety(currentStrategy); 41 undoSetOptionRedSB();42 44 res->rtyp = fanID; 43 45 res->data = (char*) tropI; 46 undoSetOptionRedSB(); 44 47 return FALSE; 45 48 } … … 47 50 { 48 51 number p = (number) v->CopyD(); 52 if (!hasFlag(u,FLAG_STD)) 53 I = gfanlib_kStd_wrapper(I,currRing); 49 54 tropicalStrategy currentStrategy(I,p,currRing); 50 55 gfan::ZFan* tropI = tropicalVariety(currentStrategy); -
Singular/dyn_modules/gfanlib/witness.cc
rb71400a rdffd154 7 7 #include <utility> 8 8 9 /***10 * Given f and G={g1,...,gk}, computes Q=(q1,...,qk) such that11 * f = q1*g1+...+qk*gk12 * is a determinate division with remainder with respect to the13 * ordering active in r.14 * Returns an error if this is not possible.15 **/16 9 matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r) 17 10 { … … 26 19 } 27 20 28 /**29 * Given F[0],...,F[l] and G[0],...,G[k],30 * computes Q[i,j] for i=0,..,k and j=0,...,l such that31 * F[j] = Q[0,j]*G[0]+...+Q[k,j]*G[k].32 */33 21 matrix divisionDiscardingRemainder(const ideal F, const ideal G, const ring r) 34 22 { … … 44 32 } 45 33 46 #ifndef NDEBUG47 BOOLEAN dwr0(leftv res, leftv args)48 {49 leftv u = args;50 leftv v = u->next;51 poly f = (poly) u->CopyD();52 ideal G = (ideal) v->CopyD();53 omUpdateInfo();54 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);55 matrix Q = divisionDiscardingRemainder(f,G,currRing);56 p_Delete(&f,currRing);57 id_Delete(&G,currRing);58 res->rtyp = MATRIX_CMD;59 res->data = (char*) Q;60 return FALSE;61 }62 #endif63 64 /***65 * Let w be the uppermost weight vector in the matrix defining the ordering on r.66 * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w.67 * Given an w-homogeneous element m of inI, computes a witness g of m in I,68 * i.e. g in I such that in_w(g)=m.69 **/70 34 poly witness(const poly m, const ideal I, const ideal inI, const ring r) 71 35 { … … 86 50 } 87 51 88 #ifndef NDEBUG89 BOOLEAN witness0(leftv res, leftv args)90 {91 leftv u = args;92 leftv v = u->next;93 leftv w = v->next;94 poly m = (poly) u->CopyD();95 ideal G = (ideal) v->CopyD();96 ideal inG = (ideal) w->CopyD();97 omUpdateInfo();98 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes);99 poly f = witness(m,G,inG,currRing);100 p_Delete(&m,currRing);101 id_Delete(&G,currRing);102 id_Delete(&inG,currRing);103 res->rtyp = POLY_CMD;104 res->data = (char*) f;105 return FALSE;106 }107 #endif108 109 /***110 * Let w be the uppermost weight vector in the matrix defining the ordering on r.111 * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w.112 * Given an w-homogeneous element m of inI, computes a witness g of m in I,113 * i.e. g in I such that in_w(g)=m.114 **/115 52 ideal witness(const ideal inI, const ideal J, const ring r) 116 53 { … … 132 69 return I; 133 70 } 71 72 #ifndef NDEBUG 73 BOOLEAN dwrDebug(leftv res, leftv args) 74 { 75 leftv u = args; 76 leftv v = u->next; 77 ideal F = (ideal) u->CopyD(); 78 ideal G = (ideal) v->CopyD(); 79 omUpdateInfo(); 80 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 81 matrix Q = divisionDiscardingRemainder(F,G,currRing); 82 id_Delete(&F,currRing); 83 id_Delete(&G,currRing); 84 res->rtyp = MATRIX_CMD; 85 res->data = (char*) Q; 86 return FALSE; 87 } 88 89 BOOLEAN witnessDebug(leftv res, leftv args) 90 { 91 leftv u = args; 92 leftv v = u->next; 93 ideal inI = (ideal) u->CopyD(); 94 ideal J = (ideal) v->CopyD(); 95 omUpdateInfo(); 96 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 97 ideal I = witness(inI,J,currRing); 98 id_Delete(&inI,currRing); 99 id_Delete(&J,currRing); 100 res->rtyp = IDEAL_CMD; 101 res->data = (char*) I; 102 return FALSE; 103 } 104 #endif -
Singular/dyn_modules/gfanlib/witness.h
rb71400a rdffd154 5 5 #include <libpolys/polys/simpleideals.h> 6 6 7 /** 8 * Computes a division discarding remainder of f with respect to G. 9 * Given f a polynomial and G={g1,...,gk} a set of polynomials in r, 10 * returns a matrix Q=(q1,...,qk) over r such that 11 * f = q1*g1+...+qk*gk+s 12 * is a determinate division with remainder s. 13 */ 7 14 matrix divisionDiscardingRemainder(const poly f, const ideal G, const ring r); 15 16 /** 17 * Computes a division discarding remainder of F with respect to G. 18 * Given F={f1,...,fl} and G={g1,...,gk} two sets of polynomials in r, 19 * returns a matrix Q=(qij) i=1,..,k j=1,...,l over r such that 20 * fj = q1j*g1+...+qkj*gk+sj 21 * is a determinate division with remainder sj for all j=1,...,l. 22 */ 8 23 matrix divisionDiscardingRemainder(const ideal F, const ideal G, const ring r); 24 25 /** 26 * Let w be the uppermost weight vector in the matrix defining the ordering on r. 27 * Let I be a Groebner basis of an ideal in r, inI its initial form with respect w. 28 * Given an w-homogeneous element m of inI, computes a witness g of m in I, 29 * i.e. g in I such that in_w(g)=m. 30 */ 9 31 poly witness(const poly m, const ideal I, const ideal inI, const ring r); 32 33 /** 34 * Computes witnesses in J for inI 35 * Given inI={h1,...,hl} and J={g1,...,gk} two sets of polynomials in r, 36 * returns a set I={f1,...,fl} of <g1,...,gk> such that 37 * in_w(fj)=hj for all j=1,...,l, 38 * where w denotes the uppoermost weight vector in the matrix defining the ordering on r. 39 * Assumes that hj is an element of <in_w(g1),...,in_w(gk)> 40 */ 10 41 ideal witness(const ideal inI, const ideal J, const ring r); 11 42 12 43 #ifndef NDEBUG 13 44 #include <Singular/ipid.h> 14 15 BOOLEAN dwr0(leftv res, leftv args); 16 BOOLEAN witness0(leftv res, leftv args); 45 BOOLEAN dwrDebug(leftv res, leftv args); 46 BOOLEAN witnessDebug(leftv res, leftv args); 17 47 #endif 18 48
Note: See TracChangeset
for help on using the changeset viewer.