Changeset b2adab in git
- Timestamp:
- Dec 5, 2018, 11:10:54 AM (5 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 412ad560b1b86611f9d6750b5a59caaa3f52c5d6
- Parents:
- 28dc75bf1ca923eca5ba650878df865c6721699db69efe9a1dd92bb34257b2f23015688ad84b6067
- git-author:
- Hans Schoenemann <hannes@mathematik.uni-kl.de>2018-12-05 11:10:54+01:00
- git-committer:
- GitHub <noreply@github.com>2018-12-05 11:10:54+01:00
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/gfan.lib
r28dc75 rb2adab 24 24 convexHull(c1,c2); convex hull 25 25 convexIntersection(c1,c2); convex hull 26 dimension(c); di emsion26 dimension(c); dimension of c 27 27 dualCone(c); the dual of c 28 28 equations(c); defining equations of c … … 56 56 fullFan(n); full fan in ambient dimension n 57 57 fVector(f); the f-Vector of f 58 getCone(f,d,i[, o,m]); the i-th cone in dimensiond in f58 getCone(f,d,i[,m]); the i-th cone of dimension d in f 59 59 insertCone(f,c[,b]); inserts the cone c into f 60 60 isCompatible(f,c); f and c live in the same ambient space … … 62 62 nmaxcones(f); number of maximal cones in f 63 63 ncones(f); number of cones in f 64 numberOfConesOfDimension(f,d[, o,m]); the number of cones in dimension d64 numberOfConesOfDimension(f,d[,m]); the number of cones in dimension d 65 65 removeCone(f,c[,b]); removes the cone c 66 66 dualPolytope(p); the dual of p 67 67 newtonPolytope(f); convex hull of all exponent vectors of f 68 68 vertices(p); vertices of p 69 onesVector(n); intvec of length n with all entries 1 69 70 "; 70 71 … … 1051 1052 proc randomPoint() 1052 1053 "USAGE: randomPoint(c); c cone 1054 randomPoint(c,b); c cone, b int 1053 1055 RETURN: bigintmat, a random point in the relative interior of c 1056 NOTE: returns a weighted sum over all its rays 1057 if b is given and b>0, only chooses weights between 1 and b 1054 1058 EXAMPLE: example randomPoint; shows an example 1055 1059 " … … 1060 1064 { 1061 1065 "EXAMPLE:"; echo = 2; 1062 intmat M[3][2]= 1063 1,0, 1064 0,1, 1065 -1,0; 1066 intmat M[2][2]= 1067 1,0, 1068 0,1; 1066 1069 cone c=coneViaPoints(M); 1067 1070 bigintmat Q=randomPoint(c); 1068 1071 print(Q); 1072 bigintmat P=randomPoint(c,5); 1073 print(P); 1069 1074 } 1070 1075 … … 1327 1332 1328 1333 proc getCone() 1329 "USAGE: getCone(f,d,i[, o,m]); f fan, d int, i int, oint, m int1334 "USAGE: getCone(f,d,i[,m]); f fan, d int, i int, m int 1330 1335 ASSUME: d is between 0 and ambientDimension(f) 1331 1336 i is between 1 and numberOfConesOfDimension(f,d,o,m) 1332 1337 RETURN: cone, returns in the fan f of all cones in dimension d the i-th cone 1333 if o=1, it will enumerate over cone orbits (deactivated for now) 1334 if m=1, it will enumerate over maximal cones 1338 if m!=0, it will enumerate over maximal cones only 1335 1339 EXAMPLE: example getCone; shows an example 1336 1340 " … … 1348 1352 fan f=emptyFan(3); 1349 1353 insertCone(f,c); 1350 getCone(f,2,1,0 ,0);1351 getCone(f,2,2,0 ,0);1354 getCone(f,2,1,0); 1355 getCone(f,2,2,0); 1352 1356 } 1353 1357 … … 1494 1498 1495 1499 proc numberOfConesOfDimension() 1496 "USAGE: numberOfConesOfDimension(f,d[, o,m]); f fan, d int, oint, m int1500 "USAGE: numberOfConesOfDimension(f,d[,m]); f fan, d int, m int 1497 1501 ASSUME: d is between 0 and ambientDimension(f) 1498 1502 RETURN: cone, returns in the fan f the number of cones in dimension d 1499 if o=1, it will only count cone orbits (deactivated for now) 1500 if m=1, it will only count maximal cones 1503 if m!=0, it will only count maximal cones 1501 1504 EXAMPLE: example numberOfConesOfDimension; shows an example 1502 1505 " … … 1515 1518 cone c=coneViaPoints(M); 1516 1519 insertCone(f,c); 1517 numberOfConesOfDimension(f,0,0 ,0);1518 numberOfConesOfDimension(f,0, 0,1);1519 numberOfConesOfDimension(f,1,0 ,0);1520 numberOfConesOfDimension(f,0, 0,1);1521 numberOfConesOfDimension(f,2,0 ,0);1522 numberOfConesOfDimension(f,2, 0,1);1523 numberOfConesOfDimension(f,3,0 ,0);1524 numberOfConesOfDimension(f,3, 0,1);1520 numberOfConesOfDimension(f,0,0); 1521 numberOfConesOfDimension(f,0,1); 1522 numberOfConesOfDimension(f,1,0); 1523 numberOfConesOfDimension(f,0,1); 1524 numberOfConesOfDimension(f,2,0); 1525 numberOfConesOfDimension(f,2,1); 1526 numberOfConesOfDimension(f,3,0); 1527 numberOfConesOfDimension(f,3,1); 1525 1528 } 1526 1529 … … 1681 1684 } 1682 1685 1686 proc onesVector() 1687 "USAGE: onesVector(n); n int 1688 RETURN: intvec, intvec of length n with all entries 1 1689 EXAMPLE: example onesVector; shows an example 1690 " 1691 { 1692 1693 } 1694 example 1695 { 1696 "EXAMPLE:"; echo = 2; 1697 intvec w = onesVector(3); 1698 w; 1699 } 1700 1683 1701 static proc mod_init() 1684 1702 { -
Singular/dyn_modules/gfanlib/bbcone.cc
r28dc75 rb2adab 1053 1053 } 1054 1054 1055 gfan::ZVector randomPoint(const gfan::ZCone* zc) 1055 int siRandBound(const int b) 1056 { 1057 int n = 0; 1058 while (n==0) 1059 { 1060 n = siRand(); 1061 if (b>1) 1062 { 1063 n = n % b; 1064 } 1065 } 1066 return n; 1067 } 1068 1069 gfan::ZVector randomPoint(const gfan::ZCone* zc, const int b) 1056 1070 { 1057 1071 gfan::ZVector rp = gfan::ZVector(zc->ambientDimension()); … … 1059 1073 gfan::ZMatrix rays = zc->extremeRays(); 1060 1074 for (int i=0; i<rays.getHeight(); i++) 1061 { 1062 int n = siRand(); 1063 rp = rp + n * rays[i].toVector(); 1064 } 1065 1066 gfan::ZMatrix lins = zc->generatorsOfLinealitySpace(); 1067 for (int i=0; i<lins.getHeight(); i++) 1068 { 1069 int n = siRand(); 1070 rp = rp + n * lins[i].toVector(); 1071 } 1075 rp += siRandBound(b) * rays[i].toVector(); 1076 1077 // gfan::ZMatrix lins = zc->generatorsOfLinealitySpace(); 1078 // for (int i=0; i<lins.getHeight(); i++) 1079 // { 1080 // int n = siRandBound(b); 1081 // rp = rp + n * lins[i].toVector(); 1082 // } 1072 1083 1073 1084 return rp; … … 1080 1091 { 1081 1092 gfan::initializeCddlibIfRequired(); 1082 gfan::ZCone* zc = (gfan::ZCone*)u->Data(); 1083 gfan::ZVector zv = randomPoint(zc); 1093 1094 int b = 0; 1095 leftv v = u->next; 1096 if ((v != NULL) && (v->Typ() == INT_CMD)) 1097 { 1098 b = (int) (long) v->Data(); 1099 b = b+1; 1100 } 1101 1102 gfan::ZCone* zc = (gfan::ZCone*)u->Data(); 1103 gfan::ZVector zv = randomPoint(zc,b); 1104 1084 1105 res->rtyp = BIGINTMAT_CMD; 1085 1106 res->data = (void*) zVectorToBigintmat(zv); … … 1574 1595 } 1575 1596 1576 BOOLEAN convexIntersectionOld(leftv res, leftv args)1577 {1578 gfan::initializeCddlibIfRequired();1579 leftv u = args;1580 if ((u != NULL) && (u->Typ() == coneID))1581 {1582 leftv v = u->next;1583 if ((v != NULL) && (v->Typ() == coneID))1584 {1585 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();1586 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();1587 int d1 = zc1->ambientDimension();1588 int d2 = zc2->ambientDimension();1589 if (d1 != d2)1590 {1591 Werror("expected ambient dims of both cones to coincide\n"1592 "but got %d and %d", d1, d2);1593 return TRUE;1594 }1595 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);1596 zc3.canonicalize();1597 res->rtyp = coneID;1598 res->data = (void *)new gfan::ZCone(zc3);1599 return FALSE;1600 }1601 if ((v != NULL) && (v->Typ() == polytopeID))1602 {1603 gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();1604 gfan::ZCone zc1 = liftUp(*zc11);1605 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();1606 int d1 = zc1.ambientDimension();1607 int d2 = zc2->ambientDimension();1608 if (d1 != d2)1609 {1610 Werror("expected ambient dims of both cones to coincide\n"1611 "but got %d and %d", d1, d2);1612 return TRUE;1613 }1614 gfan::ZCone zc3 = gfan::intersection(zc1, *zc2);1615 zc3.canonicalize();1616 res->rtyp = polytopeID;1617 res->data = (void *)new gfan::ZCone(zc3);1618 return FALSE;1619 }1620 }1621 if ((u != NULL) && (u->Typ() == polytopeID))1622 {1623 leftv v = u->next;1624 if ((v != NULL) && (v->Typ() == coneID))1625 {1626 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();1627 gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();1628 gfan::ZCone zc2 = liftUp(*zc22);1629 int d1 = zc1->ambientDimension();1630 int d2 = zc2.ambientDimension();1631 if (d1 != d2)1632 {1633 Werror("expected ambient dims of both cones to coincide\n"1634 "but got %d and %d", d1, d2);1635 return TRUE;1636 }1637 gfan::ZCone zc3 = gfan::intersection(*zc1, zc2);1638 zc3.canonicalize();1639 res->rtyp = polytopeID;1640 res->data = (void *)new gfan::ZCone(zc3);1641 return FALSE;1642 }1643 if ((v != NULL) && (v->Typ() == polytopeID))1644 {1645 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();1646 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();1647 int d1 = zc1->ambientDimension();1648 int d2 = zc2->ambientDimension();1649 if (d1 != d2)1650 {1651 Werror("expected ambient dims of both cones to coincide\n"1652 "but got %d and %d", d1, d2);1653 return TRUE;1654 }1655 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);1656 zc3.canonicalize();1657 res->rtyp = polytopeID;1658 res->data = (void *)new gfan::ZCone(zc3);1659 return FALSE;1660 }1661 }1662 WerrorS("convexIntersectionOld: unexpected parameters");1663 return TRUE;1664 }1665 1666 1597 BOOLEAN containsRelatively(leftv res, leftv args) 1667 1598 { … … 1842 1773 } 1843 1774 1775 1776 BOOLEAN onesVector(leftv res, leftv args) 1777 { 1778 leftv u=args; 1779 if ((u != NULL) && (u->Typ() == INT_CMD)) 1780 { 1781 int n = (int) (long) u->Data(); 1782 if (n>0) 1783 { 1784 intvec* v = new intvec(n); 1785 for (int i=0; i<n; i++) 1786 (*v)[i]=1; 1787 res->rtyp = INTVEC_CMD; 1788 res->data = (void*) v; 1789 return FALSE; 1790 } 1791 } 1792 WerrorS("onesVector: unexpected parameters"); 1793 return TRUE; 1794 } 1844 1795 1845 1796 /*** … … 2086 2037 p->iiAddCproc("gfan.lib","convexHull",FALSE,convexHull); 2087 2038 p->iiAddCproc("gfan.lib","convexIntersection",FALSE,intersectCones); 2088 p->iiAddCproc("gfan.lib","convexIntersectionOld",FALSE,convexIntersectionOld);2089 2039 p->iiAddCproc("gfan.lib","dimension",FALSE,dimension); 2090 2040 p->iiAddCproc("gfan.lib","dualCone",FALSE,dualCone); … … 2112 2062 p->iiAddCproc("gfan.lib","uniquePoint",FALSE,uniquePoint); 2113 2063 p->iiAddCproc("gfan.lib","faceContaining",FALSE,faceContaining); 2064 p->iiAddCproc("gfan.lib","onesVector",FALSE,onesVector); 2114 2065 coneID=setBlackboxStuff(b,"cone"); 2115 2066 } -
Singular/dyn_modules/gfanlib/bbcone.h
r28dc75 rb2adab 18 18 std::string toString(const gfan::ZCone* const c); 19 19 20 gfan::ZVector randomPoint(const gfan::ZCone* zc );20 gfan::ZVector randomPoint(const gfan::ZCone* zc, const int b=0); 21 21 gfan::ZCone liftUp(const gfan::ZCone &zc); 22 22 gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone &zc, const std::set<gfan::ZVector> &exceptThese=std::set<gfan::ZVector>()); -
Singular/dyn_modules/gfanlib/bbfan.cc
r28dc75 rb2adab 272 272 if ((v != NULL) && (v->Typ() == INT_CMD)) 273 273 { 274 gfan::initializeCddlibIfRequired(); 275 gfan::ZFan* zf = (gfan::ZFan*) u->Data(); 276 int d = (int)(long)v->Data(); 277 d -= zf->getLinealityDimension(); // shifting by dimension of lineality space 278 // since gfan always regards the lineality space as zero-dimensional 279 int m = 0; 274 280 leftv w=v->next; 281 if ((w != NULL) && (w->Typ() != INT_CMD)) 282 { 283 WerrorS("numberOfConesOfDimension: invalid maximality flag"); 284 gfan::deinitializeCddlibIfRequired(); 285 return TRUE; 286 } 275 287 if ((w != NULL) && (w->Typ() == INT_CMD)) 276 { 277 leftv x=w->next; 278 if ((x != NULL) && (x->Typ() == INT_CMD)) 279 { 280 gfan::initializeCddlibIfRequired(); 281 gfan::ZFan* zf = (gfan::ZFan*) u->Data(); 282 int d = (int)(long)v->Data(); 283 int o = (int)(long)w->Data(); 284 int m = (int)(long)x->Data(); 285 if ( (0<=d) && (d <= zf->getAmbientDimension()) 286 && ((o == 0) || (o == 1)) 287 && ((m == 0) || (m == 1))) 288 { 289 bool oo = (bool) o; 290 bool mm = (bool) m; 291 int ld = zf->getLinealityDimension(); 292 if (d-ld>=0) 293 { 294 int n = zf->numberOfConesOfDimension(d-ld,oo,mm); 295 res->rtyp = INT_CMD; 296 res->data = (void*) (long) n; 297 gfan::deinitializeCddlibIfRequired(); 298 return FALSE; 299 } 300 res->rtyp = INT_CMD; 301 res->data = (void*) (long) 0; 302 gfan::deinitializeCddlibIfRequired(); 303 return FALSE; 304 } 305 } 306 } 288 m = (int)(long) w->Data(); 289 bool mm = (bool) m; 290 291 if (d<0 || (d>zf->getAmbientDimension()-zf->getLinealityDimension())) 292 { 293 WerrorS("numberOfConesOfDimension: invalid dimension"); 294 gfan::deinitializeCddlibIfRequired(); 295 return TRUE; 296 } 297 298 int n = zf->numberOfConesOfDimension(d,0,mm); 299 res->rtyp = INT_CMD; 300 res->data = (void*) (long) n; 301 gfan::deinitializeCddlibIfRequired(); 302 return FALSE; 307 303 } 308 304 } … … 568 564 gfan::initializeCddlibIfRequired(); 569 565 gfan::ZFan* zf = (gfan::ZFan*) u->Data(); 566 570 567 int d = (int)(long)v->Data(); 568 d -= zf->getLinealityDimension(); // shifting by dimension of lineality space 569 // since gfan always regards the lineality space as zero-dimensional 571 570 int i = (int)(long)w->Data(); 572 i nt o = -1;573 int m = -1;571 i -= 1; // shifting by one, since gfan starts counting at 0 572 int m = 0; 574 573 leftv x=w->next; 575 if ((x != NULL) && (x->Typ() == INT_CMD))574 if ((x != NULL) && (x->Typ() != INT_CMD)) 576 575 { 577 o = (int)(long)x->Data(); 578 leftv y=x->next; 579 if ((y != NULL) && (y->Typ() == INT_CMD)) 580 { 581 m = (int)(long)y->Data(); 582 } 583 } 584 if (o == -1) o = 0; 585 if (m == -1) m = 0; 586 if (((o == 0) || (o == 1)) && ((m == 0) || (m == 1))) 587 { 588 bool oo = (bool) o; 589 bool mm = (bool) m; 590 if (0<=d && d<=zf->getAmbientDimension()) 591 { 592 int ld = zf->getLinealityDimension(); 593 if (0<i && i<=zf->numberOfConesOfDimension(d-ld,oo,mm)) 594 { 595 i=i-1; 596 if (d-ld>=0) 597 { 598 gfan::ZCone zc = zf->getCone(d-ld,i,oo,mm); 599 res->rtyp = coneID; 600 res->data = (void*)new gfan::ZCone(zc); 601 gfan::deinitializeCddlibIfRequired(); 602 return FALSE; 603 } 604 else 605 { 606 WerrorS("getCone: invalid dimension; no cones in this dimension"); 607 gfan::deinitializeCddlibIfRequired(); 608 return TRUE; 609 } 610 } 611 else 612 { 613 WerrorS("getCone: invalid index"); 614 gfan::deinitializeCddlibIfRequired(); 615 return TRUE; 616 } 617 } 618 else 619 { 620 WerrorS("getCone: invalid dimension"); 621 gfan::deinitializeCddlibIfRequired(); 622 return TRUE; 623 } 624 } 625 else 626 { 627 WerrorS("getCone: invalid specifier for orbit or maximal"); 576 WerrorS("getCone: invalid maximality flag"); 628 577 gfan::deinitializeCddlibIfRequired(); 629 578 return TRUE; 630 579 } 580 if ((x != NULL) && (x->Typ() == INT_CMD)) 581 m = (int)(long) x->Data(); 582 bool mm = (bool) m; 583 584 if (d<0 || (d>zf->getAmbientDimension()-zf->getLinealityDimension())) 585 { 586 WerrorS("getCone: invalid dimension"); 587 gfan::deinitializeCddlibIfRequired(); 588 return TRUE; 589 } 590 if (i<0 || i>=zf->numberOfConesOfDimension(d,0,mm)) 591 { 592 WerrorS("getCone: invalid index"); 593 gfan::deinitializeCddlibIfRequired(); 594 return TRUE; 595 } 596 597 gfan::ZCone zc = zf->getCone(d,i,0,mm); 598 res->rtyp = coneID; 599 res->data = (void*)new gfan::ZCone(zc); 600 gfan::deinitializeCddlibIfRequired(); 601 return FALSE; 631 602 } 632 603 } -
Tst/New/short_print.res.gz.uu
rb69efe rb2adab 1 1 begin 640 short_print.res.gz 2 M'XL(" *%,BTX``W-H;W)T7W!R:6YT+G)E<P`+#G'Q]%-04#"T4_#Q=%)0*BDN2 M'XL("-I\!EP"`W-H;W)T7W!R:6YT+G)E<P`+#G'Q]%-04#"T4_#Q=%)0*BDN 3 3 MT<O)3%*R5@"RXC/S,DLT-*VY0+2"G9U"<49^44E\05%F7HE>7FJY7G%)8@E7 4 4 M,-0((SL%H$2Z0H&"K8*!CD:EH4ZEIDY*@35<@;&=0J5AG)%699RAD347G`F7 5 G-X%:8&N(T&.*IL>H$DF#F1W8E2!7E!9K&&I:JW`!`""7R#_0````5 C-X%:8&N(T&-*0(^9'=BA((>4%FL8:EJK<`$`9&-$X=,````` 6 6 ` 7 7 end -
Tst/New/short_print.stat
rb69efe rb2adab 1 1 >> tst_memory_0 :: 1 317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:1722922 1 >> tst_memory_1 :: 1 317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:6663323 1 >> tst_memory_2 :: 1 317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:6991164 1 >> tst_timer_1 :: 1 317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:81 1 >> tst_memory_0 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:82264 2 1 >> tst_memory_1 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:2150160 3 1 >> tst_memory_2 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:2191264 4 1 >> tst_timer_1 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:1
Note: See TracChangeset
for help on using the changeset viewer.