Changeset e44b149 in git for dyn_modules/callgfanlib/bbfan.cc
- Timestamp:
- Jul 3, 2013, 12:04:32 PM (11 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- f80a5305e1e0960855d4bd8702e48d1c2bbf8710
- Parents:
- a667138296109b29e11fe1654025d4581abfc50a
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2013-07-03 12:04:32+02:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2013-07-18 14:56:50+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dyn_modules/callgfanlib/bbfan.cc
ra667138 re44b149 279 279 if (d-ld>=0) 280 280 { 281 int n = zf->numberOfConesOfDimension(d ,oo,mm);281 int n = zf->numberOfConesOfDimension(d-ld,oo,mm); 282 282 res->rtyp = INT_CMD; 283 283 res->data = (void*) (long) n; 284 284 return FALSE; 285 285 } 286 else 287 { 288 res->rtyp = INT_CMD; 289 res->data = (void*) (long) 0; 290 return FALSE; 291 } 286 res->rtyp = INT_CMD; 287 res->data = (void*) (long) 0; 288 return FALSE; 292 289 } 293 290 } … … 309 306 310 307 for (int i=0; i<=d; i++) 311 { n = n + zf->numberOfConesOfDimension(i,0,0); }308 n = n + zf->numberOfConesOfDimension(i,0,0); 312 309 313 310 res->rtyp = INT_CMD; … … 396 393 397 394 leftv w=v->next; 398 int n = 1;395 int n; 399 396 if ((w != NULL) && (w->Typ() == INT_CMD)) 400 intn = (int)(long) w;397 n = (int)(long) w; 401 398 402 399 if (n != 0) … … 416 413 } 417 414 } 418 else 419 { 420 WerrorS("insertCone: unexpected parameters"); 421 return TRUE; 422 } 415 WerrorS("insertCone: unexpected parameters"); 416 return TRUE; 423 417 } 424 418 … … 601 595 } 602 596 } 603 else 604 { 605 WerrorS("getCone: unexpected parameters"); 606 return TRUE; 607 } 597 WerrorS("getCone: unexpected parameters"); 598 return TRUE; 608 599 } 609 600 … … 642 633 { 643 634 lists L = (lists)omAllocBin(slists_bin); 644 int n = zf->numberOfConesOfDimension(d ,oo,mm);635 int n = zf->numberOfConesOfDimension(d-ld,oo,mm); 645 636 L->Init(n); 646 637 for (int i=0; i<n; i++) … … 672 663 } 673 664 } 674 else 675 { 676 WerrorS("getCones: unexpected parameters"); 677 return TRUE; 678 } 665 WerrorS("getCones: unexpected parameters"); 666 return TRUE; 679 667 } 680 668 … … 732 720 gfan::ZMatrix rays(gfan::ZFan* zf) 733 721 { 734 int linDim = zf->getLinealityDimension();735 722 gfan::ZMatrix rays(0,zf->getAmbientDimension()); 736 for (int i=0; i<zf->numberOfConesOfDimension( linDim+1,0,0); i++)737 { 738 gfan::ZCone zc = zf->getCone( linDim+1, i, 0, 0);723 for (int i=0; i<zf->numberOfConesOfDimension(1,0,0); i++) 724 { 725 gfan::ZCone zc = zf->getCone(1, i, 0, 0); 739 726 rays.append(zc.extremeRays()); 740 727 } … … 924 911 } 925 912 WerrorS("listOfFacets: unexpected parameters"); 913 return TRUE; 914 } 915 916 BOOLEAN tropicalVariety(leftv res, leftv args) 917 { 918 leftv u=args; 919 if ((u != NULL) && (u->Typ() == POLY_CMD)) 920 { 921 int n = rVar(currRing); 922 gfan::ZFan* zf = new gfan::ZFan(n); 923 int* expv1 = (int*)omAlloc((n+1)*sizeof(int)); 924 int* expv2 = (int*)omAlloc((n+1)*sizeof(int)); 925 int* expvr = (int*)omAlloc((n+1)*sizeof(int)); 926 gfan::ZVector expw1 = gfan::ZVector(n); 927 gfan::ZVector expw2 = gfan::ZVector(n); 928 gfan::ZVector expwr = gfan::ZVector(n); 929 gfan::ZMatrix eq, ineq; 930 for (poly s1=(poly)u->Data(); s1!=NULL; pIter(s1)) 931 { 932 pGetExpV(s1,expv1); 933 expw1 = intStar2ZVector(n,expv1); 934 for (poly s2=pNext(s1); s2!=NULL; pIter(s2)) 935 { 936 pGetExpV(s2,expv2); 937 expw2 = intStar2ZVector(n,expv2); 938 eq = gfan::ZMatrix(0,n); 939 eq.appendRow(expw1-expw2); 940 ineq = gfan::ZMatrix(0,n); 941 for (poly r=(poly)u->Data(); r!=NULL; pIter(r)) 942 { 943 pGetExpV(r,expvr); 944 expwr = intStar2ZVector(n,expvr); 945 if ((r!=s1) && (r!=s2)) 946 { 947 ineq.appendRow(expw1-expwr); 948 } 949 } 950 gfan::ZCone zc = gfan::ZCone(ineq,eq); 951 zf->insert(zc); 952 } 953 } 954 omFreeSize(expv1,(n+1)*sizeof(int)); 955 omFreeSize(expv2,(n+1)*sizeof(int)); 956 omFreeSize(expvr,(n+1)*sizeof(int)); 957 res->rtyp = fanID; 958 res->data = (void*) zf; 959 return FALSE; 960 } 961 WerrorS("tropicalVariety: unexpected parameters"); 962 return TRUE; 963 } 964 965 gfan::ZFan* commonRefinement(gfan::ZFan* zf, gfan::ZFan* zg) 966 { 967 assume(zf->getAmbientDimension() == zg->getAmbientDimension()); 968 969 // gather all maximal cones of f and g 970 std::list<gfan::ZCone> maximalConesOfF; 971 for (int d=0; d<=zf->getAmbientDimension(); d++) 972 { 973 for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++) 974 { 975 maximalConesOfF.push_back(zf->getCone(d,i,0,1)); 976 } 977 } 978 979 std::list<gfan::ZCone> maximalConesOfG; 980 for (int d=0; d<=zg->getAmbientDimension(); d++) 981 { 982 for (int i=0; i<zg->numberOfConesOfDimension(d,0,1); i++) 983 { 984 maximalConesOfG.push_back(zg->getCone(d,i,0,1)); 985 } 986 } 987 988 // construct a new fan out of their intersections 989 gfan::ZFan* zr = new gfan::ZFan(zf->getAmbientDimension()); 990 for (std::list<gfan::ZCone>::iterator itf=maximalConesOfF.begin(); 991 itf != maximalConesOfF.end(); itf++) 992 { 993 for (std::list<gfan::ZCone>::iterator itg=maximalConesOfG.begin(); 994 itg != maximalConesOfG.end(); itg++) 995 { 996 zr->insert(intersection(*itf,*itg)); 997 } 998 } 999 1000 return zr; 1001 } 1002 1003 BOOLEAN commonRefinement(leftv res, leftv args) 1004 { 1005 leftv u=args; 1006 if ((u != NULL) && (u->Typ() == fanID)) 1007 { 1008 leftv v=u->next; 1009 if ((v != NULL) && (v->Typ() == fanID)) 1010 { 1011 gfan::ZFan* zf = (gfan::ZFan*) u->Data(); 1012 gfan::ZFan* zg = (gfan::ZFan*) v->Data(); 1013 gfan::ZFan* zr = commonRefinement(zf,zg); 1014 res->rtyp = fanID; 1015 res->data = (void*) zr; 1016 return FALSE; 1017 } 1018 } 1019 WerrorS("commonRefinement: unexpected parameters"); 926 1020 return TRUE; 927 1021 } … … 1012 1106 p->iiAddCproc("","fVector",FALSE,fVector); 1013 1107 p->iiAddCproc("","containsInCollection",FALSE,containsInCollection); 1108 p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety); 1109 p->iiAddCproc("","commonRefinement",FALSE,commonRefinement); 1014 1110 // iiAddCproc("","grFan",FALSE,grFan); 1015 1111 fanID=setBlackboxStuff(b,"fan");
Note: See TracChangeset
for help on using the changeset viewer.