Changeset e57255 in git


Ignore:
Timestamp:
Dec 16, 2013, 3:12:47 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
d186d3baff30f2e6e96b2a354ff156ec286fcb4ef24b9c65dd9d2b3d937e5841295580dedc2f7412
Parents:
27877c10cae6d5eb945d62a27d66dfdf8a5a47849e8ae12733559521215c7641624da588f2d8cdf3
Message:
Merge pull request #429 from YueRen/polymakelib

Polymakelib
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Singular/LIB/COPYING

    r27877c1 re57255  
    134134paramet.lib     Thomas Keilen                   keilen@mathematik.uni-kl.de
    135135perron.lib      Oleksandr Motsak                motsak at mathematik dot uni minus kl dot de
    136 phindex.lib 
     136phindex.lib
    137137pointid.lib     Stefan Steidel                  steidel@mathematik.uni-kl.de
    138138poly.lib        Olaf Bachmann                   obachman@mathematik.uni-kl.de
    139139                Gert-Martin Greuel              greuel@mathematik.uni-kl.de
    140140                Anne Fruehbis-Krueger           anne@mathematik.uni-kl.de
    141 oldpolymake.lib Thomas Markwig                  keilen@mathematik.uni-kl.de
     141polymake.lib    Thomas Markwig                  keilen@mathematik.uni-kl.de
    142142presolve.lib    Gert-Martin Greuel              greuel@mathematik.uni-kl.de
    143143primdec.lib     Gerhard Pfister                 pfister@mathematik.uni-kl.de
  • Singular/LIB/polymake.lib

    r27877c1 re57255  
    1 ////
    2 version="version oldpolymake.lib 4.0.0.0 Jun_2013 "; // $Id$
     1version="version oldpolymake.lib 4.0.0.0 Jun_2013 ";
    32category="Tropical Geometry";
    43info="
    5 LIBRARY:   oldpolymake.lib  Computations with polytopes and fans,
    6                             interface to polymake and TOPCOM
     4LIBRARY:   polymake.lib    Computations with polytopes and fans,
     5                           interface to polymake and TOPCOM
    76AUTHOR:    Thomas Markwig,  email: keilen@mathematik.uni-kl.de
    87
     
    109   Most procedures will not work unless polymake or topcom is installed and
    1110   if so, they will only work with the operating system LINUX!
    12    For more detailed information see the following note or consult the
     11   For more detailed information see IMPORTANT NOTE respectively consult the
    1312   help string of the procedures.
    1413
    15 NOTE:
     14   The conventions used in this library for polytopes and fans, e.g. the
     15   length and labeling of their vertices resp. rays, differs from the conventions
     16   used in polymake and thus from the conventions used in the polymake
     17   extension polymake.so of Singular. We recommend to use the newer polymake.so
     18   whenever possible.
     19
     20IMPORTANT NOTE:
    1621   Even though this is a Singular library for computing polytopes and fans
    1722   such as the Newton polytope or the Groebner fan of a polynomial, most of
     
    1924@* - polymake by Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt
    2025@*   (see http://www.math.tu-berlin.de/polymake/),
    21 @* respectively (only in the procedure triangularions) by the program
    22 @* - topcom by Joerg Rambau, Universitaet Bayreuth (see http://www.uni-bayreuth.de/
    23      departments/wirtschaftsmathematik/rambau/TOPCOM);
    24 @*   This library should rather be seen as an interface which allows to use a
     26@* respectively (only in the procedure triangulations) by the program
     27@* - topcom by Joerg Rambau, Universitaet Bayreuth (see
     28@*   http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM);
     29@*   this library should rather be seen as an interface which allows to use a
    2530     (very limited) number of options which polymake respectively topcom offers
    2631     to compute with polytopes and fans and to make the results available in
     
    3237     independent of both, polymake and topcom.
    3338
    34 PROCEDURES:
    35   polymakePolytope()   computes the vertices of a polytope using polymake
    36   newtonPolytopeP()     computes the Newton polytope of a polynomial
    37   newtonPolytopeLP()   computes the lattice points of the Newton polytope
    38   normalFan()          computes the normal fan of a polytope
    39   groebnerFan()        computes the Groebner fan of a polynomial
    40   intmatToPolymake()   transforms an integer matrix into polymake format
    41   polymakeToIntmat()   transforms polymake output into an integer matrix
    42 
    43   triangulations()     computes all triangulations of a marked polytope
    44   secondaryPolytope()  computes the secondary polytope of a marked polytope
    45 
    46   secondaryFan()       computes the secondary fan of a marked polytope
    47 
    48   cycleLength()      computes the cycleLength of cycle
    49   splitPolygon()     splits a marked polygon into vertices, facets, interior points
    50   eta()              computes the eta-vector of a triangulation
    51   findOrientedBoundary()    computes the boundary of a convex hull
    52   cyclePoints()      computes lattice points connected to some lattice point
    53   latticeArea()      computes the lattice area of a polygon
    54   picksFormula()     computes the ingrediants of Pick's formula for a polygon
    55   ellipticNF()       computes the normal form of an elliptic polygon
    56   ellipticNFDB()     displays the 16 normal forms of elliptic polygons
    57 
    58   polymakeKeepTmpFiles()  determines if the files created in /tmp should be kept
     39PROCEDURES USING POLYMAKE:
     40  polymakePolytope()  computes the vertices of a polytope using polymake
     41  newtonPolytopeP()    computes the Newton polytope of a polynomial
     42  newtonPolytopeLP()  computes the lattice points of the Newton polytope
     43  normalFanL()         computes the normal fan of a polytope
     44  groebnerFan()       computes the Groebner fan of a polynomial
     45
     46PROCEDURES USING TOPCOM:
     47  triangulations()    computes all triangulations of a marked polytope
     48  secondaryPolytope() computes the secondary polytope of a marked polytope
     49
     50PROCEDURES USING POLYMAKE AND TOPCOM:
     51  secondaryFan()      computes the secondary fan of a marked polytope
     52
     53PROCEDURES CONERNED WITH PLANAR POLYGONS:
     54  cycleLength()    computes the cycleLength of cycle
     55  splitPolygon()   splits a marked polygon into vertices, facets, interior points
     56  eta()            computes the eta-vector of a triangulation
     57  findOrientedBoundary()  computes the boundary of a convex hull
     58  cyclePoints()    computes lattice points connected to some lattice point
     59  latticeArea()    computes the lattice area of a polygon
     60  picksFormula()   computes the ingrediants of Pick's formula for a polygon
     61  ellipticNF()     computes the normal form of an elliptic polygon
     62  ellipticNFDB()   displays the 16 normal forms of elliptic polygons
    5963
    6064KEYWORDS:    polytope; fan; secondary fan; secondary polytope; polymake;
     
    8589////////////////////////////////////////////////////////////////////////////////
    8690
     91static proc mod_init ()
     92{
     93  LIB "gfanlib.so";
     94  LIB "polymake.so";
     95}
    8796
    8897/////////////////////////////////////////////////////////////////////////////
     
    9099/////////////////////////////////////////////////////////////////////////////
    91100
    92 proc polymakePolytope (intmat polytop,list #)
    93 "USAGE:  polymakePolytope(polytope[,#]);   polytope list, # string
    94 ASSUME:  each row of polytope gives the coordinates of a lattice point of a
     101proc polymakePolytope (intmat points)
     102"USAGE:  polymakePolytope(points);   polytope intmat
     103ASSUME:  each row of points gives the coordinates of a lattice point of a
    95104         polytope with their affine coordinates as given by the output of
    96105         secondaryPolytope
    97106PURPOSE: the procedure calls polymake to compute the vertices of the polytope
    98107         as well as its dimension and information on its facets
    99 RETURN:  list L with four entries
     108RETURN:  list, L with four entries
    100109@*            L[1] : an integer matrix whose rows are the coordinates of vertices
    101110                     of the polytope
    102111@*            L[2] : the dimension of the polytope
    103 @*            L[3] : a list whose i-th entry explains to which vertices the
     112@*            L[3] : a list whose ith entry explains to which vertices the
    104113                     ith vertex of the Newton polytope is connected
    105114                     -- i.e. L[3][i] is an integer vector and an entry k in
    106115                        there means that the vertex L[1][i] is connected to the
    107116                        vertex L[1][k]
    108 @*            L[4] : an integer matrix whose rows mulitplied by
     117@*            L[4] : an matrix of type bigintmat whose rows mulitplied by
    109118                     (1,var(1),...,var(nvar)) give a linear system of equations
    110119                     describing the affine hull of the polytope,
     
    118127         convention which starts indexing its vertices by zero while we start
    119128         with one !
    120 @*    -  the procedure creates the file  /tmp/polytope.polymake which contains
    121          the polytope in polymake format; if you wish to use this for further
    122          computations with polymake, you have to use the procedure
    123          polymakeKeepTmpFiles in before
    124 @*    -  moreover, the procedure creates the file /tmp/polytope.output which
    125          it deletes again before ending
    126 @*    -  it is possible to provide an optional second argument a string
    127          which then will be used instead of 'polytope' in the name of the
    128          polymake output file
    129129EXAMPLE: example polymakePolytope;   shows an example"
    130130{
    131   // the header for the file secendarypolytope.polymake
    132   string sp="_application polytope
    133 _version 2.2
    134 _type RationalPolytope
    135 
    136 POINTS
    137 ";
     131  // add a first column to polytope as homogenising coordinate
     132  points=intmatAddFirstColumn(points,"points");
     133  polytope polytop=polytopeViaPoints(points);
     134  list graph=vertexAdjacencyGraph(polytop)[2];
    138135  int i,j;
    139   // set the name for the polymake output file
    140   if (size(#)>0)
    141   {
    142     if (typeof(#[1])=="string")
    143     {
    144       string dateiname=#[1];
    145     }
    146     else
    147     {
    148       string dateiname="polytope";
    149     }
    150   }
    151   else
    152   {
    153     string dateiname="polytope";
    154   }
    155   // create the lattice point list for polymake
    156   sp=sp+intmatToPolymake(polytop,"points");
    157   // initialise dateiname.polymake and compute the vertices
    158   write(":w /tmp/"+dateiname+".polymake",sp);
    159   system("sh","cd /tmp; polymake "+dateiname+".polymake VERTICES > "+dateiname+".output");
    160   string vertices=read("/tmp/"+dateiname+".output");
    161   system("sh","/bin/rm /tmp/"+dateiname+".output");
    162   intmat np=polymakeToIntmat(vertices,"affine");
    163   // compute the dimension
    164   system("sh","cd /tmp; polymake "+dateiname+".polymake DIM > "+dateiname+".output");
    165   string pdim=read("/tmp/"+dateiname+".output");
    166   system("sh","/bin/rm /tmp/"+dateiname+".output");
    167   pdim=pdim[5,size(pdim)-6];
    168   execute("int nd="+pdim+";");
    169   // compute the vertex-edge graph
    170   system("sh","cd /tmp; polymake "+dateiname+".polymake GRAPH > "+dateiname+".output");
    171   string vertexedgegraph=read("/tmp/"+dateiname+".output");
    172   system("sh","/bin/rm /tmp/"+dateiname+".output");
    173   vertexedgegraph=vertexedgegraph[7,size(vertexedgegraph)-8];
    174   string newveg;
    175   for (i=1;i<=size(vertexedgegraph);i++)
    176   {
    177     if (vertexedgegraph[i]=="{")
    178     {
    179       newveg=newveg+"intvec(";
    180     }
    181     else
    182     {
    183       if (vertexedgegraph[i]=="}")
    184       {
    185         newveg=newveg+"),";
    186       }
    187       else
    188       {
    189         if (vertexedgegraph[i]==" ")
    190         {
    191           newveg=newveg+",";
    192         }
    193         else
    194         {
    195           newveg=newveg+vertexedgegraph[i];
    196         }
    197       }
    198     }
    199   }
    200   newveg=newveg[1,size(newveg)-1];
    201   execute("list nveg="+newveg+";");
    202   // raise each entry in nveg by one
    203   for (i=1;i<=size(nveg);i++)
    204   {
    205     for (j=1;j<=size(nveg[i]);j++)
    206     {
    207       nveg[i][j]=nveg[i][j]+1;
    208     }
    209   }
    210   // compute the affine hull
    211   system("sh","cd /tmp; polymake "+dateiname+".polymake AFFINE_HULL > "+dateiname+".output");
    212   string equations=read("/tmp/"+dateiname+".output");
    213   system("sh","/bin/rm /tmp/"+dateiname+".output");
    214   if (size(equations)>14)
    215   {
    216     intmat neq=polymakeToIntmat(equations,"cleardenom");
    217   }
    218   else
    219   {
    220     intmat neq[1][ncols(polytop)+1];
    221   }
    222   // delete the tmp-files, if polymakekeeptmpfiles is not set
    223   if (defined(polymakekeeptmpfiles)==0)
    224   {
    225     system("sh","/bin/rm /tmp/"+dateiname+".polymake");
    226   }
    227   // return the files
    228   return(list(np,nd,nveg,neq));
     136  for (i=1;i<=size(graph);i++)
     137  {
     138    for (j=1;j<=size(graph[i]);j++)
     139    {
     140      graph[i][j]=graph[i][j]+1;
     141    }
     142  }
     143  return(list(intmatcoldelete(vertices(polytop),1),dimension(polytop),graph,equations(polytop)));
    229144}
    230145example
     
    247162   ring r=0,x(1..4),dp;
    248163   matrix M[5][1]=1,x(1),x(2),x(3),x(4);
    249    np[4]*M;
     164   intmat(np[4])*M;
    250165}
    251166
    252167/////////////////////////////////////////////////////////////////////////////
    253168
    254 proc newtonPolytopeP (poly f,list #)
    255 "USAGE: newtonPolytopeP(f[,#]);  f poly, # string
    256 RETURN: list L with four entries
     169proc newtonPolytopeP (poly f)
     170"USAGE: newtonPolytopeP(f);  f poly
     171RETURN: list, L with four entries
    257172@*            L[1] : an integer matrix whose rows are the coordinates of vertices
    258173                     of the Newton polytope of f
     
    263178                        there means that the vertex L[1][i] is
    264179                        connected to the vertex L[1][k]
    265 @*            L[4] : an integer matrix whose rows mulitplied by
     180@*            L[4] : an matrix of type bigintmat whose rows mulitplied by
    266181                     (1,var(1),...,var(nvar)) give a linear system of equations
    267182                     describing the affine hull of the Newton polytope, i.e. the
     
    269184NOTE: -  if we replace the first column of L[4] by zeros, i.e. if we move
    270185         the affine hull to the origin, then we get the equations for the
    271          orthogonal comploment of the linearity space of the normal fan dual
     186         orthogonal complement of the linearity space of the normal fan dual
    272187         to the Newton polytope, i.e. we get the EQUATIONS that
    273188         we need as input for polymake when computing the normal fan
     
    275190         TU Berlin and Michael Joswig, so it only works if polymake is installed;
    276191         see http://www.math.tu-berlin.de/polymake/
    277 @*    -  the procedure creates the file  /tmp/newtonPolytope.polymake which
    278          contains the polytope in polymake format and which can be used for
    279          further computations with polymake
    280 @*    -  moreover, the procedure creates the file /tmp/newtonPolytope.output
    281          and deletes it again before ending
    282 @*    -  it is possible to give as an optional second argument a string
    283          which then will be used instead of 'newtonPolytope' in the name of
    284          the polymake output file
    285192EXAMPLE: example newtonPolytopeP;   shows an example"
    286193{
     
    296203    f=f-lead(f);
    297204  }
    298   if (size(#)==0)
    299   {
    300     #[1]="newtonPolytope";
    301   }
    302205  // call polymakePolytope with exponents
    303   return(polymakePolytope(exponents,#));
     206  return(polymakePolytope(exponents));
    304207}
    305208example
     
    330233   // the Newton polytope is contained in the affine space given
    331234   //     by the equations
    332    np[4]*M;
     235   intmat(np[4])*M;
    333236}
    334237
     
    339242RETURN: list, the exponent vectors of the monomials occuring in f,
    340243              i.e. the lattice points of the Newton polytope of f
    341 EXAMPLE: example normalFan;   shows an example"
     244EXAMPLE: example newtonPolytopeLP;   shows an example"
    342245{
    343246  list np;
     
    363266/////////////////////////////////////////////////////////////////////////////
    364267
    365 proc normalFan (intmat vertices,intmat affinehull,list graph,int er,list #)
    366 "USAGE:  normalFan (vert,aff,graph,rays,[,#]);   vert,aff intmat,  graph list, rays int, # string
     268proc normalFanL (def vertices, def affinehull,list graph,int er,list #)
     269"USAGE:  normalFanL (vert,aff,graph,rays,[,#]);   vert,aff intmat,  graph list, rays int, # string
    367270ASSUME:  - vert is an integer matrix whose rows are the coordinate of
    368271           the vertices of a convex lattice polytope;
     
    396299@*       - in the optional argument # it is possible to hand over other names
    397300           for the variables to be used -- be careful, the format must be correct
    398            which is not tested, e.g. if you want the variable names to be
    399            u00,u10,u01,u11 then you must hand over the string 'u11,u10,u01,u11'
    400 EXAMPLE: example normalFan;   shows an example"
    401 {
     301           and that is not tested, e.g. if you want the variable names to be
     302           u00,u10,u01,u11 then you must hand over the string u11,u10,u01,u11
     303EXAMPLE: example normalFanL;   shows an example"
     304{
     305  if (typeof(affinehull) != "intmat" && typeof (affinehull) != "bigintmat")
     306  {
     307    ERROR("normalFanL: input affinehull has to be either intmat or bigintmat");
     308    list L;
     309    return (L);
     310  }
    402311  list ineq; // stores the inequalities of the cones
    403312  int i,j,k;
     
    431340    list pp;  // contain strings representing the inequalities
    432341              // describing the normal cone
    433     intmat ie[size(graph[i])][ncols(vertices)]; // contains the inequalities
    434                                                 // as rows
     342    if (typeof (vertices) == "intmat")
     343    {
     344      intmat ie[size(graph[i])][ncols(vertices)]; // contains the inequalities
     345    }                                             // as rows
     346    if (typeof (vertices) == "bigintmat")
     347    {
     348      bigintmat ie[size(graph[i])][ncols(vertices)]; // contains the inequalities
     349    }                                                // as rows
    435350    // consider all the vertices to which the ith vertex in the
    436351    // polytope is connected by an edge
     
    469384  }
    470385  // remove the first column of affine hull to compute the linearity space
    471   intmat linearity=intmatcoldelete(affinehull,1);
     386  bigintmat linearity[1][ncols(vertices)];
     387  if (nrows(affinehull)>0)
     388  {
     389    linearity=intmatcoldelete(affinehull,1);
     390  }
    472391  //////////////////////////////////////////////////////////////////
    473392  // Compute next the extreme rays of the cones
     
    476395  {
    477396    list extremerays; // keeps the result
    478     string polymake; // keeps polymake output
    479     // the header for ineq.polymake
    480     string head="_application polytope
    481 _version 2.2
    482 _type RationalPolytope
    483 
    484 INEQUALITIES
    485 ";
    486     // the tail for both polymake files
    487     string tail="
    488 EQUATIONS
    489 ";
    490     tail=tail+intmatToPolymake(linearity,"rays");
    491     string ungleichungen; // keeps the inequalities for the polymake code
     397    cone kegel;
     398    bigintmat linearspan=intmatAddFirstColumn(linearity,"rays");
    492399    intmat M; // the matrix keeping the inequalities
    493     // create the file ineq.output
    494     write(":w /tmp/ineq.output","");
    495     int dimension; // keeps the dimension of the intersection the
    496                    // bad cones with the u11tobeseencone
    497400    for (i=1;i<=size(ineq);i++)
    498401    {
    499       i,". Cone of ",nrows(vertices); // indicate how many
    500                                       // vertices have been dealt with
    501       ungleichungen=intmatToPolymake(ineq[i][1],"rays");
    502       // write the inequalities to ineq.polymake and call polymake
    503       write(":w /tmp/ineq.polymake",head+ungleichungen+tail);
    504       ungleichungen=""; // clear ungleichungen
    505       system("sh","cd /tmp; /bin/rm ineq.output; polymake ineq.polymake VERTICES > ineq.output");
    506       // read the result of polymake
    507       polymake=read("/tmp/ineq.output");
    508       intmat VERT=polymakeToIntmat(polymake,"affine");
    509       extremerays[i]=VERT;
    510       kill VERT;
     402      kegel=coneViaInequalities(intmatAddFirstColumn(ineq[i][1],"rays"),linearspan);
     403      extremerays[i]=intmatcoldelete(rays(kegel),1);
    511404    }
    512405    for (i=1;i<=size(ineq);i++)
     
    514407      ineq[i]=ineq[i]+list(extremerays[i]);
    515408    }
    516   }
    517   // delete the tmp-files, if polymakekeeptmpfiles is not set
    518   if (defined(polymakekeeptmpfiles)==0)
    519   {
    520     system("sh","/bin/rm /tmp/ineq.polymake");
    521     system("sh","/bin/rm /tmp/ineq.output");
    522409  }
    523410  // get the linearity space
     
    534421   list np=newtonPolytopeP(f);
    535422   // the Groebner fan of f, i.e. the normal fan of the Newton polytope
    536    list gf=normalFan(np[1],np[4],np[3],1,"x,y,z");
     423   list gf=normalFanL(np[1],np[4],np[3],1,"x,y,z");
    537424   // the number of cones in the Groebner fan of f is:
    538425   size(gf[1]);
     
    549436/////////////////////////////////////////////////////////////////////////////
    550437
    551 proc groebnerFan (poly f,list #)
    552 "USAGE:  groebnerFan(f[,#]);  f poly, # string
     438proc groebnerFan (poly f)
     439"USAGE:  groebnerFan(f);  f poly
    553440RETURN:  list, the ith entry of L[1] contains information about the ith cone
    554441               in the Groebner fan dual to the ith vertex in the Newton
     
    564451                      in each cone
    565452@*             L[3] = the Newton polytope of f in the format of the procedure
    566                       newtonPolytope
    567 @*             L[4] = integer matrix where each row represents the exponet
     453                      newtonPolytopeP
     454@*             L[4] = integer matrix where each row represents the exponent
    568455                      vector of one monomial occuring in the input polynomial
    569456NOTE: - if you have already computed the Newton polytope of f then you might want
    570         to use the procedure normalFan instead in order to avoid doing costly
     457        to use the procedure normalFanL instead in order to avoid doing costly
    571458        computation twice
    572459@*    - the procedure calls for its computation polymake by Ewgenij Gawrilow,
    573460        TU Berlin and Michael Joswig, so it only works if polymake is installed;
    574461        see http://www.math.tu-berlin.de/polymake/
    575 @*    - the procedure creates the file  /tmp/newtonPolytope.polymake which
    576         contains the Newton polytope of f in polymake format and which can
    577         be used for further computations with polymake
    578 @*    - it is possible to give as an optional second argument as string which
    579         then will be used instead of 'newtonPolytope' in the name of the
    580         polymake output file
    581462EXAMPLE: example groebnerFan;   shows an example"
    582463{
     
    591472    f=f-lead(f);
    592473  }
    593   if (size(#)==0)
    594   {
    595     #[1]="newtonPolytope";
    596   }
    597474  // call polymakePolytope with exponents
    598   list newtonp=polymakePolytope(exponents,"newtonPolytope");
     475  list newtonp=polymakePolytope(exponents);
    599476  // get the variables as string
    600477  string variablen;
     
    604481  }
    605482  variablen=variablen[1,size(variablen)-1];
    606   // call normalFan in order to compute the Groebner fan
    607   list gf=normalFan(newtonp[1],newtonp[4],newtonp[3],1,variablen);
     483  // call normalFanL in order to compute the Groebner fan
     484  list gf=normalFanL(newtonp[1],newtonp[4],newtonp[3],1,variablen);
    608485  // append newtonp to gf
    609486  gf[3]=newtonp;
     
    642519
    643520
    644 /////////////////////////////////////////////////////////////////////////////
    645 
    646 proc intmatToPolymake (intmat M,string art)
    647 "USAGE:  intmatToPolymake(M,art);  M intmat, art string
    648 ASSUME:  - M is an integer matrix which should be transformed into polymake
    649            format;
    650 @*       - art is one of the following strings:
    651 @*           + 'rays'   : indicating that a first column of 0's should be added
    652 @*           + 'points' : indicating that a first column of 1's should be added
    653 RETURN:  string, the matrix is transformed in a string and a first column has
    654                  been added
    655 EXAMPLE: example intmatToPolymake;   shows an example"
    656 {
    657   if (art=="rays")
    658   {
    659     string anf="0 ";
    660   }
    661   else
    662   {
    663     string anf="1 ";
    664   }
    665   string sp;
    666   int i,j;
    667   // create the lattice point list for polymake
    668   for (i=1;i<=nrows(M);i++)
    669   {
    670     sp=sp+anf;
    671     for (j=1;j<=ncols(M);j++)
    672     {
    673       sp=sp+string(M[i,j])+" ";
    674       if (j==ncols(M))
    675       {
    676         sp=sp+"
    677 ";
    678       }
    679     }
    680   }
    681   return(sp);
    682 }
    683 example
    684 {
    685    "EXAMPLE:";
    686    echo=2;
    687    intmat M[3][4]=1,2,3,4,5,6,7,8,9,10,11,12;
    688    intmatToPolymake(M,"rays");
    689    intmatToPolymake(M,"points");
    690 }
    691 
    692 /////////////////////////////////////////////////////////////////////////////
    693 
    694 proc polymakeToIntmat (string pm,string art)
    695 "USAGE:  polymakeToIntmat(pm,art);  pm, art string
    696 ASSUME:  pm is the result of calling polymake with one 'argument' like
    697          VERTICES, AFFINE_HULL, etc., so that the first row of the string is
    698          the name of the corresponding 'argument' and the further rows contain
    699          the result which consists of vectors either over the integers
    700          or over the rationals
    701 RETURN:  intmat, the rows of the matrix are basically the vectors in pm, starting
    702                  from the second row, where each row has been multiplied with the
    703                  lowest common multiple of the denominators of its entries as if
    704                  it is an integer matrix; moreover, if art=='affine', then
    705                  the first column is omitted since we only want affine
    706                  coordinates
    707 EXAMPLE: example polymakeToIntmat;   shows an example"
    708 {
    709   // we need a line break
    710   string zeilenumbruch="
    711 ";
    712   // remove the 'argment' name, i.e. the first row of pm
    713   while (pm[1]!=zeilenumbruch)
    714   {
    715     pm=stringdelete(pm,1);
    716   }
    717   pm=stringdelete(pm,1);
    718   // find out how many entries each vector has, namely one more
    719   // than 'spaces' in a row
    720   int i=1;
    721   int s=1;
    722   int z=1;
    723   while (pm[i]!=zeilenumbruch)
    724   {
    725     if (pm[i]==" ")
    726     {
    727       s++;
    728     }
    729     i++;
    730   }
    731   // if we want to have affine coordinates
    732   if (art=="affine")
    733   {
    734     s--; // then there is one column less
    735     // and the entry of the first column (in the first row) has to be removed
    736     while (pm[1]!=" ")
    737     {
    738       pm=stringdelete(pm,1);
    739     }
    740     pm=stringdelete(pm,1);
    741   }
    742   // we add two line breaks at the end in order to have this as
    743   // a stopping criterion
    744   pm=pm+zeilenumbruch+zeilenumbruch;
    745   // we now have to work through each row
    746   for (i=1;i<=size(pm);i++)
    747   {
    748     // if there are two consecutive line breaks we are done
    749     if ((pm[i]==zeilenumbruch) and (pm[i+1]==zeilenumbruch))
    750     {
    751       i=size(pm)+1;
    752     }
    753     else
    754     {
    755       // a line break has to be replaced by a comma
    756       if (pm[i]==zeilenumbruch)
    757       {
    758         z++;
    759         pm[i]=",";
    760         // if we want to have affine coordinates,
    761         // then we have to delete the first entry in each row
    762         if (art=="affine")
    763         {
    764          while (pm[i+1]!=" ")
    765          {
    766            pm=stringdelete(pm,i+1);
    767          }
    768          pm=stringdelete(pm,i+1);
    769         }
    770       }
    771       // a space has to be replaced by a comma
    772       if (pm[i]==" ")
    773       {
    774         pm[i]=",";
    775       }
    776     }
    777   }
    778   // if we have introduced superflous commata at the end, they should be removed
    779   while (pm[size(pm)]==",")
    780   {
    781     pm=stringdelete(pm,size(pm));
    782   }
    783   // since the matrix could be over the rationals,
    784   // we need a ring with rational coefficients
    785   ring zwischering=0,x,lp;
    786   // create the matrix with the elements of pm as entries
    787   execute("matrix mm["+string(z)+"]["+string(s)+"]="+pm+";");
    788   // transform this into an integer matrix
    789   matrix M[1][ncols(mm)]; // takes a row of mm
    790   int cm;  // takes a lowest common multiple
    791   // multiply each row by an integer such that its entries are integers
    792   for (int j=1;j<=nrows(mm);j++)
    793   {
    794     M=mm[j,1..ncols(mm)];
    795     cm=commondenominator(M);
    796     for (i=1;i<=ncols(mm);i++)
    797     {
    798       mm[j,i]=cm*mm[j,i];
    799     }
    800   }
    801   // transform the matrix mm into an integer matrix
    802   execute("intmat im["+string(z)+"]["+string(s)+"]="+string(mm)+";");
    803   return(im);
    804 }
    805 example
    806 {
    807    "EXAMPLE:";
    808    echo=2;
    809    // this is the usual output of some polymake computation
    810    string pm="VERTICES
    811 0 1 3 5/3 1/3 -1 -23/3 -1/3 5/3 1/3 1
    812 0 1 3 -23/3 5/3 1 5/3 1/3 1/3 -1/3 -1
    813 0 1 1 1/3 -1/3 -1 5/3 1/3 -23/3 5/3 3
    814 0 1 1 5/3 -23/3 3 1/3 5/3 -1/3 1/3 -1
    815 0 1 -1 1/3 5/3 3 -1/3 -23/3 1/3 5/3 1
    816 0 1 -1 -1/3 1/3 1 1/3 5/3 5/3 -23/3 3
    817 0 1 -1 1 3 -5 -1 3 -1 1 -1
    818 0 1 -1 -1 -1 -1 1 1 3 3 -5
    819 0 1 -5 3 1 -1 3 -1 1 -1 -1
    820 
    821 ";
    822    intmat PM=polymakeToIntmat(pm,"affine");
    823    // note that the first column has been removed, since we asked for
    824    // affine coordinates, and the denominators have been cleared
    825    print(PM);
    826 }
    827 
    828521///////////////////////////////////////////////////////////////////////////////
    829522/// PROCEDURES USING TOPCOM
    830523///////////////////////////////////////////////////////////////////////////////
    831524
    832 proc triangulations (list polygon)
    833 "USAGE:  triangulations(polygon); list polygon
     525proc triangulations (list polygon,list #)
     526"USAGE:  triangulations(polygon[,#]); list polygon, list #
    834527ASSUME:  polygon is a list of integer vectors of the same size representing
    835528         the affine coordinates of the lattice points
     
    846539       this  procedure; see
    847540@*     http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     541@*   - if you only want to have the regular triangulations the procedure should
     542       be called with the string 'regular' as optional argument
    848543@*   - the procedure creates the files /tmp/triangulationsinput and
    849544       /tmp/triangulationsoutput;
     
    851546       output containing the triangulations of corresponding to points in the
    852547       format of points2triangs; if you wish to use this for further
    853        computations with topcom, you have to use the procedure
    854        polymakeKeepTmpFiles in before
     548       computations with topcom, you have to call the procedure with the
     549       string 'keepfiles' as optional argument
    855550@*   - note that an integer i in an integer vector representing a triangle
    856551       refers to the ith lattice point, i.e. polygon[i]; this convention is
     
    860555{
    861556  int i,j;
     557  // check for optional arguments
     558  int regular,keepfiles;
     559  if (size(#)>0)
     560  {
     561    for (i=1;i<=size(#);i++)
     562    {
     563      if (typeof(#[i])=="string")
     564      {
     565        if (#[i]=="keepfiles")
     566        {
     567          keepfiles=1;
     568        }
     569        if (#[i]=="regular")
     570        {
     571          regular=1;
     572        }
     573      }
     574    }
     575  }
    862576  // prepare the input for points2triangs by writing the input polygon in the
    863577  // necessary format
     
    875589  write(":w /tmp/triangulationsinput",spi);
    876590  // call points2triangs
    877   system("sh","cd /tmp; points2triangs < triangulationsinput > triangulationsoutput");
     591  if (regular==1) // compute only regular triangulations
     592  {
     593    system("sh","cd /tmp; points2triangs --regular < triangulationsinput > triangulationsoutput");
     594  }
     595  else // compute all triangulations
     596  {
     597    system("sh","cd /tmp; points2triangs < triangulationsinput > triangulationsoutput");
     598  }
    878599  string p2t=read("/tmp/triangulationsoutput"); // takes result of points2triangs
    879   // delete the tmp-files, if polymakekeeptmpfiles is not set
    880   if (defined(polymakekeeptmpfiles)==0)
     600  // delete the tmp-files, if no second argument is given
     601  if (keepfiles==0)
    881602  {
    882603    system("sh","cd /tmp; rm -f triangulationsinput; rm -f triangulationsoutput");
     
    953674            else
    954675            {
    955               np2t=np2t+p2t[i];
     676              if (p2t[i]=="[")
     677              {
     678                // in Topcom version 17.4 (and maybe also in earlier versions) the list
     679                // of triangulations is indexed starting with index 0, in Singular
     680                // we have to start with index 1
     681                np2t=np2t+p2t[i]+"1+";
     682              }
     683              else
     684              {
     685                np2t=np2t+p2t[i];
     686              }
    956687            }
    957688          }
     
    962693  list T;
    963694  execute(np2t);
     695  // depending on the version of Topcom, the list T has or has not an entry T[1]
     696  // if it has none, the entry should be removed
     697  while (typeof(T[1])=="none")
     698  {
     699    T=delete(T,1);
     700  }
    964701  // raise each index by one
    965702  for (i=1;i<=size(T);i++)
     
    1000737RETURN:  list, say L, such that:
    1001738@*             L[1] = intmat, each row gives the affine coordinates of a lattice
    1002                       point in the secondary polytope given by the marked polytope
    1003                       corresponding to polygon
     739                      point in the secondary polytope given by the marked
     740                      polytope corresponding to polygon
    1004741@*             L[2] = the list of corresponding triangulations
    1005742NOTE: if the triangluations are not handed over as optional argument the
     
    1114851       see http://www.math.tu-berlin.de/polymake/
    1115852@*   - in the optional argument # it is possible to hand over other names for
    1116        the variables to be used -- be careful, the format must be correct
    1117        which is not tested, e.g. if you want the variable names to be
     853       the variables to be used -- be careful, the format must be correct and
     854       that is not tested, e.g. if you want the variable names to be
    1118855       u00,u10,u01,u11 then you must hand over the string 'u11,u10,u01,u11'
    1119856@*   - if the triangluations are not handed over as optional argument the
     
    1135872  list sp=secondaryPolytope(polygon,triang);
    1136873  list spp=polymakePolytope(sp[1]);
    1137   list sf=normalFan(spp[1],spp[4],spp[3],1);
     874  list sf=normalFanL(spp[1],spp[4],spp[3],1);
    1138875  return(list(sf[1],sf[2],spp,triang));
    1139876}
     
    13781115@*       triang is a list of integer vectors all of size three describing a
    13791116         triangulation of the polygon described by polygon; if an entry of
    1380          triang is the vector (i,j,k) then the triangle is built from the vertices
     1117         triang is the vector (i,j,k) then the triangle is built by the vertices
    13811118         with indices i, j and k
    13821119RETURN:  intvec, the integer vector eta describing that vertex of the Newton
     
    19481685  // points and
    19491686  // the number b of boundary points are connected by the formula: A=b+2g-2
    1950   return(list(area,bdpts,(area-bdpts+2)/2));
     1687  return(list(area,bdpts,(area-bdpts+2) div 2));
    19511688}
    19521689example
     
    19731710"USAGE:  ellipticNF(polygon);   polygon list
    19741711ASSUME:  polygon is a list of integer vectors in the plane such that their
    1975          convex hull C has precisely one interior lattice point, i.e. C is the
     1712         convex hull C has precisely one interior lattice point; i.e. C is the
    19761713         Newton polygon of an elliptic curve
    19771714PURPOSE: compute the normal form of the polygon with respect to the unimodular
     
    19911728  int i;            // index
    19921729  intvec edge;      // stores the vector of an edge
    1993   intvec boundary;  // stores lattice lengths of the edges of the Newton cylce
     1730  intvec boundary;  // stores lattice lengths of the edges of the Newton cycle
    19941731  // find the vertices of the Newton cycle and order it clockwise
    19951732  list pg=findOrientedBoundary(polygon)[2];
     
    23022039
    23032040/////////////////////////////////////////////////////////////////////////////////
    2304 /// AUXILARY PROCEDURES
    2305 /////////////////////////////////////////////////////////////////////////////////
    2306 
    2307 proc polymakeKeepTmpFiles (int i)
    2308 "USAGE:  polymakeKeepTmpFiles(int i);   i int
    2309 PURPOSE: some procedures create files in the directory /tmp which are used for
    2310          computations with polymake respectively topcom; these will be removed
    2311          when the corresponding procedure is left; however, it might be
    2312          desireable to keep them for further computations with either polymake or
    2313          topcom; this can be achieved by this procedure; call the procedure as:
    2314 @*       - polymakeKeepTmpFiles(1); - then the files will be kept
    2315 @*       - polymakeKeepTmpFiles(0); - then files will be removed in the future
    2316 RETURN:  none"
    2317 {
    2318   if ((i==1) and (defined(polymakekeeptmpfiles)==0))
    2319   {
    2320     int polymakekeeptmpfiles;
    2321     export(polymakekeeptmpfiles);
    2322   }
    2323   if (i!=1)
    2324   {
    2325     if (defined(polymakekeeptmpfiles))
    2326     {
    2327       kill polymakekeeptmpfiles;
    2328     }
    2329   }
    2330 }
    2331 
    2332 
    2333 /////////////////////////////////////////////////////////////////////////////////
    23342041/////////////////////////////////////////////////////////////////////////////////
    23352042/// AUXILARY PROCEDURES, WHICH ARE DECLARED STATIC
     
    23642071}
    23652072
    2366 static proc intmatcoldelete (intmat w,int i)
     2073static proc intmatcoldelete (def w,int i)
    23672074"USAGE:      intmatcoldelete(w,i); w intmat, i int
    23682075RETURN:      intmat, the integer matrix w with the ith comlumn deleted
    2369 NOTE:        the procedure is called by intmatsort and normalFan"
    2370 {
    2371   if ((i<1) or (i>ncols(w)) or (ncols(w)==1))
    2372   {
    2373     return(w);
    2374   }
    2375   if (i==1)
    2376   {
    2377     intmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),2..ncols(w)];
    2378     return(M);
    2379   }
    2380   if (i==ncols(w))
    2381   {
    2382     intmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),1..ncols(w)-1];
    2383     return(M);
    2384   }
    2385   else
    2386   {
    2387     intmat M[nrows(w)][i-1]=w[1..nrows(w),1..i-1];
    2388     intmat N[nrows(w)][ncols(w)-i]=w[1..nrows(w),i+1..ncols(w)];
    2389     return(intmatconcat(M,N));
     2076NOTE:        the procedure is called by intmatsort and normalFanL"
     2077{
     2078  if (typeof(w)=="intmat")
     2079  {
     2080    if ((i<1) or (i>ncols(w)) or (ncols(w)==1))
     2081    {
     2082      return(w);
     2083    }
     2084    if (i==1)
     2085    {
     2086      intmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),2..ncols(w)];
     2087      return(M);
     2088    }
     2089    if (i==ncols(w))
     2090    {
     2091      intmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),1..ncols(w)-1];
     2092      return(M);
     2093    }
     2094    else
     2095    {
     2096      intmat M[nrows(w)][i-1]=w[1..nrows(w),1..i-1];
     2097      intmat N[nrows(w)][ncols(w)-i]=w[1..nrows(w),i+1..ncols(w)];
     2098      return(intmatconcat(M,N));
     2099    }
     2100  }
     2101  if (typeof(w)=="bigintmat")
     2102  {
     2103    if ((i<1) or (i>ncols(w)) or (ncols(w)==1))
     2104    {
     2105      return(w);
     2106    }
     2107    if (i==1)
     2108    {
     2109      bigintmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),2..ncols(w)];
     2110      return(M);
     2111    }
     2112    if (i==ncols(w))
     2113    {
     2114      bigintmat M[nrows(w)][ncols(w)-1]=w[1..nrows(w),1..ncols(w)-1];
     2115      return(M);
     2116    }
     2117    else
     2118    {
     2119      bigintmat MN[nrows(w)][ncols(w)-1];
     2120      MN[1..nrows(w),1..i-1]=w[1..nrows(w),1..i-1];
     2121      MN[1..nrows(w),i..ncols(w)-1]=w[1..nrows(w),i+1..ncols(w)];
     2122      return(MN);
     2123    }
     2124  } else
     2125  {
     2126    ERROR("intmatcoldelete: input matrix has to be of type intmat or bigintmat");
     2127    intmat M; return(M);
    23902128  }
    23912129}
     
    26832421  return(list(coord,coords,latex));
    26842422}
     2423
     2424static proc intmatAddFirstColumn (def M,string art)
     2425"USAGE:  intmatAddFirstColumn(M,art);  M intmat, art string
     2426ASSUME:  - M is an integer matrix where a first column of 0's or 1's should be added
     2427@*       - art is one of the following strings:
     2428@*         + 'rays'   : indicating that a first column of 0's should be added
     2429@*         + 'points' : indicating that a first column of 1's should be added
     2430RETURN:  intmat, a first column has been added to the matrix"
     2431{
     2432  if (typeof (M) == "intmat")
     2433  {
     2434    intmat N[nrows(M)][ncols(M)+1];
     2435    int i,j;
     2436    for (i=1;i<=nrows(M);i++)
     2437    {
     2438      if (art=="rays")
     2439      {
     2440        N[i,1]=0;
     2441      }
     2442      else
     2443      {
     2444        N[i,1]=1;
     2445      }
     2446      for (j=1;j<=ncols(M);j++)
     2447      {
     2448        N[i,j+1]=M[i,j];
     2449      }
     2450    }
     2451    return(N);
     2452  }
     2453  if (typeof (M) == "bigintmat")
     2454  {
     2455    bigintmat N[nrows(M)][ncols(M)+1];
     2456    int i,j;
     2457    for (i=1;i<=nrows(M);i++)
     2458    {
     2459      if (art=="rays")
     2460      {
     2461        N[i,1]=0;
     2462      }
     2463      else
     2464      {
     2465        N[i,1]=1;
     2466      }
     2467      for (j=1;j<=ncols(M);j++)
     2468      {
     2469        N[i,j+1]=M[i,j];
     2470      }
     2471    }
     2472    return(N);
     2473  }
     2474  else
     2475  {
     2476    ERROR ("intmatAddFirstColumn: input matrix has to be either intmat or bigintmat");
     2477    intmat N;
     2478    return (N);
     2479  }
     2480}
     2481
     2482
     2483
  • Singular/LIB/tropical.lib

    r27877c1 re57255  
    1 ///////////////////////////////////////////////////////////
    2 version="version tropical.lib 4.0.0.0 Jun_2013 "; // $Id$
     1//
     2version="$Id$";
    33category="Tropical Geometry";
    44info="
     
    650650          // pass first to a ring where a and @a
    651651          // are variables in order to use maps
    652           string @mp= string(minpoly);
     652          poly mp=minpoly;
    653653          ring INTERRING=char(LIFTRING),(t,@a,a),dp;
    654           execute("poly mp=" + @mp + ";");
     654          poly mp=imap(LIFTRING,mp);
    655655          ideal LIFT=imap(LIFTRING,LIFT);
    656656          kill LIFTRING;
     
    10121012  {
    10131013    def GLOBALRING=basering;
    1014     string @mp= string(minpoly);
     1014    number mp=minpoly;
    10151015    execute("ring LOCALRING=("+charstr(basering)+"),("+varstr(basering)+"),ds;");
    1016     execute("minpoly= " + @mp + ";");
    10171016    poly f=imap(GLOBALRING,f);
     1017    minpoly=imap(GLOBALRING,mp);
    10181018  }
    10191019  // check if a substitution is necessary
     
    10491049    if (minpoly!=0)
    10501050    {
    1051       string @mp= string(minpoly);
     1051      poly mp=minpoly;
    10521052      def OLDRING=basering;
    10531053      execute("ring NEWRING=0,("+varstr(basering)+","+parstr(basering)+"),ds;");
    1054       execute("ideal I = " + @mp + ";");
    1055       I = I,imap(OLDRING,f);
     1054      ideal I=imap(OLDRING,mp),imap(OLDRING,f);
    10561055    }
    10571056    else
     
    10651064      w=NewtP[jj]-NewtP[jj+1];
    10661065      ggteiler=gcd(w[1],w[2]);
    1067       zw=w[1]/ggteiler;
    1068       w[1]=w[2]/ggteiler;
     1066      zw=w[1] div ggteiler;
     1067      w[1]=w[2] div ggteiler;
    10691068      w[2]=zw;
    10701069      // if we have introduced a third variable for the parameter, then w needs a third component
     
    11341133    else
    11351134    {
    1136       string @mp= string(minpoly);
     1135      poly mp=minpoly;
    11371136      ring degreering=0,a,dp;
    1138       execute("poly mp=" + @mp + ";");
     1137      poly mp=imap(countring,mp);
    11391138      numberofbranchesfound=numberofbranchesfound+deg(mp);
    11401139      setring countring;
     
    11581157   ring r=0,(x,y),ds;
    11591158   poly f=x2-y4+x5y7;
    1160    puiseuxExpansion(puiseuxExpansion(f,3));
     1159   puiseuxExpansion(f,3,"subst");
     1160   displayPuiseuxExpansion(puiseuxExpansion(f,3));
    11611161}
    11621162
     
    15401540      ggt=gcd(normalvector[1],normalvector[2]);   // the gcd of the entries
    15411541      zw=normalvector[2];    // create the outward pointing normal vector
    1542       normalvector[2]=-normalvector[1]/ggt;
    1543       normalvector[1]=zw/ggt;
     1542      normalvector[2]=-normalvector[1] div ggt;
     1543      normalvector[1]=zw div ggt;
    15441544      if (size(#)==0) // we are computing w.r.t. minimum
    15451545      {
     
    27182718        if(k<>j)  // except the unit vector of the non-zero component
    27192719        {
    2720           intvec u; u[size(w)]=0; u[k]=1;
    2721           O[r,1..size(w)]=u; r=r+1;
     2720          intvec u;
     2721          u[size(w)]=0;
     2722          u[k]=1;
     2723          O[r,1..size(w)]=u;
     2724          r=r+1;
     2725          kill u;
    27222726        }
    27232727      }
     
    47084712        wneu=NewtP[1]-NewtP[2];
    47094713        int ggteiler=gcd(wneu[1],wneu[2]);
    4710         wneu[1]=-wneu[1]/ggteiler;
    4711         wneu[2]=wneu[2]/ggteiler;
     4714        wneu[1]=-wneu[1] div ggteiler;
     4715        wneu[2]=wneu[2] div ggteiler;
    47124716        if (wneu[1]>0)
    47134717        {
     
    48074811  for (jj=1;jj<=anzahlvariablen+numberdeletedvariables-1;jj++)
    48084812  {
    4809     PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight/ww[1]);
     4813    PARA[jj]=(PARA[jj]+a[jj+1])*t^(tw[jj+1]*tweight div ww[1]);
    48104814  }
    48114815  // if we have reached the stop-level, i.e. either
     
    53535357    if (koeffizienten[j-ord(p)+1]!=0)
    53545358    {
    5355       if ((j-(N*wj)/w1)==0)
     5359      if ((j-(N*wj) div w1)==0)
    53565360      {
    53575361        dp=dp+displaycoef(koeffizienten[j-ord(p)+1]);
    53585362      }
    5359       if (((j-(N*wj)/w1)==1) and (N!=1))
     5363      if (((j-(N*wj) div w1)==1) and (N!=1))
    53605364      {
    53615365        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t^(1/"+string(N)+")";
    53625366      }
    5363       if (((j-(N*wj)/w1)==1) and (N==1))
     5367      if (((j-(N*wj) div w1)==1) and (N==1))
    53645368      {
    53655369        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t";
    53665370      }
    5367       if (((j-(N*wj)/w1)==-1) and (N==1))
     5371      if (((j-(N*wj) div w1)==-1) and (N==1))
    53685372      {
    53695373        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*1/t";
    53705374      }
    5371       if (((j-(N*wj)/w1)==-1) and (N!=1))
     5375      if (((j-(N*wj) div w1)==-1) and (N!=1))
    53725376      {
    53735377        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*1/t^(1/"+string(N)+")";
    53745378      }
    5375       if (((j-(N*wj)/w1)>1) and (N==1))
    5376       {
    5377         dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t^"+string(j-(N*wj)/w1);
    5378       }
    5379       if (((j-(N*wj)/w1)>1) and (N!=1))
    5380       {
    5381         dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t^("+string(j-(N*wj)/w1)+"/"+string(N)+")";
    5382       }
    5383       if (((j-(N*wj)/w1)<-1) and (N==1))
     5379      if (((j-(N*wj) div w1)>1) and (N==1))
     5380      {
     5381        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t^"+string(j-(N*wj) div w1);
     5382      }
     5383      if (((j-(N*wj) div w1)>1) and (N!=1))
     5384      {
     5385        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*t^("+string(j-(N*wj) div w1)+"/"+string(N)+")";
     5386      }
     5387      if (((j-(N*wj) div w1)<-1) and (N==1))
    53845388      {
    53855389        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*1/t^"+string(wj-j);
    53865390      }
    5387       if (((j-(N*wj)/w1)<-1) and (N!=1))
    5388       {
    5389         dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*1/t^("+string((N*wj)/w1-j)+"/"+string(N)+")";
     5391      if (((j-(N*wj) div w1)<-1) and (N!=1))
     5392      {
     5393        dp=dp+displaycoef(koeffizienten[j-ord(p)+1])+"*1/t^("+string((N*wj) div w1-j)+"/"+string(N)+")";
    53905394      }
    53915395      if (j<deg(p))
     
    54955499    {
    54965500      setring LIFTRing;
    5497       string @mp= string(minpoly);
     5501      poly mp=minpoly;
    54985502      execute("ring TESTRing=("+charstr(LIFTRing)+"),("+varstr(BASERING)+"),dp;");
    5499       execute("minpoly= " + @mp + ";");
     5503      minpoly=number(imap(LIFTRing,mp));
    55005504      ideal i=imap(BASERING,i);
    55015505    }
     
    57695773              wneu=NewtP[jjj]-NewtP[jjj+1];
    57705774              int ggteiler=gcd(wneu[1],wneu[2]);
    5771               wneu[1]=-wneu[1]/ggteiler;
    5772               wneu[2]=wneu[2]/ggteiler;
     5775              wneu[1]=-wneu[1] div ggteiler;
     5776              wneu[2]=wneu[2] div ggteiler;
    57735777              if (wneu[1]>0)
    57745778              {
     
    58695873        {
    58705874          execute("ring PARARing=("+string(char(basering))+",@a),t,ls;");
    5871           minpoly=number(imap(PREGFANRING,m)); // ?
     5875          minpoly=number(imap(PREGFANRING,m));
    58725876        }
    58735877        else
     
    59085912        for (jjj=1;jjj<=anzahlvariablen+numberdeletedvariables-1;jjj++)
    59095913        {
    5910           PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight/ww[1]);
     5914          PARA[jjj]=(PARA[jjj]+zeros[size(zeros)][jjj+1])*t^(ww[jjj+1]*tweight div ww[1]);
    59115915        }
    59125916        // delete the last entry in zero, since that one has
     
    60336037    {
    60346038      I=subst(i,var(lastvar),0);
    6035       while (subst(I[1],t,0)==0)
     6039      while ((I[1]!=0) and (subst(I[1],t,0)==0))
    60366040      {
    60376041        I[1]=I[1]/t;
     
    78147818    poly denom=delta*hn^5;
    78157819    poly ggt=gcd(num,denom);
    7816     num=num/ggt;
    7817     denom=denom/ggt;
     7820    num=num div ggt;
     7821    denom=denom div ggt;
    78187822    setring BASERING;
    78197823    poly num=imap(TRING,num);
  • Singular/ipid.cc

    r9e8ae12 re57255  
    433433  else if ((IDTYP(h)==RING_CMD)||(IDTYP(h)==QRING_CMD))
    434434    rKill(h);
    435   else
     435  else if (IDDATA(h)!=NULL)
    436436    s_internalDelete(IDTYP(h),IDDATA(h),r);
    437437  //  general  -------------------------------------------------------------
  • Singular/singular-libs

    r27877c1 re57255  
    2323        paraplanecurves.lib phindex.lib \
    2424        pointid.lib poly.lib \
    25         oldpolymake.lib presolve.lib primdec.lib primdecint.lib \
     25        polymake.lib presolve.lib primdec.lib primdecint.lib \
    2626        primitiv.lib qhmoduli.lib random.lib realclassify.lib \
    2727        realrad.lib reesclos.lib resbinomial.lib \
     
    5757        ncfactor.lib nctools.lib perron.lib qmatrix.lib \
    5858        ncall.lib
    59        
    6059
     60
  • Singular/subexpr.cc

    r9e8ae12 re57255  
    455455void s_internalDelete(const int t,  void *d, const ring r)
    456456{
     457  assume(d!=NULL);
    457458  switch (t)
    458459  {
  • Tst/Short/bug_newstruct.res.gz.uu

    r9e8ae12 re57255  
    11begin 640 bug_newstruct.res.gz
    2 M'XL(")/1P5$``V)U9U]N97=S=')U8W0N<F5S`)6236O"0!"&[_D5+\%#`A+=
    3 MJJUMZI86+P$1P=*K^=K(0K*1_6CIO^_&F(W7GG9FWOEXAMGCYS;9`R`4N^0#
    4 MOE8ZJGGNQ][QICQ0V.")"ZZ#,/:Z%Y0B-^>38#]*2U/HR%J1TIEV50L*9R\C
    5 MS&9PR5#:5)535]$H!?ZEY-]<M=*?^C57-M<T329*-471"@:=\=H/1[C'NS%/
    6 M$:XENU%>T[ZLB#WKO2'MO!1<P8B255RPLA>8E*U$6Q1&2E:""U@W9U4K&?IF
    7 MM4W&^J5O81NF;L@SQ4"-@YM-YA2':,#?C%"$=$*WR&;`*C(!T6ID2O&SP"39
    8 M?[WODNTDF(?0+1K6Y,S25="_%W9=,EBN%N&_T`FQ[&ZNHR?VO!;Z&G[M.E//
    9 =,=_\(?/NI,2>M/L4W<F-"D@83[P_D)E)>TH"````
     2M'XL("+JRJ5(``V)U9U]N97=S=')U8W0N<F5S`)62RVK#,!!%]_Z*B\G"AN!$
     3M;=JF=:/2DHTAA$!*MXD?<A#84I#DEOY]I3B6L^U*,W/G<8;1_G.=;0$0BDWV
     4M@=!HDS2\"--@?U7N*&SPP`4W49P&[@6E*+K30;`?;517FL1:B3:Y\57W%-Y>
     5M))C-X).A35?77GU(1BD*SQ7_YEJJ<!HV7-O<KFUS4>DI2BD83,Z;,![A'F_&
     6M/"6XE&Q&>4G[LC(-K/>&H_..X!J=J%C-!:MZ@2DE%619=DJQ"ES`N@6KI6+H
     7MFS4V&<N7OH5M>/1#GBD&:NS\;#*GV"4#_FJ$(L0);I'5@%7F`D(:Y%KSD\`D
     8MVWZ];[+U))K',!(M:PMFZ6J8WS.[+!DM'A;QO]`)L>Q^KJ<G]KP6^A)^=9UI
     9>X)FO_I!Y<U)B3^H^A3MYIR,2IY/@#R.]3(I*`@``
    1010`
    1111end
  • Tst/Short/polymake.tst

    r27877c1 re57255  
    33LIB "tst.lib";
    44tst_init();
    5 LIB "oldpolymake.lib"; // TODO: update test result!
     5LIB "polymake.lib";
    66///////////////////////////////////////////////////////////////////////////
    77// A) Test for Procedures using Polymake
    88///////////////////////////////////////////////////////////////////////////
    99example polymakePolytope;
    10 example newtonPolytope;
     10example newtonPolytopeP;
    1111example newtonPolytopeLP;
    12 example normalFan;
     12example normalFanL;
    1313example groebnerFan;
    14 example intmatToPolymake;
    15 example polymakeToIntmat;
    1614///////////////////////////////////////////////////////////////////////////
    1715// B) Test for Procedures using Topcom
  • debian/changelog

    r9e8ae12 re57255  
    1 singular (3.1.3.sw-1) unstable; urgency=low
     1singular (4.0.0-1) unstable; urgency=low
    22
    33  * Initial release.
  • doc/COPYING.texi

    r27877c1 re57255  
    131131@copyright{} Winfried Bruns and Bogdan Ichim
    132132@* @uref{http://www.mathematik.uni-osnabrueck.de/normaliz/}
    133 @item polymake (used by oldpolymake.lib, @pxref{oldpolymake_lib})
     133@item polymake (used by polymake.lib, @pxref{polymake_lib})
    134134@copyright{} Ewgenij Gawrilow and Michael Joswig
    135135@* @uref{http://www.polymake.de/}
     
    142142@copyright{} Oliver Labs (2001-2008), Stephan Holzer (2004-2005)
    143143@* @uref{http://surfex.AlgebraicSurface.net}
    144 @item TOPCOM (used by oldpolymake.lib, @pxref{oldpolymake_lib})
     144@item TOPCOM (used by polymake.lib, @pxref{polymake_lib})
    145145@copyright{} J@"org Rambau
    146146@* @uref{http://www.rambau.wm.uni-bayreuth.de/TOPCOM/}
  • doc/Makefile.bsp

    r27877c1 re57255  
    6363CHKSUM_DB       = ${DOC_SUBDIR}/chksum
    6464# which tags to avoid:
    65 DOC2TEX_EXAMPLE_EXCLUSIONS = -exclude oldpolymake
     65DOC2TEX_EXAMPLE_EXCLUSIONS = -exclude polymake
    6666# which tags to avoid:
    67 TAG             = oldpolymake
     67TAG             = polymake
    6868DOC2TEX         = ${PERL} ./doc2tex.pl -docdir ${DOC_SUBDIR} \
    6969                  -Singular ${SINGULAR} -verbose ${VERBOSE} -make ${MAKE} \
  • doc/NEWS.texi

    r9e8ae12 re57255  
    4242@itemize
    4343@item @nref{sba}: an F5 like Groebner base computation
     44@item @nref{ASSUME}: support for debugging libraries
    4445@end itemize
    4546
     
    4748@itemize
    4849@item @nref{classifyci_lib}: Isolated complete intersection singularities in characteristic  0
    49 @item @xref{schubert_lib}:  Proceduces for Intersection Theory
     50@item @nref{derham_lib}: Computation of deRham cohomology
    5051@end itemize
    5152
     
    5455@item
    5556improved grobcov.lib (@nref{grobcov_lib})
     57@item
     58fixed normal.lib (@nref{normal_lib})
    5659@end itemize
    5760
  • kernel/kstd1.cc

    r9e8ae12 re57255  
    29692969
    29702970      // enter into S, L, and T
    2971       //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     2971      if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     2972      {
    29722973        enterT(strat->P, strat);
    2973       // posInS only depends on the leading term
    2974       strat->enterS(strat->P, pos, strat, strat->tl);
    2975 
     2974        // posInS only depends on the leading term
     2975        strat->enterS(strat->P, pos, strat, strat->tl);
     2976
     2977        if (pos<strat->sl)
     2978        {
     2979          need_retry++;
     2980          // move all "larger" elements fromS to L
     2981          // remove them from T
     2982          int ii=pos+1;
     2983          for(;ii<=strat->sl;ii++)
     2984          {
     2985            LObject h;
     2986            memset(&h,0,sizeof(h));
     2987            h.tailRing=strat->tailRing;
     2988            h.p=strat->S[ii]; strat->S[ii]=NULL;
     2989            strat->initEcart(&h);
     2990            h.sev=strat->sevS[ii];
     2991            int jj=strat->tl;
     2992            while (jj>=0)
     2993            {
     2994              if (strat->T[jj].p==h.p)
     2995              {
     2996                strat->T[jj].p=NULL;
     2997                if (jj<strat->tl)
     2998                {
     2999                  memmove(&(strat->T[jj]),&(strat->T[jj+1]),
     3000                          (strat->tl-jj)*sizeof(strat->T[jj]));
     3001                  memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]),
     3002                          (strat->tl-jj)*sizeof(strat->sevT[jj]));
     3003                }
     3004                strat->tl--;
     3005                break;
     3006              }
     3007              jj--;
     3008            }
     3009            int lpos=strat->posInL(strat->L,strat->Ll,&h,strat);
     3010            enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos);
     3011            #ifdef KDEBUG
     3012            if (TEST_OPT_DEBUG)
     3013            {
     3014              Print("move S[%d] -> L[%d]: ",ii,pos);
     3015              p_wrp(h.p,currRing, strat->tailRing);
     3016              PrintLn();
     3017            }
     3018            #endif
     3019          }
     3020          if (strat->fromQ!=NULL)
     3021          {
     3022            for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0;
     3023          }
     3024          strat->sl=pos;
     3025        }
     3026      }
     3027      else
     3028      {
     3029        // clean P
     3030      }
    29763031      if (strat->P.lcm!=NULL)
    29773032#ifdef HAVE_RINGS
     
    29803035        pLmFree(strat->P.lcm);
    29813036#endif
    2982       if (pos<strat->sl)
    2983       {
    2984         need_retry++;
    2985         // move all "larger" elements fromS to L
    2986         // remove them from T
    2987         int ii=pos+1;
    2988         for(;ii<=strat->sl;ii++)
    2989         {
    2990           LObject h;
    2991           memset(&h,0,sizeof(h));
    2992           h.tailRing=strat->tailRing;
    2993           h.p=strat->S[ii]; strat->S[ii]=NULL;
    2994           strat->initEcart(&h);
    2995           h.sev=strat->sevS[ii];
    2996           int jj=strat->tl;
    2997           while (jj>=0)
    2998           {
    2999             if (strat->T[jj].p==h.p)
    3000             {
    3001               strat->T[jj].p=NULL;
    3002               if (jj<strat->tl)
    3003               {
    3004                 memmove(&(strat->T[jj]),&(strat->T[jj+1]),
    3005                         (strat->tl-jj)*sizeof(strat->T[jj]));
    3006                 memmove(&(strat->sevT[jj]),&(strat->sevT[jj+1]),
    3007                         (strat->tl-jj)*sizeof(strat->sevT[jj]));
    3008               }
    3009               strat->tl--;
    3010               break;
    3011             }
    3012             jj--;
    3013           }
    3014           int lpos=strat->posInL(strat->L,strat->Ll,&h,strat);
    3015           enterL(&strat->L,&strat->Ll,&strat->Lmax,h,lpos);
    3016           #ifdef KDEBUG
    3017           if (TEST_OPT_DEBUG)
    3018           {
    3019             Print("move S[%d] -> L[%d]: ",ii,pos);
    3020             p_wrp(h.p,currRing, strat->tailRing);
    3021             PrintLn();
    3022           }
    3023           #endif
    3024         }
    3025         if (strat->fromQ!=NULL)
    3026         {
    3027           for(ii=pos+1;ii<=strat->sl;ii++) strat->fromQ[ii]=0;
    3028         }
    3029         strat->sl=pos;
    3030       }
    30313037    }
    30323038
  • kernel/kstd2.cc

    r9e8ae12 re57255  
    13901390
    13911391      // enter into S, L, and T
    1392       //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     1392      if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     1393      {
    13931394        enterT(strat->P, strat);
    13941395#ifdef HAVE_RINGS
    1395       if (rField_is_Ring(currRing))
    1396         superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
    1397       else
    1398 #endif
    1399         enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
    1400       // posInS only depends on the leading term
    1401       strat->enterS(strat->P, pos, strat, strat->tl);
     1396        if (rField_is_Ring(currRing))
     1397          superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     1398        else
     1399#endif
     1400          enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     1401        // posInS only depends on the leading term
     1402        strat->enterS(strat->P, pos, strat, strat->tl);
    14021403#if 0
    1403       int pl=pLength(strat->P.p);
    1404       if (pl==1)
    1405       {
    1406         //if (TEST_OPT_PROT)
    1407         //PrintS("<1>");
    1408       }
    1409       else if (pl==2)
    1410       {
    1411         //if (TEST_OPT_PROT)
    1412         //PrintS("<2>");
    1413       }
    1414 #endif
     1404        int pl=pLength(strat->P.p);
     1405        if (pl==1)
     1406        {
     1407          //if (TEST_OPT_PROT)
     1408          //PrintS("<1>");
     1409        }
     1410        else if (pl==2)
     1411        {
     1412          //if (TEST_OPT_PROT)
     1413          //PrintS("<2>");
     1414        }
     1415#endif
     1416      }
    14151417      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    14161418//      Print("[%d]",hilbeledeg);
     
    24492451      // enter into S, L, and T
    24502452      // here we need to recompute new signatures, but those are trivial ones
    2451       //if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
    2452       enterT(strat->P, strat);
    2453       // posInS only depends on the leading term
    2454       strat->enterS(strat->P, pos, strat, strat->tl);
     2453      if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     2454      {
     2455        enterT(strat->P, strat);
     2456        // posInS only depends on the leading term
     2457        strat->enterS(strat->P, pos, strat, strat->tl);
    24552458//#if 1
    24562459#ifdef DEBUGF5
    2457       Print("ELEMENT ADDED TO GCURR DURING INTERRED: ");
    2458       pWrite(pHead(strat->S[strat->sl]));
    2459       pWrite(strat->sig[strat->sl]);
    2460 #endif
    2461       if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     2460        Print("ELEMENT ADDED TO GCURR DURING INTERRED: ");
     2461        pWrite(pHead(strat->S[strat->sl]));
     2462        pWrite(strat->sig[strat->sl]);
     2463#endif
     2464        if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
     2465      }
    24622466      //      Print("[%d]",hilbeledeg);
    24632467      if (strat->P.lcm!=NULL)
Note: See TracChangeset for help on using the changeset viewer.