Changeset a2930e in git


Ignore:
Timestamp:
Aug 8, 2008, 12:30:35 PM (16 years ago)
Author:
Thomas Markwig <keilen@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
90203a90e070f1fa64b3e7012c9d1f4ef0992f60
Parents:
5c2528e65b18f6f0a12b589f87196ebcd79b90af
Message:
Procedures secondaryFan and polymakeKeepTmpFiles added.


git-svn-id: file:///usr/local/Singular/svn/trunk@10975 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/polymake.lib

    r5c2528 ra2930e  
    1 version="$Id: polymake.lib,v 1.7 2008-08-07 16:04:01 keilen Exp $";
     1version="$Id: polymake.lib,v 1.8 2008-08-08 10:30:35 keilen Exp $";
    22category="Tropical Geometry";
    33info="
     
    4141     secondaryPolytope(list)       computes the secondary polytope of a marked polytope
    4242
     43PROCEDURES USING POLYMAKE AND TOPCOM:
     44     secondaryFan(list)            computes the secondary fan of a marked polytope
     45
    4346PROCEDURES CONERNED WITH PLANAR POLYGONS:
    4447     cycleLength(list,intvec)      computes the cycleLength of cycle dual to list with interior point intvec
     
    5255     ellipticNFDB(int)             displays the 16 normal forms of elliptic polygons
    5356
    54 KEYWORDS:        polytope; fan; secondary fan; secondary polytope; polymake;
    55                     Newton polytope; Groebner fan
     57AUXILARY PROCEDURES:
     58     polymakeKeepTmpFiles(int)     determines whether the files created in /tmp should be kept
     59
     60KEYWORDS:    polytope; fan; secondary fan; secondary polytope; polymake;
     61             Newton polytope; Groebner fan
    5662
    5763";
     
    7985LIB "random.lib";
    8086////////////////////////////////////////////////////////////////////////////////////
     87
    8188
    8289////////////////////////////////////////////////////////////////////////////////////////
     
    108115         starts indexing its vertices by zero while we start with one !
    109116@*    -  the procedure creates the file  /tmp/polytope.polymake which contains the polytope
    110          in polymake format and which can be used for further computations with polymake
     117         in polymake format; if you wish to use this for further computations with polymake,
     118         you have to use the procedure polymakeKeepTmpFiles in before
    111119@*    -  moreover, the procedure creates the file /tmp/polytope.output which it deletes
    112120         again before ending
     
    206214    intmat neq[1][ncols(polytope)+1];
    207215  }
     216  // delete the tmp-files, if polymakekeeptmpfiles is not set
     217  if (defined(polymakekeeptmpfiles)==0)
     218  {
     219    system("sh","/bin/rm /tmp/"+dateiname+".polymake");
     220  }
     221  // return the files
    208222  return(list(np,nd,nveg,neq));
    209223}
     
    468482    }
    469483  }
     484  // delete the tmp-files, if polymakekeeptmpfiles is not set
     485  if (defined(polymakekeeptmpfiles)==0)
     486  {
     487    system("sh","/bin/rm /tmp/ineq.polymake");
     488    system("sh","/bin/rm /tmp/ineq.output");
     489  }
    470490  // get the linearity space
    471491  return(list(ineq,linearity));
     
    757777////////////////////////////////////////////////////////////////////////////////////////
    758778
    759 proc triangulations (list polygon, list #)
    760 "USAGE:  triangulations(polygon[,#]); list polygon, list #
     779proc triangulations (list polygon)
     780"USAGE:  triangulations(polygon); list polygon
    761781ASSUME:  polygon is a list of integer vectors of the same size representing the affine
    762782         coordinates of the lattice points
     
    776796         the former is used as input for points2triangs and the latter is its output
    777797         containing the triangulations of corresponding to points in the format
    778          of points2triangs; if you want to use these for further computations with topcom
    779          you have to hand an optional parameter (e.g. the number 1) to the procedure,
    780          since otherwise the files will be destroyed before leaving the procedure
     798         of points2triangs; if you wish to use this for further computations with topcom,
     799         you have to use the procedure polymakeKeepTmpFiles in before
    781800@*     - note that an integer i in an integer vector representing a triangle refers to
    782801         the ith lattice point, i.e. polygon[i]; this convention is different from
     
    802821  system("sh","cd /tmp; points2triangs < triangulationsinput > triangulationsoutput");
    803822  string p2t=read("/tmp/triangulationsoutput"); // takes the result of points2triangs
    804   if (size(#)==0)
     823  // delete the tmp-files, if polymakekeeptmpfiles is not set
     824  if (defined(polymakekeeptmpfiles)==0)
    805825  {
    806826    system("sh","cd /tmp; rm -f triangulationsinput; rm -f triangulationsoutput");
     
    9901010   secpoly[2];
    9911011}
     1012
     1013////////////////////////////////////////////////////////////////////////////////////////
     1014/// PROCEDURES USING POLYMAKE AND TOPCOM
     1015////////////////////////////////////////////////////////////////////////////////////////
     1016
     1017proc secondaryFan (list polygon,list #)
     1018"USAGE:  secondaryFan(polygon[,#]); list polygon, list #
     1019ASSUME:  - polygon is a list of integer vectors of the same size representing the affine
     1020           coordinates of lattice points
     1021@*       - if the triangulations of the corresponding polygon have already been computed
     1022           with the procedure triangulations then these can be given as a second (optional)
     1023           argument in order to avoid doing this computation again
     1024PURPOSE: the procedure considers the marked polytope given as the convex hull of
     1025         the lattice points and with these lattice points as markings; it then
     1026         computes the lattice points of the secondary polytope given by this
     1027         marked polytope which correspond to the triangulations computed by
     1028         the procedure triangulations
     1029RETURN:  list, the ith entry of L[1] contains information about the ith cone in the
     1030               secondary fan of the polygon, i.e. the cone dual to the ith vertex of the
     1031               secondary polytope
     1032@*             L[1][i][1] = integer matrix representing the inequalities which describe the
     1033                            cone dual to the ith vertex
     1034@*             L[1][i][2] = a list which contains the inequalities represented by L[i][1]
     1035                            as a list of strings, where we use the variables x(1),...,x(n)
     1036@*             L[1][i][3] = only present if 'er' is set to 1; in that case it is an interger matrix
     1037                            whose rows are the extreme rays of the cone
     1038@*             L[2] = is an integer matrix whose rows span the linearity space of the fan,
     1039                      i.e. the linear space which is contained in each cone
     1040@*             L[3] = the secondary polytope in the format of the procedure polymakePolytope
     1041@*             L[4] = the list of triangulations corresponding to the vertices
     1042                      of the secondary polytope
     1043NOTE:    - the procedure calls for its computation polymake by Ewgenij Gawrilow,
     1044           TU Berlin and Michael Joswig, so it only works if polymake is installed;
     1045           see http://www.math.tu-berlin.de/polymake/
     1046@*       - in the optional argument # it is possible to hand over other names for the
     1047           variables to be used -- be carful, the format must be correct and that is
     1048           not tested, e.g. if you want the variable names to be u00,u10,u01,u11
     1049           then you must hand over the string u11,u10,u01,u11
     1050@*       - if the triangluations are not handed over as optional argument the procedure calls
     1051           for its computation of these triangulations the program points2triangs
     1052           from the program topcom by Joerg Rambau, Universitaet Bayreuth; it
     1053           therefore is necessary that this program is installed in order to use this
     1054           procedure; see
     1055@*         http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM
     1056EXAMPLE: example secondaryFan;   shows an example"
     1057{
     1058  if (size(#)==0)
     1059  {
     1060    list triang=triangulations(polygon);
     1061  }
     1062  else
     1063  {
     1064    list triang=#[1];
     1065  }
     1066  list sp=secondaryPolytope(polygon,triang);
     1067  list spp=polymakePolytope(sp[1]);
     1068  list sf=normalFan(spp[1],spp[4],spp[3],1);
     1069  return(list(sf[1],sf[2],spp,triang));
     1070}
     1071example
     1072{
     1073   "EXAMPLE:";
     1074   echo=2;
     1075   // the lattice points of the unit square in the plane
     1076   list polygon=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1);
     1077   // the secondary polytope of this lattice point configuration is computed
     1078   list secfan=secondaryFan(polygon);
     1079   // the number of cones in the secondary fan of the polygon
     1080   size(secfan[1]);
     1081   // the inequalities of the first cone as matrix are:
     1082   print(secfan[1][1][1]);
     1083   // the inequalities of the first cone as string are:
     1084   print(secfan[1][1][2]);
     1085   // the rows of the following matrix are the extreme rays of the first cone:
     1086   print(secfan[1][1][3]);
     1087   // each cone contains the linearity space spanned by:
     1088   print(secfan[2]);
     1089   // the points in the secondary polytope
     1090   print(secfan[3][1]);
     1091   // the corresponding triangulations
     1092   secfan[4];
     1093}
     1094
    9921095
    9931096////////////////////////////////////////////////////////////////////////////////////////
     
    20292132}
    20302133
     2134
     2135/////////////////////////////////////////////////////////////////////////////////
     2136/// AUXILARY PROCEDURES
     2137/////////////////////////////////////////////////////////////////////////////////
     2138
     2139proc polymakeKeepTmpFiles (int i)
     2140"USAGE:  polymakeKeepTmpFiles(int i);   i int
     2141PURPOSE: some procedures create files in the directory /tmp which are used for
     2142         computations with polymake respectively topcom; these will be removed
     2143         when the corresponding procedure is left; however, it might be desireable
     2144         to keep them for further computations with either polymake or topcom; this
     2145         can be achieved by this procedure; call the procedure as:
     2146@*       - polymakeKeepTmpFiles(1);  - then the files will be kept
     2147@*       - polymakeKeepTmpFiles(0);  - then the files will be removed in the future
     2148RETURN:  none"
     2149{
     2150  if (i==1)
     2151  {
     2152    int polymakekeeptmpfiles;
     2153    export polymakekeeptmpfiles;
     2154  }
     2155  else
     2156  {
     2157    if (defined(polymakekeeptmpfiles))
     2158    {
     2159      kill polymakekeeptmpfiles;
     2160    }
     2161  }
     2162}
     2163
     2164
    20312165/////////////////////////////////////////////////////////////////////////////////
    20322166/////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.