Changeset a2930e in git
- Timestamp:
- Aug 8, 2008, 12:30:35 PM (15 years ago)
- Branches:
- (u'spielwiese', '91e5db82acc17434e4062bcfa44e6efa7d41fd30')
- Children:
- 90203a90e070f1fa64b3e7012c9d1f4ef0992f60
- Parents:
- 5c2528e65b18f6f0a12b589f87196ebcd79b90af
- 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:01keilen Exp $";1 version="$Id: polymake.lib,v 1.8 2008-08-08 10:30:35 keilen Exp $"; 2 2 category="Tropical Geometry"; 3 3 info=" … … 41 41 secondaryPolytope(list) computes the secondary polytope of a marked polytope 42 42 43 PROCEDURES USING POLYMAKE AND TOPCOM: 44 secondaryFan(list) computes the secondary fan of a marked polytope 45 43 46 PROCEDURES CONERNED WITH PLANAR POLYGONS: 44 47 cycleLength(list,intvec) computes the cycleLength of cycle dual to list with interior point intvec … … 52 55 ellipticNFDB(int) displays the 16 normal forms of elliptic polygons 53 56 54 KEYWORDS: polytope; fan; secondary fan; secondary polytope; polymake; 55 Newton polytope; Groebner fan 57 AUXILARY PROCEDURES: 58 polymakeKeepTmpFiles(int) determines whether the files created in /tmp should be kept 59 60 KEYWORDS: polytope; fan; secondary fan; secondary polytope; polymake; 61 Newton polytope; Groebner fan 56 62 57 63 "; … … 79 85 LIB "random.lib"; 80 86 //////////////////////////////////////////////////////////////////////////////////// 87 81 88 82 89 //////////////////////////////////////////////////////////////////////////////////////// … … 108 115 starts indexing its vertices by zero while we start with one ! 109 116 @* - 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 111 119 @* - moreover, the procedure creates the file /tmp/polytope.output which it deletes 112 120 again before ending … … 206 214 intmat neq[1][ncols(polytope)+1]; 207 215 } 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 208 222 return(list(np,nd,nveg,neq)); 209 223 } … … 468 482 } 469 483 } 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 } 470 490 // get the linearity space 471 491 return(list(ineq,linearity)); … … 757 777 //////////////////////////////////////////////////////////////////////////////////////// 758 778 759 proc triangulations (list polygon , list #)760 "USAGE: triangulations(polygon [,#]); list polygon, list #779 proc triangulations (list polygon) 780 "USAGE: triangulations(polygon); list polygon 761 781 ASSUME: polygon is a list of integer vectors of the same size representing the affine 762 782 coordinates of the lattice points … … 776 796 the former is used as input for points2triangs and the latter is its output 777 797 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 781 800 @* - note that an integer i in an integer vector representing a triangle refers to 782 801 the ith lattice point, i.e. polygon[i]; this convention is different from … … 802 821 system("sh","cd /tmp; points2triangs < triangulationsinput > triangulationsoutput"); 803 822 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) 805 825 { 806 826 system("sh","cd /tmp; rm -f triangulationsinput; rm -f triangulationsoutput"); … … 990 1010 secpoly[2]; 991 1011 } 1012 1013 //////////////////////////////////////////////////////////////////////////////////////// 1014 /// PROCEDURES USING POLYMAKE AND TOPCOM 1015 //////////////////////////////////////////////////////////////////////////////////////// 1016 1017 proc secondaryFan (list polygon,list #) 1018 "USAGE: secondaryFan(polygon[,#]); list polygon, list # 1019 ASSUME: - 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 1024 PURPOSE: 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 1029 RETURN: 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 1043 NOTE: - 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 1056 EXAMPLE: 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 } 1071 example 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 992 1095 993 1096 //////////////////////////////////////////////////////////////////////////////////////// … … 2029 2132 } 2030 2133 2134 2135 ///////////////////////////////////////////////////////////////////////////////// 2136 /// AUXILARY PROCEDURES 2137 ///////////////////////////////////////////////////////////////////////////////// 2138 2139 proc polymakeKeepTmpFiles (int i) 2140 "USAGE: polymakeKeepTmpFiles(int i); i int 2141 PURPOSE: 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 2148 RETURN: 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 2031 2165 ///////////////////////////////////////////////////////////////////////////////// 2032 2166 /////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.