Changeset c96414 in git
- Timestamp:
- Nov 21, 2014, 3:23:43 PM (9 years ago)
- Branches:
- (u'spielwiese', 'a719bcf0b8dbc648b128303a49777a094b57592c')
- Children:
- e4c54031d2902cbf09cf0ab7914602044e166cc0
- Parents:
- 4664b33f793e7e511d9722557720dd523ec89856
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2014-11-21 15:23:43+01:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:05+01:00
- Location:
- Singular/dyn_modules/gfanlib
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/bbfan.cc
r4664b3 rc96414 309 309 leftv u=args; 310 310 if ((u != NULL) && (u->Typ() == fanID)) 311 { 312 gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 313 int d = zf->getAmbientDimension(); 314 int n = 0; 315 316 for (int i=0; i<=d; i++) 317 n = n + zf->numberOfConesOfDimension(i,0,0); 318 319 res->rtyp = INT_CMD; 320 res->data = (void*) (long) n; 321 return FALSE; 322 } 323 else 324 { 325 WerrorS("check_compatibility: unexpected parameters"); 326 return TRUE; 327 } 311 { 312 gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 313 int d = zf->getAmbientDimension(); 314 int n = 0; 315 316 for (int i=0; i<=d; i++) 317 n = n + zf->numberOfConesOfDimension(i,0,0); 318 319 res->rtyp = INT_CMD; 320 res->data = (void*) (long) n; 321 return FALSE; 322 } 323 WerrorS("ncones: unexpected parameters"); 324 return TRUE; 328 325 } 329 326 … … 332 329 leftv u=args; 333 330 if ((u != NULL) && (u->Typ() == fanID)) 334 { 335 gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 336 337 int n = 0; 338 for (int d=0; d<=zf->getAmbientDimension(); d++) 339 { n = n + zf->numberOfConesOfDimension(d,0,1); } 340 341 res->rtyp = INT_CMD; 342 res->data = (void*) (long) n; 343 return FALSE; 344 } 345 else 346 { 347 WerrorS("nmaxcones: unexpected parameters"); 348 return TRUE; 349 } 350 } 351 352 bool isCompatible(gfan::ZFan* zf, gfan::ZCone* zc) 331 { 332 gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 333 334 int n = 0; 335 for (int d=0; d<=zf->getAmbientDimension(); d++) 336 n = n + zf->numberOfConesOfDimension(d,0,1); 337 338 res->rtyp = INT_CMD; 339 res->data = (void*) (long) n; 340 return FALSE; 341 } 342 WerrorS("nmaxcones: unexpected parameters"); 343 return TRUE; 344 } 345 346 bool isCompatible(const gfan::ZFan* zf, const gfan::ZCone* zc) 353 347 { 354 348 bool b = (zf->getAmbientDimension() == zc->ambientDimension()); … … 466 460 } 467 461 } 468 // if ((u != NULL) && (u->Typ() == coneID))469 // {470 // leftv v=u->next;471 // if ((v != NULL) && (v->Typ() == coneID))472 // {473 // gfan::ZCone* zc = (gfan::ZCone*)u->Data();474 // gfan::ZCone* zd = (gfan::ZCone*)v->Data();475 // res->rtyp = INT_CMD;476 // res->data = (void*) (int) hasFace(zc,zd);477 // return FALSE;478 // }479 // }480 462 WerrorS("containsInCollection: unexpected parameters"); 481 463 return TRUE; 482 464 } 483 465 484 // BOOLEAN coneContaining(leftv res, leftv args) 485 // { 486 // leftv u=args; 487 // if ((u != NULL) && (u->Typ() == fanID)) 488 // { 489 // if ((v != NULL) && (v->Typ() == BIGINTMAT_CMD)) 490 // { 491 // gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 492 // bigintmat* vec = (bigintmat*)v->Data(); 493 // } 494 // } 495 // WerrorS("coneContaining: unexpected parameters"); 496 // return TRUE; 497 // } 466 BOOLEAN coneContaining(leftv res, leftv args) 467 { 468 leftv u=args; 469 if ((u != NULL) && (u->Typ() == fanID)) 470 { 471 leftv v=u->next; 472 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) 473 { 474 gfan::ZFan* zf = (gfan::ZFan*)u->Data(); 475 gfan::ZVector* point; 476 if (v->Typ() == INTVEC_CMD) 477 { 478 intvec* w0 = (intvec*) v->Data(); 479 bigintmat* w1 = iv2bim(w0,coeffs_BIGINT); 480 w1->inpTranspose(); 481 point = bigintmatToZVector(*w1); 482 delete w1; 483 } 484 else 485 { 486 bigintmat* w1 = (bigintmat*) v->Data(); 487 point = bigintmatToZVector(*w1); 488 } 489 lists L = (lists)omAllocBin(slists_bin); 490 res->rtyp = LIST_CMD; 491 res->data = (void*) L; 492 delete point; 493 return FALSE; 494 } 495 } 496 WerrorS("coneContaining: unexpected parameters"); 497 return TRUE; 498 } 498 499 499 500 BOOLEAN removeCone(leftv res, leftv args) -
Singular/dyn_modules/gfanlib/bbfan.h
r4664b3 rc96414 14 14 void bbfan_setup(SModulFunctions* p); 15 15 16 bool isCompatible(const gfan::ZFan* zf, const gfan::ZCone* zc); 17 16 18 int getAmbientDimension(gfan::ZFan* zf); 17 19 int getCodimension(gfan::ZFan* zf); -
Singular/dyn_modules/gfanlib/initial.cc
r4664b3 rc96414 194 194 return; 195 195 } 196 196 197 197 198 /*** … … 341 342 // return inI; 342 343 // } 343 344 // BOOLEAN initial(leftv res, leftv args)345 // {346 // leftv u = args;347 // if ((u != NULL) && (u->Typ() == POLY_CMD) && (u->next == NULL))348 // {349 // poly p = (poly) u->Data();350 // res->rtyp = POLY_CMD;351 // res->data = (void*) initial(p, currRing);352 // return FALSE;353 // }354 // if ((u != NULL) && (u->Typ() == IDEAL_CMD) && (u->next == NULL))355 // {356 // ideal I = (ideal) u->Data();357 // res->rtyp = IDEAL_CMD;358 // res->data = (void*) initial(I, currRing);359 // return FALSE;360 // }361 // WerrorS("initial: unexpected parameters");362 // return TRUE;363 // } -
Singular/dyn_modules/gfanlib/ppinitialReduction.cc
r4664b3 rc96414 1 #include < kernel/polys.h>1 #include <libpolys/polys/monomials/p_polys.h> 2 2 #include <Singular/ipid.h> 3 3 4 #include <libpolys/polys/monomials/p_polys.h>5 4 #include <singularWishlist.h> 6 #include < tropicalStrategy.h>5 #include <ppinitialReduction.h> 7 6 8 7 #include <map> 9 8 #include <set> 10 #include <iostream>11 9 #include <exception> 12 10 13 #include <ppinitialReduction.h> 14 11 12 #ifndef NDEBUG 15 13 bool isOrderingLocalInT(const ring r) 16 14 { … … 23 21 p_Delete(&t,r); 24 22 return (s==1); 23 } 24 #endif 25 26 void divideByCommonGcd(poly &g, const ring r) 27 { 28 number commonGcd = n_Copy(p_GetCoeff(g,r),r->cf); 29 for (poly gCache=pNext(g); gCache; pIter(gCache)) 30 { 31 number commonGcdCache = n_Gcd(commonGcd,p_GetCoeff(gCache,r),r->cf); 32 n_Delete(&commonGcd,r->cf); 33 commonGcd = commonGcdCache; 34 if (n_IsOne(commonGcd,r->cf)) 35 { 36 n_Delete(&commonGcd,r->cf); 37 return; 38 } 39 } 40 for (poly gCache=g; gCache; pIter(gCache)) 41 { 42 number oldCoeff = p_GetCoeff(gCache,r); 43 number newCoeff = n_Div(oldCoeff,commonGcd,r->cf); 44 p_SetCoeff(gCache,newCoeff,r); 45 } 46 p_Test(g,r); 47 n_Delete(&commonGcd,r->cf); 48 return; 25 49 } 26 50 … … 93 117 } 94 118 p_Test(g,r); 119 divideByCommonGcd(g,r); 95 120 return; 96 121 } … … 146 171 return; 147 172 } 173 174 #ifndef NDEBUG 175 BOOLEAN ptNormalize(leftv res, leftv args) 176 { 177 leftv u = args; 178 if ((u != NULL) && (u->Typ() == IDEAL_CMD)) 179 { 180 leftv v = u->next; 181 if ((v!=NULL) && (v->Typ()==NUMBER_CMD)) 182 { 183 omUpdateInfo(); 184 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 185 ideal I = (ideal) u->CopyD(); 186 number p = (number) v->CopyD(); 187 ptNormalize(I,p,currRing); 188 n_Delete(&p,currRing->cf); 189 res->rtyp = IDEAL_CMD; 190 res->data = (char*) I; 191 return FALSE; 192 } 193 } 194 return TRUE; 195 } 196 #endif //NDEBUG 148 197 149 198 #ifndef NDEBUG … … 172 221 #endif //NDEBUG 173 222 174 void pReduce 0(ideal &I, const number p, const ring r)223 void pReduce(ideal &I, const number p, const ring r) 175 224 { 176 225 int k = idSize(I); … … 188 237 189 238 190 /** *239 /** 191 240 * reduces h initially with respect to g, 192 241 * returns false if h was initially reduced in the first place, 193 242 * returns true if reductions have taken place. 194 243 * assumes that h and g are in pReduced form and homogeneous in x of the same degree 195 * */244 */ 196 245 bool ppreduceInitially(poly* hStar, const poly g, const ring r) 197 246 { … … 377 426 for (int k=j+1; k<n; k++) 378 427 if (ppreduceInitially(&I->m[k], I->m[j], r)) 428 { 379 429 pReduce(I->m[k],p,r); 430 for (int l=j+1; l<k; l++) 431 if (ppreduceInitially(&I->m[k], I->m[l], r)) 432 pReduce(I->m[k],p,r); 433 } 380 434 381 435 /*** … … 387 441 if (ppreduceInitially(&I->m[i], I->m[k], r)) 388 442 pReduce(I->m[i],p,r); 389 for (int k=j+1; k<n; k++) 390 if (ppreduceInitially(&I->m[j], I->m[k], r)) 391 pReduce(I->m[j],p,r); 443 for (int k=j; k<n-1; k++) 444 for (int l=k+1; l<n; l++) 445 if (ppreduceInitially(&I->m[k], I->m[l], r)) 446 pReduce(I->m[j],p,r); 392 447 393 448 /*** … … 533 588 * T is sorted by the ordering on the temrs the pairs correspond to. 534 589 **/ 535 int m=idSize(H) ,n=0;590 int m=idSize(H); 536 591 ideal I = idInit(m); 537 592 std::vector<mark> T; … … 551 606 { 552 607 sortMarks(I,r,T); 553 std::cout << "T.size()=" << T.size() << std::endl;554 std::cout << "T[0] = (" << T[0].first << "," << T[0].second << ")" << std::endl;555 608 int i=0; for (; i<k; i++) 556 609 if (p_LeadmonomDivisibleBy(G->m[i],getTerm(I,T[0]),r)) break; 557 610 if (i<k) 558 611 { 559 if (T[0].first==10 && T[0].second==3)560 {561 std::cout << "check this" << std::endl;562 }563 std::cout << "reducing" << std::endl;564 612 poly g = p_One(r); poly h0 = getTerm(I,T[0]); 565 613 assume(h0!=NULL); … … 615 663 G = (ideal) w->CopyD(); 616 664 (void) ppreduceInitially(H,p,G,currRing); 617 id_Delete(&H,currRing);618 id_Delete(&G,currRing);619 n_Delete(&p,currRing->cf);620 omUpdateInfo();621 Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);622 H = (ideal) u->CopyD();623 p = (number) v->CopyD();624 G = (ideal) w->CopyD();625 (void) ppreduceInitially(H,p,G,currRing);626 665 n_Delete(&p,currRing->cf); 627 666 id_Delete(&G,currRing); … … 635 674 } 636 675 #endif //NDEBUG 637 638 639 static std::vector<int> synchronize(const ideal I, const ideal Hi)640 {641 int k = idSize(I);642 int l = idSize(Hi);643 std::vector<int> synch(k);644 int j;645 for (int i=0; i<k; i++)646 {647 for (j=0; j<l; j++)648 {649 if (I->m[i]==Hi->m[j])650 {651 synch[i] = j;652 break;653 }654 }655 if (j==l)656 synch[i] = -1;657 }658 return synch;659 }660 661 static void synchronize(ideal I, const ideal Hi, const std::vector<int> synch)662 {663 for (unsigned i=0; i<synch.size(); i++)664 if (synch[i]>=0)665 {666 I->m[i] = Hi->m[synch[i]];667 std::cout << i << " -> " << synch[i] << std::endl;668 }669 }670 671 void z_Write(number p, ring r)672 {673 poly g = p_One(r);674 p_SetCoeff(g,p,r);675 p_Write(g,r);676 return;677 }678 676 679 677 /** … … 708 706 709 707 std::map<long,ideal>::iterator it=H.begin(); 708 ideal Hi = it->second; 709 idShallowDelete(&Hi); 710 710 it++; 711 idealHi = it->second;711 Hi = it->second; 712 712 713 713 /*** … … 715 715 * and all lower components 716 716 **/ 717 // std::vector<int> synch = synchronize(I,Hi);718 717 if (ppreduceInitially(Hi,p,r)) return true; 719 // synchronize(I,Hi,synch);720 718 id_Test(Hi,r); 721 719 id_Test(I,r); … … 763 761 } 764 762 m += l; IDELEMS(GG) = m; GG->m = &G->m[n-m]; 765 // std::vector<int> synch = synchronize(I,it->second);766 763 id_Test(it->second,r); 767 764 id_Test(GG,r); 768 if (ppreduceInitially(it->second,p,r)) return true;769 765 if (ppreduceInitially(it->second,p,GG,r)) return true; 770 766 id_Test(it->second,r); 771 767 id_Test(GG,r); 772 // synchronize(I,it->second,synch);773 768 idShallowDelete(&Hi); Hi = it->second; 774 769 } … … 776 771 777 772 ptNormalize(I,p,r); 778 omFreeBin((ADDRESS)GG, sip_sideal_bin); idShallowDelete(&G); 773 omFreeBin((ADDRESS)GG, sip_sideal_bin); 774 idShallowDelete(&G); 779 775 return false; 780 776 } 781 777 782 778 783 // #ifndef NDEBUG 784 // BOOLEAN ppreduceInitially4(leftv res, leftv args) 785 // { 786 // leftv u = args; 787 // if ((u != NULL) && (u->Typ() == IDEAL_CMD)) 788 // { 789 // ideal I; 790 // omUpdateInfo(); 791 // Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 792 // I = (ideal) u->CopyD(); 793 // (void) ppreduceInitially(I,currRing); 794 // id_Delete(&I,currRing); 795 // omUpdateInfo(); 796 // Print("usedBytesAfter=%ld\n",om_Info.UsedBytes); 797 // I = (ideal) u->CopyD(); 798 // (void) ppreduceInitially(I,currRing); 799 // res->rtyp = IDEAL_CMD; 800 // res->data = (char*) I; 801 // return FALSE; 802 // } 803 // return TRUE; 804 // } 805 // #endif 779 #ifndef NDEBUG 780 BOOLEAN reduceInitiallyDebug(leftv res, leftv args) 781 { 782 leftv u = args; 783 if ((u != NULL) && (u->Typ() == IDEAL_CMD)) 784 { 785 leftv v = u->next; 786 if ((v != NULL) && (v->Typ() == NUMBER_CMD)) 787 { 788 omUpdateInfo(); 789 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 790 ideal I = (ideal) u->CopyD(); 791 number p = (number) v->Data(); 792 (void) ppreduceInitially(I,currRing,p); 793 res->rtyp = IDEAL_CMD; 794 res->data = (char*) I; 795 return FALSE; 796 } 797 } 798 return TRUE; 799 } 800 #endif 806 801 807 802 -
Singular/dyn_modules/gfanlib/ppinitialReduction.h
r4664b3 rc96414 5 5 #include <tropicalStrategy.h> 6 6 7 #ifndef NDEBUG8 BOOLEAN pppReduce(leftv res, leftv args);9 BOOLEAN ppreduceInitially0(leftv res, leftv args);10 BOOLEAN ppreduceInitially1(leftv res, leftv args);11 BOOLEAN ppreduceInitially2(leftv res, leftv args);12 BOOLEAN ppreduceInitially3(leftv res, leftv args);13 BOOLEAN ppreduceInitially4(leftv res, leftv args);14 #endif15 16 7 typedef std::pair<int,int> mark; 17 8 typedef std::vector<std::pair<int,int> > marks; 18 9 19 10 bool isOrderingLocalInT(const ring r); 20 void pReduce 0(ideal &I, const number p, const ring r);11 void pReduce(ideal &I, const number p, const ring r); 21 12 bool ppreduceInitially(ideal I, const ring r, const number p); 22 13 BOOLEAN ppreduceInitially(leftv res, leftv args); 23 14 24 void z_Write(number p, ring r); 15 #ifndef NDEBUG 16 BOOLEAN reduceInitiallyDebug(leftv res, leftv args); 17 BOOLEAN ptNormalize(leftv res, leftv args); 18 BOOLEAN ppreduceInitially3(leftv res, leftv args); 19 #endif 25 20 26 21 #endif -
Singular/dyn_modules/gfanlib/singularWishlist.h
r4664b3 rc96414 3 3 4 4 #include <libpolys/polys/monomials/p_polys.h> 5 6 /* #ifndef NDEBUG */ 7 /* void z_Write(number p, ring r) */ 8 /* { */ 9 /* poly g = p_One(r); */ 10 /* p_SetCoeff(g,p,r); */ 11 /* p_Write(g,r); */ 12 /* return; */ 13 /* } */ 14 /* #endif */ 5 15 6 16 static inline BOOLEAN _p_LeadmonomDivisibleByNoComp(poly a, poly b, const ring r) … … 47 57 } 48 58 59 /** 60 * p_LmDivisibleBy checks also the divisibility of coefficients 61 **/ 49 62 static inline BOOLEAN p_LeadmonomDivisibleBy(poly a, poly b, const ring r) 50 63 { … … 57 70 } 58 71 72 /** 73 * id_ShallowDelete deletes the monomials of the polynomials stored inside of it 74 **/ 59 75 inline void idShallowDelete (ideal *h) 60 76 { -
Singular/dyn_modules/gfanlib/tropical.cc
r4664b3 rc96414 171 171 172 172 173 BOOLEAN initial(leftv res, leftv args) 174 { 175 leftv u = args; 176 if ((u != NULL) && (u->Typ() == POLY_CMD) && (u->next == NULL)) 177 { 178 leftv v = u->next; 179 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) 180 { 181 poly p = (poly) u->Data(); 182 gfan::ZVector* weightVector; 183 if (v->Typ() == INTVEC_CMD) 184 { 185 intvec* w0 = (intvec*) v->Data(); 186 bigintmat* w1 = iv2bim(w0,coeffs_BIGINT); 187 w1->inpTranspose(); 188 weightVector = bigintmatToZVector(*w1); 189 delete w1; 190 } 191 else 192 { 193 bigintmat* w1 = (bigintmat*) v->Data(); 194 weightVector = bigintmatToZVector(*w1); 195 } 196 res->rtyp = IDEAL_CMD; 197 res->data = (void*) initial(p, currRing, *weightVector); 198 delete weightVector; 199 return FALSE; 200 } 201 } 202 if ((u != NULL) && (u->Typ() == IDEAL_CMD) && (u->next == NULL)) 203 { 204 leftv v = u->next; 205 if ((v !=NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD))) 206 { 207 ideal I = (ideal) u->Data(); 208 gfan::ZVector* weightVector; 209 if (v->Typ() == INTVEC_CMD) 210 { 211 intvec* w0 = (intvec*) v->Data(); 212 bigintmat* w1 = iv2bim(w0,coeffs_BIGINT); 213 w1->inpTranspose(); 214 weightVector = bigintmatToZVector(*w1); 215 delete w1; 216 } 217 else 218 { 219 bigintmat* w1 = (bigintmat*) v->Data(); 220 weightVector = bigintmatToZVector(*w1); 221 } 222 res->rtyp = POLY_CMD; 223 res->data = (void*) initial(I, currRing, *weightVector); 224 delete weightVector; 225 return FALSE; 226 } 227 } 228 WerrorS("initial: unexpected parameters"); 229 return TRUE; 230 } 231 232 173 233 void tropical_setup(SModulFunctions* p) 174 234 { 175 235 p->iiAddCproc("","groebnerCone",FALSE,groebnerCone); 176 236 p->iiAddCproc("","maximalGroebnerCone",FALSE,maximalGroebnerCone); 177 //p->iiAddCproc("","initial",FALSE,initial);237 p->iiAddCproc("","initial",FALSE,initial); 178 238 // p->iiAddCproc("","tropicalNeighbours",FALSE,tropicalNeighbours); 179 239 #ifndef NDEBUG … … 183 243 // p->iiAddCproc("","ppreduceInitially1",FALSE,ppreduceInitially1); 184 244 // p->iiAddCproc("","ppreduceInitially2",FALSE,ppreduceInitially2); 185 // p->iiAddCproc("","ppreduceInitially3",FALSE,ppreduceInitially3); 245 p->iiAddCproc("","ptNormalize",FALSE,ptNormalize); 246 p->iiAddCproc("","ppreduceInitially3",FALSE,ppreduceInitially3); 186 247 // p->iiAddCproc("","ppreduceInitially4",FALSE,ppreduceInitially4); 187 248 // p->iiAddCproc("","ttpReduce",FALSE,ttpReduce); … … 198 259 // p->iiAddCproc("","tropicalCurve0",FALSE,tropicalCurve0); 199 260 // p->iiAddCproc("","tropicalCurve1",FALSE,tropicalCurve1); 261 p->iiAddCproc("","reduceInitiallyDebug",FALSE,reduceInitiallyDebug); 262 p->iiAddCproc("","getWitnessDebug",FALSE,getWitnessDebug); 263 p->iiAddCproc("","getFlipDebug",FALSE,getFlipDebug); 200 264 p->iiAddCproc("","tropicalStartingPoint",FALSE,tropicalStartingPoint); 201 265 p->iiAddCproc("","positiveTropicalStartingPoint",FALSE,positiveTropicalStartingPoint); -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
r4664b3 rc96414 130 130 * and compute the common refinement with its tropical variety. 131 131 * If all initial ideals are monomial free, then we have our tropical curve */ 132 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end(); zc++)132 for (std::set<gfan::ZCone>::iterator zc=C.begin(); zc!=C.end();) 133 133 { 134 134 gfan::ZVector w = zc->getRelativeInteriorPoint(); … … 157 157 zc = C.begin(); 158 158 } 159 else 160 zc++; 159 161 id_Delete(&inIs,s); 160 162 id_Delete(&ininIs,s); -
Singular/dyn_modules/gfanlib/tropicalStrategy.cc
r4664b3 rc96414 335 335 nMapFunc identity = n_SetMap(startingRing->cf,r->cf); 336 336 number p = identity(uniformizingParameter,startingRing->cf,r->cf); 337 pReduce0(I,p,r);337 ::pReduce(I,p,r); 338 338 n_Delete(&p,r->cf); 339 339 … … 768 768 return false; 769 769 } 770 771 772 773 #ifndef NDEBUG 774 tropicalStrategy::tropicalStrategy(): 775 originalRing(NULL), 776 originalIdeal(NULL), 777 expectedDimension(NULL), 778 linealitySpace(gfan::ZCone()), // to come, see below 779 startingRing(NULL), // to come, see below 780 startingIdeal(NULL), // to come, see below 781 uniformizingParameter(NULL), // to come, see below 782 shortcutRing(NULL), // to come, see below 783 onlyLowerHalfSpace(false), 784 weightAdjustingAlgorithm1(NULL), 785 weightAdjustingAlgorithm2(NULL), 786 extraReductionAlgorithm(NULL) 787 { 788 } 789 790 tropicalStrategy tropicalStrategy::debugStrategy(const ideal startIdeal, number unifParameter, ring startRing) 791 { 792 tropicalStrategy debug; 793 debug.originalRing = rCopy(startRing); 794 debug.originalIdeal = id_Copy(startIdeal,startRing); 795 debug.startingRing = rCopy(startRing); 796 debug.startingIdeal = id_Copy(startIdeal,startRing); 797 debug.uniformizingParameter = n_Copy(unifParameter,startRing->cf); 798 799 debug.shortcutRing = rCopy0(startRing); 800 nKillChar(debug.shortcutRing->cf); 801 debug.shortcutRing->cf = nInitChar(n_Zp,(void*)(long)IsPrime(n_Int(unifParameter,startRing->cf))); 802 rComplete(debug.shortcutRing); 803 rTest(debug.shortcutRing); 804 805 debug.onlyLowerHalfSpace = true; 806 debug.weightAdjustingAlgorithm1 = valued_adjustWeightForHomogeneity; 807 debug.weightAdjustingAlgorithm2 = valued_adjustWeightUnderHomogeneity; 808 debug.extraReductionAlgorithm = ppreduceInitially; 809 810 return debug; 811 } 812 813 BOOLEAN getWitnessDebug(leftv res, leftv args) 814 { 815 leftv u = args; 816 if ((u!=NULL) && (u->Typ()==IDEAL_CMD)) 817 { 818 leftv v = u->next; 819 if ((v!=NULL) && (v->Typ()==IDEAL_CMD)) 820 { 821 leftv w = v->next; 822 if ((w!=NULL) && (w->Typ()==IDEAL_CMD)) 823 { 824 leftv x = w->next; 825 if ((x!=NULL) && (x->Typ()==NUMBER_CMD)) 826 { 827 omUpdateInfo(); 828 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 829 830 ideal inJ = (ideal) u->CopyD(); 831 ideal inI = (ideal) v->CopyD(); 832 ideal I = (ideal) w->CopyD(); 833 number p = (number) x->CopyD(); 834 tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing); 835 ideal J = debug.getWitness(inJ,inI,I,currRing); 836 id_Delete(&inJ,currRing); 837 id_Delete(&inI,currRing); 838 id_Delete(&I,currRing); 839 n_Delete(&p,currRing->cf); 840 res->rtyp = IDEAL_CMD; 841 res->data = (char*) J; 842 return FALSE; 843 } 844 } 845 } 846 } 847 return TRUE; 848 } 849 850 BOOLEAN getFlipDebug(leftv res, leftv args) 851 { 852 leftv u = args; 853 if ((u!=NULL) && (u->Typ()==IDEAL_CMD)) 854 { 855 leftv v = u->next; 856 if ((v!=NULL) && (v->Typ()==NUMBER_CMD)) 857 { 858 leftv w = v->next; 859 if ((w!=NULL) && (w->Typ()==BIGINTMAT_CMD)) 860 { 861 leftv x = w->next; 862 if ((x!=NULL) && (x->Typ()==BIGINTMAT_CMD)) 863 { 864 omUpdateInfo(); 865 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 866 867 ideal I = (ideal) u->CopyD(); 868 number p = (number) v->CopyD(); 869 bigintmat* interiorPoint0 = (bigintmat*) w->CopyD(); 870 bigintmat* facetNormal0 = (bigintmat*) x->CopyD(); 871 tropicalStrategy debug = tropicalStrategy::debugStrategy(I,p,currRing); 872 873 gfan::ZVector* interiorPoint = bigintmatToZVector(interiorPoint0); 874 gfan::ZVector* facetNormal = bigintmatToZVector(facetNormal0); 875 std::pair<ideal,ring> Js = debug.getFlip(I,currRing,*interiorPoint,*facetNormal); 876 ideal J = Js.first; 877 ring s = Js.second; 878 879 id_Delete(&J,s); 880 rDelete(s); 881 882 id_Delete(&I,currRing); 883 n_Delete(&p,currRing->cf); 884 delete interiorPoint0; 885 delete facetNormal0; 886 delete interiorPoint; 887 delete facetNormal; 888 889 res->rtyp = NONE; 890 res->data = NULL; 891 return FALSE; 892 } 893 } 894 } 895 } 896 WerrorS("getFlipDebug: unexpected parameters"); 897 return TRUE; 898 } 899 #endif -
Singular/dyn_modules/gfanlib/tropicalStrategy.h
r4664b3 rc96414 13 13 #include <witness.h> 14 14 15 #ifndef NDEBUG 16 17 #include <Singular/ipshell.h> // for isPrime(int i) 18 #include <adjustWeights.h> 19 #include <ppinitialReduction.h> 20 21 #endif 22 15 23 /** \file 16 24 * implementation of the class tropicalStrategy … … 109 117 void putUniformizingBinomialInFront(ideal I, const ring r, const number q) const; 110 118 111 112 119 public: 113 120 … … 125 132 */ 126 133 tropicalStrategy(const tropicalStrategy& currentStrategy); 134 135 136 #ifndef NDEBUG 137 tropicalStrategy(); 138 139 static tropicalStrategy debugStrategy(const ideal startIdeal, number unifParameter, ring startRing); 140 #endif 141 127 142 /** 128 143 * destructor … … 318 333 int dim(ideal I, ring r); 319 334 335 #ifndef NDEBUG 336 BOOLEAN getWitnessDebug(leftv res, leftv args); 337 BOOLEAN getFlipDebug(leftv res, leftv args); 320 338 #endif 339 340 #endif -
Singular/dyn_modules/gfanlib/tropicalVariety.cc
r4664b3 rc96414 3 3 #include <bbfan.h> 4 4 #include <groebnerCone.h> 5 #include <tropicalVarietyOfPolynomials.h> 5 6 #include <tropicalVarietyOfIdeals.h> 6 7 #include <libpolys/coeffs/numbers.h> … … 8 9 #include <kernel/structs.h> 9 10 11 #include <iostream> 12 #include <gfanlib/gfanlib_zfan.h> 10 13 11 14 BITSET bitsetSave1, bitsetSave2; … … 28 31 } 29 32 33 static gfan::ZFan* toZFan(std::set<gfan::ZCone> maxCones) 34 { 35 std::set<gfan::ZCone>::iterator sigma = maxCones.begin(); 36 gfan::ZFan* zf = new gfan::ZFan(sigma->ambientDimension()); 37 for (; sigma!=maxCones.end(); sigma++) 38 zf->insert(*sigma); 39 return zf; 40 } 41 30 42 BOOLEAN tropicalVariety(leftv res, leftv args) 31 43 { 44 omUpdateInfo(); 45 Print("usedBytesAfter=%ld\n",om_Info.UsedBytes); 32 46 leftv u = args; 33 47 if ((u!=NULL) && (u->Typ()==IDEAL_CMD)) … … 35 49 ideal I = (ideal) u->CopyD(); 36 50 leftv v = u->next; 51 52 if (idSize(I)==1) 53 { 54 poly g = I->m[0]; 55 if (v==NULL) 56 { 57 tropicalStrategy currentStrategy(I,currRing); 58 std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,currentStrategy); 59 // while (1) 60 // { 61 // omUpdateInfo(); 62 // Print("usedBytesAfter=%ld\n",om_Info.UsedBytes); 63 // tropicalStrategy debugTest(I,currRing); 64 // maxCones = tropicalVariety(g,currRing,debugTest); 65 // gfan::ZFan* zf = toZFan(maxCones); 66 // delete zf; 67 // } 68 res->rtyp = fanID; 69 res->data = (char*) toZFan(maxCones); 70 id_Delete(&I,currRing); 71 return FALSE; 72 } 73 if ((v!=NULL) && (v->Typ()==NUMBER_CMD)) 74 { 75 number p = (number) v->CopyD(); 76 tropicalStrategy currentStrategy(I,p,currRing); 77 std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,currentStrategy); 78 res->rtyp = fanID; 79 res->data = (char*) toZFan(maxCones); 80 id_Delete(&I,currRing); 81 n_Delete(&p,currRing->cf); 82 return FALSE; 83 } 84 } 85 37 86 if (v==NULL) 38 87 { 39 88 setOptionRedSB(); 40 89 if (!hasFlag(u,FLAG_STD)) 41 I = gfanlib_kStd_wrapper(I,currRing); 90 { 91 ideal stdI = gfanlib_kStd_wrapper(I,currRing); 92 id_Delete(&I,currRing); 93 I = stdI; 94 } 42 95 tropicalStrategy currentStrategy(I,currRing); 43 96 gfan::ZFan* tropI = tropicalVariety(currentStrategy); … … 45 98 res->data = (char*) tropI; 46 99 undoSetOptionRedSB(); 100 id_Delete(&I,currRing); 47 101 return FALSE; 48 102 } … … 51 105 number p = (number) v->CopyD(); 52 106 if (!hasFlag(u,FLAG_STD)) 53 I = gfanlib_kStd_wrapper(I,currRing); 107 { 108 ideal stdI = gfanlib_kStd_wrapper(I,currRing); 109 id_Delete(&I,currRing); 110 I = stdI; 111 } 54 112 tropicalStrategy currentStrategy(I,p,currRing); 55 113 gfan::ZFan* tropI = tropicalVariety(currentStrategy); 56 114 res->rtyp = fanID; 57 115 res->data = (char*) tropI; 116 id_Delete(&I,currRing); 58 117 return FALSE; 59 118 } -
Singular/dyn_modules/gfanlib/tropicalVarietyOfIdeals.cc
r4664b3 rc96414 5 5 gfan::ZFan* tropicalVariety(const tropicalStrategy currentStrategy) 6 6 { 7 ideal I = currentStrategy.getStartingIdeal();8 ring r = currentStrategy.getStartingRing();9 7 groebnerCone startingCone = tropicalStartingCone(currentStrategy); 10 8 groebnerCones tropicalVariety = tropicalTraversal(startingCone); -
Singular/dyn_modules/gfanlib/witness.cc
r4664b3 rc96414 90 90 { 91 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; 92 if ((u != NULL) && (u->Typ() == IDEAL_CMD)) 93 { 94 leftv v = u->next; 95 if ((v!=NULL) && (v->Typ()==IDEAL_CMD)) 96 { 97 omUpdateInfo(); 98 Print("usedBytesBefore=%ld\n",om_Info.UsedBytes); 99 ideal inI = (ideal) u->CopyD(); 100 ideal J = (ideal) v->CopyD(); 101 ideal I = witness(inI,J,currRing); 102 id_Delete(&inI,currRing); 103 id_Delete(&J,currRing); 104 res->rtyp = IDEAL_CMD; 105 res->data = (char*) I; 106 return FALSE; 107 } 108 } 109 return TRUE; 103 110 } 104 111 #endif
Note: See TracChangeset
for help on using the changeset viewer.