Changeset b2adab in git


Ignore:
Timestamp:
Dec 5, 2018, 11:10:54 AM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
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
Message:
Merge pull request #899 from YueRen/gfanlibQualityOfLifeUpdate

Gfanlib quality of life update
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/gfan.lib

    r28dc75 rb2adab  
    2424       convexHull(c1,c2);   convex hull
    2525       convexIntersection(c1,c2); convex hull
    26        dimension(c);         diemsion
     26       dimension(c);         dimension of c
    2727       dualCone(c);          the dual of c
    2828       equations(c);         defining equations of c
     
    5656       fullFan(n);            full fan in ambient dimension n
    5757       fVector(f);            the f-Vector of f
    58        getCone(f,d,i[,o,m]);  the i-th cone in dimensiond in f
     58       getCone(f,d,i[,m]);  the i-th cone of dimension d in f
    5959       insertCone(f,c[,b]);   inserts the cone c into f
    6060       isCompatible(f,c);     f and c live in the same ambient space
     
    6262       nmaxcones(f);          number of maximal cones in f
    6363       ncones(f);             number of cones in f
    64        numberOfConesOfDimension(f,d[,o,m]); the number of cones in dimension d
     64       numberOfConesOfDimension(f,d[,m]); the number of cones in dimension d
    6565       removeCone(f,c[,b]);   removes the cone c
    6666       dualPolytope(p);       the dual of p
    6767       newtonPolytope(f);     convex hull of all exponent vectors of f
    6868       vertices(p);           vertices of p
     69       onesVector(n);         intvec of length n with all entries 1
    6970";
    7071
     
    10511052proc randomPoint()
    10521053"USAGE:   randomPoint(c);  c cone
     1054         randomPoint(c,b);  c cone, b int
    10531055RETURN:  bigintmat, a random point in the relative interior of c
     1056NOTE:    returns a weighted sum over all its rays
     1057         if b is given and b>0, only chooses weights between 1 and b
    10541058EXAMPLE: example randomPoint; shows an example
    10551059"
     
    10601064{
    10611065  "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;
    10661069  cone c=coneViaPoints(M);
    10671070  bigintmat Q=randomPoint(c);
    10681071  print(Q);
     1072  bigintmat P=randomPoint(c,5);
     1073  print(P);
    10691074}
    10701075
     
    13271332
    13281333proc getCone()
    1329 "USAGE:   getCone(f,d,i[,o,m]);  f fan, d int, i int, o int, m int
     1334"USAGE:   getCone(f,d,i[,m]);  f fan, d int, i int, m int
    13301335ASSUME:  d is between 0 and ambientDimension(f)
    13311336         i is between 1 and numberOfConesOfDimension(f,d,o,m)
    13321337RETURN:  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
    13351339EXAMPLE: example getCone; shows an example
    13361340"
     
    13481352  fan f=emptyFan(3);
    13491353  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);
    13521356}
    13531357
     
    14941498
    14951499proc numberOfConesOfDimension()
    1496 "USAGE:   numberOfConesOfDimension(f,d[,o,m]);  f fan, d int, o int, m int
     1500"USAGE:   numberOfConesOfDimension(f,d[,m]);  f fan, d int, m int
    14971501ASSUME:  d is between 0 and ambientDimension(f)
    14981502RETURN:  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
    15011504EXAMPLE: example numberOfConesOfDimension; shows an example
    15021505"
     
    15151518  cone c=coneViaPoints(M);
    15161519  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);
    15251528}
    15261529
     
    16811684}
    16821685
     1686proc onesVector()
     1687"USAGE:   onesVector(n);  n int
     1688RETURN:  intvec, intvec of length n with all entries 1
     1689EXAMPLE: example onesVector; shows an example
     1690"
     1691{
     1692
     1693}
     1694example
     1695{
     1696  "EXAMPLE:"; echo = 2;
     1697  intvec w = onesVector(3);
     1698  w;
     1699}
     1700
    16831701static proc mod_init()
    16841702{
  • Singular/dyn_modules/gfanlib/bbcone.cc

    r28dc75 rb2adab  
    10531053}
    10541054
    1055 gfan::ZVector randomPoint(const gfan::ZCone* zc)
     1055int 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
     1069gfan::ZVector randomPoint(const gfan::ZCone* zc, const int b)
    10561070{
    10571071  gfan::ZVector rp = gfan::ZVector(zc->ambientDimension());
     
    10591073  gfan::ZMatrix rays = zc->extremeRays();
    10601074  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  // }
    10721083
    10731084  return rp;
     
    10801091  {
    10811092    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
    10841105    res->rtyp = BIGINTMAT_CMD;
    10851106    res->data = (void*) zVectorToBigintmat(zv);
     
    15741595}
    15751596
    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 
    16661597BOOLEAN containsRelatively(leftv res, leftv args)
    16671598{
     
    18421773}
    18431774
     1775
     1776BOOLEAN 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}
    18441795
    18451796/***
     
    20862037  p->iiAddCproc("gfan.lib","convexHull",FALSE,convexHull);
    20872038  p->iiAddCproc("gfan.lib","convexIntersection",FALSE,intersectCones);
    2088   p->iiAddCproc("gfan.lib","convexIntersectionOld",FALSE,convexIntersectionOld);
    20892039  p->iiAddCproc("gfan.lib","dimension",FALSE,dimension);
    20902040  p->iiAddCproc("gfan.lib","dualCone",FALSE,dualCone);
     
    21122062  p->iiAddCproc("gfan.lib","uniquePoint",FALSE,uniquePoint);
    21132063  p->iiAddCproc("gfan.lib","faceContaining",FALSE,faceContaining);
     2064  p->iiAddCproc("gfan.lib","onesVector",FALSE,onesVector);
    21142065  coneID=setBlackboxStuff(b,"cone");
    21152066}
  • Singular/dyn_modules/gfanlib/bbcone.h

    r28dc75 rb2adab  
    1818std::string toString(const gfan::ZCone* const c);
    1919
    20 gfan::ZVector randomPoint(const gfan::ZCone* zc);
     20gfan::ZVector randomPoint(const gfan::ZCone* zc, const int b=0);
    2121gfan::ZCone liftUp(const gfan::ZCone &zc);
    2222gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone &zc, const std::set<gfan::ZVector> &exceptThese=std::set<gfan::ZVector>());
  • Singular/dyn_modules/gfanlib/bbfan.cc

    r28dc75 rb2adab  
    272272    if ((v != NULL) && (v->Typ() == INT_CMD))
    273273    {
     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;
    274280      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      }
    275287      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;
    307303    }
    308304  }
     
    568564        gfan::initializeCddlibIfRequired();
    569565        gfan::ZFan* zf = (gfan::ZFan*) u->Data();
     566
    570567        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
    571570        int i = (int)(long)w->Data();
    572         int o = -1;
    573         int m = -1;
     571        i -= 1; // shifting by one, since gfan starts counting at 0
     572        int m = 0;
    574573        leftv x=w->next;
    575         if ((x != NULL) && (x->Typ() == INT_CMD))
     574        if ((x != NULL) && (x->Typ() != INT_CMD))
    576575        {
    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");
    628577          gfan::deinitializeCddlibIfRequired();
    629578          return TRUE;
    630579        }
     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;
    631602      }
    632603    }
  • Tst/New/short_print.res.gz.uu

    rb69efe rb2adab  
    11begin 640 short_print.res.gz
    2 M'XL("*%,BTX``W-H;W)T7W!R:6YT+G)E<P`+#G'Q]%-04#"T4_#Q=%)0*BDN
     2M'XL("-I\!EP"`W-H;W)T7W!R:6YT+G)E<P`+#G'Q]%-04#"T4_#Q=%)0*BDN
    33MT<O)3%*R5@"RXC/S,DLT-*VY0+2"G9U"<49^44E\05%F7HE>7FJY7G%)8@E7
    44M,-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````
     5C-X%:8&N(T&-*0(^9'=BA((>4%FL8:EJK<`$`9&-$X=,`````
    66`
    77end
  • Tst/New/short_print.stat

    rb69efe rb2adab  
    1 1 >> tst_memory_0 :: 1317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:172292
    2 1 >> tst_memory_1 :: 1317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:666332
    3 1 >> tst_memory_2 :: 1317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:699116
    4 1 >> tst_timer_1 :: 1317751967:3133- exportiert :3-1-3:ix86-Linux:mamawutz:8
     11 >> tst_memory_0 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:82264
     21 >> tst_memory_1 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:2150160
     31 >> tst_memory_2 :: 1543929050:4113, 64 bit:4.1.1:x86_64-Linux:nepomuck:2191264
     41 >> 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.