1 | ||
Editor: page
Time: 2007/11/12 23:38:45 GMT-8 |
||
Note: transferred from axiom-developer.org |
changed: - http://www.math.tu-berlin.de/polymake Polymake is a (more and more versatile) tool for the algorithmic treatment of convex polyhedra and finite simplicial complexes. As one of its many new features polymake now also deals with tight spans: This is the bounded subcomplex of a certain unbounded polyhedron associated to a finite metric space. The system offers access to a wide variety of algorithms and packages within a common framework. polymake is flexible and continuously expanding. The software supplies C++ and perl interfaces which make it highly adaptable to individual needs. This is a trivial wrapper for the wonderful polymake package. Note that this is rather a proof of concept, so if you think you've got a better design idea, go ahead and comment below. So far, only little of the polymake functionality is covered, but it's mostly very easy to extend. Usage You can find some simple examples in [SandBox polymake]. There, you can also try it out online! Design I've decided to communicate with polymake for a start via file I/O, but would be easy to change this if necessary. Every polymake object created is stored with a "canonical" name: For example, if you ask for a cube of dimension 4, axiom will issue the shell command 'cube cube4.poly 4'. Then, when you ask for a property of this cube, for example, the hvector, then the shell command 'polymake cube4.poly H_VECTOR > tmp.poly' is issued. Finally axiom reads the contents of 'tmp.poly' and converts it to the appropriate type. Thus, the only thing that really has to be programmed is a conversion routine for every polymake type. Some of these are trivial, like the Boolean, vector or matrix types, some others need more thought. Currently there are only two domains: 'Polytope' and 'SimplicialComplex'. If you want a particular polymake property or construction supported, or want to have a new domain like 'Graph', go ahead and change the contents of this file. If you need help, you can always ask me. \begin{axiom} )lib STRCNV READFILE \end{axiom} \begin{spad} )abbrev domain POLYTOPE Polytope Polytope(): Exports == Implementation where Cardinal ==> NonNegativeInteger Scalar ==> Fraction Integer Exports == with coerce: % -> OutputForm ------------------------------------------------------------------------------- -- polytope constructions -- ------------------------------------------------------------------------------- cube: Integer -> % cross: Integer -> % rand01: (Integer, Integer) -> % randSphere: (Integer, Integer) -> % ------------------------------------------------------------------------------- -- polytope properties -- ------------------------------------------------------------------------------- points: % -> Matrix Scalar ++ Points such that the polyhedron is their convex hull. Redundancies are ++ allowed. Vector (x0 x1 .. xd) represents a point in (d+1)-space ++ (homogeneous coordinates.) Affine points are identified by x0 > ++ 0. Points with x0 = 0 can be interpreted as rays. polymake ++ automatically normalizes each coordinate vector, dividing them by the ++ first non-zero element. The clients and rule subroutines can always ++ assume that x0 is either 0 or 1. Dual to INEQUALITIES. Input section ++ only. Ask for VERTICES if you want to compute a V-representation from ++ an H-representation. vertices: % -> Matrix Scalar ++ Vertices of the polyhedron. No redundancies are allowed. The ++ coordinates are normalized the same way as POINTS. Dual to FACETS. inequalities: % -> Matrix Scalar ++ Inequalities that describe half-spaces such that the polyhedron is ++ their intersection. Redundancies are allowed. Dual to POINTS. A ++ vector (A0 A1 .. Ad) defines the (closed affine) half-space of points ++ (1,x1,..,xd) such that A0 + A1 x1 + .. + Ad xd >= 0. Input section ++ only. Ask for FACETS and AFFINE_HULL if you want to compute an ++ H-representation from a V-representation. facets: % -> Matrix Scalar ++ Facets of the polyhedron, encoded as INEQUALITIES. Dual to VERTICES. equations: % -> Matrix Scalar ++ Equations that hold for all points of the polyhedron. A vector (A0 A1 ++ .. Ad) describes the hyperplane of all points (1,x1,..,xd) such that ++ A0 + A1 x1 + .. + Ad xd = 0. Input section only. Ask for AFFINE_HULL ++ if you want to see an irredundant description of the affine span. affineHull: % -> Matrix Scalar ++ Dual basis of the affine hull of the polyhedron. vertexNormals: % -> Matrix Scalar ++ The i-th row is the normal vector of a hyperplane separating the i-th ++ vertex from the rest ones. This property is a by-product of redundant ++ point elimination algorithm. validPoint: % -> Vector Scalar ++ Some point belonging to the polyhedron. dim: % -> Cardinal ++ Dimension of the affine hull of the polyhedron = dimension of the ++ polyhedron. If the polytope is given purely combinatorically, it's the ++ dimension of a minimal embedding space deduced from the combinatorial ++ structure. ambientDim: % -> Cardinal ++ Dimension of the space where the polyhedron lives in. feasible: % -> Boolean ++ True if the polyhedron is not empty. pointed: % -> Boolean ++ True if the polyhedron does not contain an affine line. farFace: % -> Set Cardinal ++ Indices of vertices that are rays. unboundedFacets: % -> Set Cardinal ++ Indices of facets that are unbounded. bounded: % -> Boolean ++ True if the polyhedron is a bounded polytope. -- boundedGraph: % -> Graph -- ++ Graph of the bounded subcomplex. centered: % -> Boolean ++ True if (1,0,0,..) is a relative interior point. Polar to BOUNDED. positive: % -> Boolean ++ True if all vertices of the polyhedron have non-negative coordinates, ++ that is, it lies entirely in the positive orthant. nPoints: % -> Cardinal ++ Number of points. nInequalities: % -> Cardinal ++ Number of inequalities. vertexBarycenter: % -> Vector Scalar ++ The center of gravity of the vertices of a bounded polytope. minimalVertexAngle: % -> Scalar ++ The minimum angle between any two vertices (seen from the ++ VERTEXBARYCENTER). zonotopeInputVectors: % -> Matrix Scalar ++ Contains the vector configuration for which a zonotope can be built. reverseTransformation: % -> Matrix Scalar ++ Some invertible linear transformation that can be used to get back a ++ previous coordinate repersentation of the polytope. It operates from ++ the right on point row vectors (e.g. in properties like POINTS, ++ VERTICES, REL_INT_POINT); its inverse operates from the left on ++ hyperplane column vectors. -- vertexLabels: % -> array<label> -- ++ Unique names assigned to the VERTICES. If specified, they are shown by -- ++ visualization tools instead of vertex indices. For a polytope build -- ++ from scratch, you should create this property by yourself, either -- ++ manually in a text editor, or with a client program. If you build a -- ++ polytope with a construction client taking some other input -- ++ polytope(s), you can create the labels automatically if you call the -- ++ client with a -relabel option. The exact format of the labels is -- ++ dependent on the construction, and is described by the corresponding -- ++ client. -- facetLabels: % -> array<label> -- ++ Unique names assigned to the FACETS, analogous to VERTEX_LABELS. galeTransform: % -> Matrix Scalar ++ Coordinates of the Gale transform. steinerPoints: % -> Matrix Scalar ++ A weighted inner point depending on the outer angle called Steiner ++ point for all faces of dimensions 2 to d. -- Combinatorics nVertices: % -> Cardinal ++ Number of vertices. nBoundedVertices: % -> Cardinal ++ Number of bounded vertices (non-rays). nFacets: % -> Cardinal ++ Number of facets. nVertexFacetInc: % -> Cardinal ++ Number of pairs of incident vertices and facets. -- verticesInFacets: % -> incidence_matrix -- ++ Vertex-facet incidence matrix, with rows corresponding to facets and -- ++ columns to vertices. Vertices and facets are numbered from 0 to -- ++ N_VERTICES-1 rsp. N_FACETS-1, according to their order in VERTICES -- ++ rsp. FACETS. -- facetsThruVertices: % -> incidence_matrix -- ++ transposed VERTICES_IN_FACETS -- hasseDiagram: % -> face_lattice -- ++ The face lattice of the polytope organized as a directed graph. Each -- ++ node corresponds to some proper face of the polytope. The nodes -- ++ corresponding to the vertices and facets appear in the same order as -- ++ the elements of VERTICES and FACETS properties. Two special nodes -- ++ represent the whole polytope and the empty face. -- vertexSizes: % -> array<Cardinal> -- ++ Number of incident facets for each vertex. -- facetSizes: % -> array<Cardinal> -- ++ Number of incident vertices for each facet. -- -- graph: % -> graph -- ++ Vertex-edge graph. -- -- dualGraph: % -> graph -- ++ Facet-ridge graph. Dual to GRAPH. nEdges: % -> Cardinal ++ Number of edges. nRidges: % -> Cardinal ++ Number of ridges. -- vertexDegrees: % -> array<Cardinal> -- ++ Degrees of vertices in the GRAPH. -- facetDegrees: % -> array<Cardinal> -- ++ Degrees of facets in the DUAL_GRAPH. diameter: % -> Cardinal ++ Graph theoretical diameter of GRAPH. dualDiameter: % -> Cardinal ++ Graph theoretical diameter of DUAL_GRAPH. triangleFree: % -> Boolean ++ True if GRAPH does not contain a triangle. dualTriangleFree: % -> Boolean ++ True if DUAL_GRAPH does not contain a triangle. altshulerDet: % -> Cardinal ++ Let M be the vertex-facet incidence matrix, then the Altshulter ++ determinant is defined as max{det(M?MT), det(MT?M)}. fVector: % -> Vector Cardinal ++ fk is the number of k-faces. f2Vector: % -> Matrix Cardinal ++ fik is the number of incident pairs of i-faces and k-faces; the main ++ diagonal contains the F_VECTOR. flagVector: % -> Vector Cardinal ++ Condensed form of the flag vector. Use Dehn-Sommerville equations, via ++ user function N_FLAGS, to extend. cdIndexCoefficients: % -> Vector Cardinal ++ Coefficients of the cd-index. hVector: % -> Vector Cardinal ++ Simplicial h-vector. Defined for simplicial polytopes and also for ++ their duals. cubicalHVector: % -> Vector Cardinal ++ undocumented essentiallyGeneric: % -> Boolean ++ all intermediate polytopes (with respect to the given insertion order) ++ in the beneath-and-beyond algorithm are simplicial. We have the ++ ++ implication : VERTICES in general position => ESSENTIALLY_GENERIC => ++ SIMPLICIAL simplicial: % -> Boolean ++ True if the polytope is simplicial. simple: % -> Boolean ++ True if the polytope is simple. Dual to SIMPLICIAL. even: % -> Boolean ++ True if the GRAPH of the polytope is bipartite. dualEven: % -> Boolean ++ True if the DUAL_GRAPH of the polytope is bipartite. Dual to EVEN. connectivity: % -> Cardinal ++ Node connectivity of the GRAPH of the polytope, that is, the minimal ++ number of nodes to be removed from the graph such that the result is ++ disconnected. dualConnectivity: % -> Cardinal ++ Node connectivity of the DUAL_GRAPH of the polytope. Dual to ++ CONNECTIVITY. simpliciality: % -> Cardinal ++ Maximal dimension in which all faces are simplices. simplicity: % -> Cardinal ++ Maximal dimension in which all dual faces are simplices. faceSimplicity: % -> Cardinal ++ Maximal dimension in which all faces are simple polytopes. cubical: % -> Boolean ++ True if all facets are cubes. cubicality: % -> Cardinal ++ Maximal dimension in which all facets are cubes. cocubical: % -> Boolean ++ Dual to CUBICAL. cocubicality: % -> Cardinal ++ Dual to CUBICALITY. neighborly: % -> Boolean ++ True if the polytope is neighborly. neighborliness: % -> Cardinal ++ Maximal dimension in which all facets are neighborly. balanced: % -> Boolean ++ Dual to NEIGHBORLY. balance: % -> Cardinal ++ Maximal dimension in which all facets are balanced. fatness: % -> Scalar ++ Parameter describing the shape of the face-lattice of a 4-polytope. complexity: % -> Scalar Implementation == add polydir: String := "/tmp/" polytmp: String := polydir "tmp.poly" polylib: String := "/usr/local/polymake/bin" polytmpfile:FileName := polytmp::FileName Rep := String coerce p == coerce(p)$Rep polycons: (String, String, String) -> % polycons(rep, cmd, prm) == systemCommand("system " cmd " " polydir rep ".poly " prm)_ $MoreSystemCommands rep::Rep polyprop: (%, String) -> Void polyprop(rep, cmd) == systemCommand("system polymake " polydir (rep::Rep) ".poly "_ cmd " > " polytmp)$MoreSystemCommands ------------------------------------------------------------------------------- -- polytope constructions -- ------------------------------------------------------------------------------- cube n == polycons("cube" string(n), "cube", string(n)) cross n == polycons("cross" string(n), "cross", string(n)) rand01(d, n) == polycons("rand01" string(d) string(n), "rand01", _ string(d) " " string(n)) randSphere(d, n) == polycons("randsphere" string(d) string(n), "rand__sphere", _ string(d) " " string(n)) ------------------------------------------------------------------------------- -- polytope properties -- ------------------------------------------------------------------------------- points s == polyprop(s, "POINTS") getMatrixFraction(polytmpfile)$ReadFile vertices s == polyprop(s, "VERTICES") getMatrixFraction(polytmpfile)$ReadFile inequalities s == polyprop(s, "INEQUALITIES") getMatrixFraction(polytmpfile)$ReadFile facets s == polyprop(s, "FACETS") getMatrixFraction(polytmpfile)$ReadFile equations s == polyprop(s, "EQUATIONS") getMatrixFraction(polytmpfile)$ReadFile affineHull s == polyprop(s, "AFFINE__HULL") getMatrixFraction(polytmpfile)$ReadFile vertexNormals s == polyprop(s, "VERTEX__NORMALS") getMatrixFraction(polytmpfile)$ReadFile validPoint s == polyprop(s, "VALID__POINT") getVectorFraction(polytmpfile)$ReadFile dim s == polyprop(s, "DIM") getInteger(polytmpfile)$ReadFile :: Cardinal ambientDim s == polyprop(s, "AMBIENT__DIM") getInteger(polytmpfile)$ReadFile :: Cardinal feasible s == polyprop(s, "FEASIBLE") getBoolean(polytmpfile)$ReadFile pointed s == polyprop(s, "POINTED") getBoolean(polytmpfile)$ReadFile farFace s == polyprop(s, "FAR__FACE") getSetInteger(polytmpfile)$ReadFile pretend Set Cardinal unboundedFacets s == polyprop(s, "UNBOUNDED__FACETS") getSetInteger(polytmpfile)$ReadFile pretend Set Cardinal bounded s == polyprop(s, "BOUNDED") getBoolean(polytmpfile)$ReadFile centered s == polyprop(s, "CENTERED") getBoolean(polytmpfile)$ReadFile positive s == polyprop(s, "POSITIVE") getBoolean(polytmpfile)$ReadFile nPoints s == polyprop(s, "N__POINTS") getInteger(polytmpfile)$ReadFile :: Cardinal nInequalities s == polyprop(s, "N__INEQUALITIES") getInteger(polytmpfile)$ReadFile :: Cardinal vertexBarycenter s == polyprop(s, "VERTEX__BARYCENTER") getVectorFraction(polytmpfile)$ReadFile minimalVertexAngle s == polyprop(s, "MINIMAL__VERTEX__ANGLE") getFraction(polytmpfile)$ReadFile zonotopeInputVectors s == polyprop(s, "ZONOTOPE__INPUT__VECTORS") getMatrixFraction(polytmpfile)$ReadFile reverseTransformation s == polyprop(s, "REVERSE__TRANSFORMATION") getMatrixFraction(polytmpfile)$ReadFile -- vertexLabels: % -> array<label> -- facetLabels: % -> array<label> galeTransform s == polyprop(s, "GALE__TRANSFORM") getMatrixFraction(polytmpfile)$ReadFile steinerPoints s == polyprop(s, "STEINER__POINTS") getMatrixFraction(polytmpfile)$ReadFile -- Combinatorics nVertices s == polyprop(s, "N__VERTICES") getInteger(polytmpfile)$ReadFile :: Cardinal nBoundedVertices s == polyprop(s, "N__BOUNDED__VERTICES") getInteger(polytmpfile)$ReadFile :: Cardinal nFacets s == polyprop(s, "N__FACETS") getInteger(polytmpfile)$ReadFile :: Cardinal nVertexFacetInc s == polyprop(s, "N__VERTEX__FACET__INC") getInteger(polytmpfile)$ReadFile :: Cardinal -- verticesInFacets: % -> incidence_matrix -- ++ Vertex-facet incidence matrix, with rows corresponding to facets and -- ++ columns to vertices. Vertices and facets are numbered from 0 to -- ++ N_VERTICES-1 rsp. N_FACETS-1, according to their order in VERTICES -- ++ rsp. FACETS. -- facetsThruVertices: % -> incidence_matrix -- ++ transposed VERTICES_IN_FACETS -- hasseDiagram: % -> face_lattice -- ++ The face lattice of the polytope organized as a directed graph. Each -- ++ node corresponds to some proper face of the polytope. The nodes -- ++ corresponding to the vertices and facets appear in the same order as -- ++ the elements of VERTICES and FACETS properties. Two special nodes -- ++ represent the whole polytope and the empty face. -- vertexSizes: % -> array<Cardinal> -- ++ Number of incident facets for each vertex. -- facetSizes: % -> array<Cardinal> -- ++ Number of incident vertices for each facet. -- -- graph: % -> graph -- ++ Vertex-edge graph. -- -- dualGraph: % -> graph -- ++ Facet-ridge graph. Dual to GRAPH. nEdges s == polyprop(s, "N__EDGES") getInteger(polytmpfile)$ReadFile :: Cardinal nRidges s == polyprop(s, "N__RIDGES") getInteger(polytmpfile)$ReadFile :: Cardinal -- vertexDegrees: % -> array<Cardinal> -- ++ Degrees of vertices in the GRAPH. -- facetDegrees: % -> array<Cardinal> -- ++ Degrees of facets in the DUAL_GRAPH. diameter s == polyprop(s, "DIAMETER") getInteger(polytmpfile)$ReadFile :: Cardinal dualDiameter s == polyprop(s, "DUAL__DIAMETER") getInteger(polytmpfile)$ReadFile :: Cardinal triangleFree s == polyprop(s, "TRIANGLE__FREE") getBoolean(polytmpfile)$ReadFile dualTriangleFree s == polyprop(s, "DUAL__TRIANGLE__FREE") getBoolean(polytmpfile)$ReadFile altshulerDet s == polyprop(s, "ALTSHULER__DET") getInteger(polytmpfile)$ReadFile :: Cardinal fVector s == polyprop(s, "F__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal f2Vector s == polyprop(s, "F2__VECTOR") getMatrixInteger(polytmpfile)$ReadFile pretend Matrix Cardinal flagVector s == polyprop(s, "FLAG__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal cdIndexCoefficients s == polyprop(s, "CD__INDEX__COEFFICIENTS") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal hVector s == polyprop(s, "H__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal cubicalHVector s == polyprop(s, "CUBICAL__H__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal essentiallyGeneric s == polyprop(s, "ESSENTIALLY__GENERIC") getBoolean(polytmpfile)$ReadFile simplicial s == polyprop(s, "SIMPLICIAL") getBoolean(polytmpfile)$ReadFile simple s == polyprop(s, "SIMPLE") getBoolean(polytmpfile)$ReadFile even s == polyprop(s, "EVEN") getBoolean(polytmpfile)$ReadFile dualEven s == polyprop(s, "DUAL__EVEN") getBoolean(polytmpfile)$ReadFile connectivity s == polyprop(s, "CONNECTIVITY") getInteger(polytmpfile)$ReadFile :: Cardinal dualConnectivity s == polyprop(s, "DUAL__CONNECTIVITY") getInteger(polytmpfile)$ReadFile :: Cardinal simpliciality s == polyprop(s, "SIMPLICIALITY") getInteger(polytmpfile)$ReadFile :: Cardinal simplicity s == polyprop(s, "SIMPLICITY") getInteger(polytmpfile)$ReadFile :: Cardinal faceSimplicity s == polyprop(s, "FACE__SIMPLICITY") getInteger(polytmpfile)$ReadFile :: Cardinal cubical s == polyprop(s, "CUBICAL") getBoolean(polytmpfile)$ReadFile cubicality s == polyprop(s, "CUBICALITY") getInteger(polytmpfile)$ReadFile :: Cardinal cocubical s == polyprop(s, "COCUBICAL") getBoolean(polytmpfile)$ReadFile cocubicality s == polyprop(s, "COCUBICALITY") getInteger(polytmpfile)$ReadFile :: Cardinal neighborly s == polyprop(s, "NEIGHBORLY") getBoolean(polytmpfile)$ReadFile neighborliness s == polyprop(s, "NEIGHBORLINESS") getInteger(polytmpfile)$ReadFile :: Cardinal balanced s == polyprop(s, "BALANCED") getBoolean(polytmpfile)$ReadFile balance s == polyprop(s, "BALANCE") getInteger(polytmpfile)$ReadFile :: Cardinal fatness s == polyprop(s, "FATNESS") getFraction(polytmpfile)$ReadFile complexity s == polyprop(s, "FATNESS") getFraction(polytmpfile)$ReadFile )abbrev domain TOPAZ SimplicialComplex SimplicialComplex(): Exports == Implementation where Exports == with coerce: % -> OutputForm ------------------------------------------------------------------------------- -- topaz constructions -- ------------------------------------------------------------------------------- boundaryComplex: Polytope -> % ------------------------------------------------------------------------------- -- topaz properties -- ------------------------------------------------------------------------------- facets: % -> List Set Integer Implementation == add polydir: String := "/tmp/" polytmp: String := polydir "tmp.poly" polylib: String := "/usr/local/polymake/bin" polytmpfile:FileName := polytmp::FileName Rep := String coerce p == coerce(p)$Rep topazcons: (String, String, String) -> % topazcons(rep, cmd, prm) == systemCommand("system " cmd " " polydir rep ".top " prm)_ $MoreSystemCommands rep::Rep topazprop: (%, String) -> Void topazprop(rep, cmd) == systemCommand("system polymake -A topaz " polydir (rep::Rep) ".top "_ cmd " > " polytmp)$MoreSystemCommands facets s == topazprop(s, "FACETS") getListSetInteger(polytmpfile)$ReadFile boundaryComplex s == topazcons(s pretend String, "boundary__complex", _ (s pretend String) ".poly") s pretend String :: Rep \end{spad} Let's try it out: \begin{axiom} c := cube 4 systemCommand("system cat /tmp/cube4.poly")$MoreSystemCommands \end{axiom}
http://www.math.tu-berlin.de/polymake
Polymake is a (more and more versatile) tool for the algorithmic treatment of convex polyhedra and finite simplicial complexes.
As one of its many new features polymake now also deals with tight spans: This is the bounded subcomplex of a certain unbounded polyhedron associated to a finite metric space.
The system offers access to a wide variety of algorithms and packages within a common framework. polymake is flexible and continuously expanding. The software supplies C++ and perl interfaces which make it highly adaptable to individual needs.
This is a trivial wrapper for the wonderful polymake package. Note that this is rather a proof of concept, so if you think you've got a better design idea, go ahead and comment below. So far, only little of the polymake functionality is covered, but it's mostly very easy to extend.
You can find some simple examples in SandBox polymake. There, you can also try it out online!
I've decided to communicate with polymake for a start via file I/O, but would be easy to change this if necessary. Every polymake object created is stored with a "canonical" name: For example, if you ask for a cube of dimension 4, axiom will issue the shell command cube cube4.poly 4
. Then, when you ask for a property of this cube, for example, the hvector, then the shell command polymake cube4.poly H_VECTOR > tmp.poly
is issued. Finally axiom reads the contents of tmp.poly
and converts it to the appropriate type. Thus, the only thing that really has to be programmed is a conversion routine for every polymake type. Some of these are trivial, like the Boolean, vector or matrix types, some others need more thought.
Currently there are only two domains: Polytope
and SimplicialComplex
. If you want a particular polymake property or construction supported, or want to have a new domain like Graph
, go ahead and change the contents of this file. If you need help, you can always ask me.
(1) -> )lib STRCNV READFILE
>> System error: The value 1954 is not of type LIST
)abbrev domain POLYTOPE Polytope Polytope(): Exports == Implementation where Cardinal ==> NonNegativeInteger Scalar ==> Fraction Integer
Exports == with
coerce: % -> OutputForm
------------------------------------------------------------------------------- -- polytope constructions -- -------------------------------------------------------------------------------
cube: Integer -> %
cross: Integer -> %
rand01: (Integer,Integer) -> %
randSphere: (Integer,Integer) -> %
------------------------------------------------------------------------------- -- polytope properties -- -------------------------------------------------------------------------------
points: % -> Matrix Scalar ++ Points such that the polyhedron is their convex hull. Redundancies are ++ allowed. Vector (x0 x1 .. xd) represents a point in (d+1)-space ++ (homogeneous coordinates.) Affine points are identified by x0 > ++ 0. Points with x0 = 0 can be interpreted as rays. polymake ++ automatically normalizes each coordinate vector,dividing them by the ++ first non-zero element. The clients and rule subroutines can always ++ assume that x0 is either 0 or 1. Dual to INEQUALITIES. Input section ++ only. Ask for VERTICES if you want to compute a V-representation from ++ an H-representation.
vertices: % -> Matrix Scalar ++ Vertices of the polyhedron. No redundancies are allowed. The ++ coordinates are normalized the same way as POINTS. Dual to FACETS.
inequalities: % -> Matrix Scalar ++ Inequalities that describe half-spaces such that the polyhedron is ++ their intersection. Redundancies are allowed. Dual to POINTS. A ++ vector (A0 A1 .. Ad) defines the (closed affine) half-space of points ++ (1,x1, .., xd) such that A0 + A1 x1 + .. + Ad xd >= 0. Input section ++ only. Ask for FACETS and AFFINE_HULL if you want to compute an ++ H-representation from a V-representation.
facets: % -> Matrix Scalar ++ Facets of the polyhedron,encoded as INEQUALITIES. Dual to VERTICES.
equations: % -> Matrix Scalar ++ Equations that hold for all points of the polyhedron. A vector (A0 A1 ++ .. Ad) describes the hyperplane of all points (1,x1, .., xd) such that ++ A0 + A1 x1 + .. + Ad xd = 0. Input section only. Ask for AFFINE_HULL ++ if you want to see an irredundant description of the affine span.
affineHull: % -> Matrix Scalar ++ Dual basis of the affine hull of the polyhedron.
vertexNormals: % -> Matrix Scalar ++ The i-th row is the normal vector of a hyperplane separating the i-th ++ vertex from the rest ones. This property is a by-product of redundant ++ point elimination algorithm.
validPoint: % -> Vector Scalar ++ Some point belonging to the polyhedron.
dim: % -> Cardinal ++ Dimension of the affine hull of the polyhedron = dimension of the ++ polyhedron. If the polytope is given purely combinatorically,it's the ++ dimension of a minimal embedding space deduced from the combinatorial ++ structure.
ambientDim: % -> Cardinal ++ Dimension of the space where the polyhedron lives in.
feasible: % -> Boolean ++ True if the polyhedron is not empty.
pointed: % -> Boolean ++ True if the polyhedron does not contain an affine line.
farFace: % -> Set Cardinal ++ Indices of vertices that are rays.
unboundedFacets: % -> Set Cardinal ++ Indices of facets that are unbounded.
bounded: % -> Boolean ++ True if the polyhedron is a bounded polytope.
-- boundedGraph: % -> Graph -- ++ Graph of the bounded subcomplex.
centered: % -> Boolean ++ True if (1,0, 0, ..) is a relative interior point. Polar to BOUNDED.
positive: % -> Boolean ++ True if all vertices of the polyhedron have non-negative coordinates,++ that is, it lies entirely in the positive orthant.
nPoints: % -> Cardinal ++ Number of points.
nInequalities: % -> Cardinal ++ Number of inequalities.
vertexBarycenter: % -> Vector Scalar ++ The center of gravity of the vertices of a bounded polytope.
minimalVertexAngle: % -> Scalar ++ The minimum angle between any two vertices (seen from the ++ VERTEXBARYCENTER).
zonotopeInputVectors: % -> Matrix Scalar ++ Contains the vector configuration for which a zonotope can be built.
reverseTransformation: % -> Matrix Scalar ++ Some invertible linear transformation that can be used to get back a ++ previous coordinate repersentation of the polytope. It operates from ++ the right on point row vectors (e.g. in properties like POINTS,++ VERTICES, REL_INT_POINT); its inverse operates from the left on ++ hyperplane column vectors.
-- vertexLabels: % -> array<label> -- ++ Unique names assigned to the VERTICES. If specified,they are shown by -- ++ visualization tools instead of vertex indices. For a polytope build -- ++ from scratch, you should create this property by yourself, either -- ++ manually in a text editor, or with a client program. If you build a -- ++ polytope with a construction client taking some other input -- ++ polytope(s), you can create the labels automatically if you call the -- ++ client with a -relabel option. The exact format of the labels is -- ++ dependent on the construction, and is described by the corresponding -- ++ client.
-- facetLabels: % -> array<label> -- ++ Unique names assigned to the FACETS,analogous to VERTEX_LABELS.
galeTransform: % -> Matrix Scalar ++ Coordinates of the Gale transform.
steinerPoints: % -> Matrix Scalar ++ A weighted inner point depending on the outer angle called Steiner ++ point for all faces of dimensions 2 to d.
-- Combinatorics
nVertices: % -> Cardinal ++ Number of vertices.
nBoundedVertices: % -> Cardinal ++ Number of bounded vertices (non-rays).
nFacets: % -> Cardinal ++ Number of facets.
nVertexFacetInc: % -> Cardinal ++ Number of pairs of incident vertices and facets.
-- verticesInFacets: % -> incidence_matrix -- ++ Vertex-facet incidence matrix,with rows corresponding to facets and -- ++ columns to vertices. Vertices and facets are numbered from 0 to -- ++ N_VERTICES-1 rsp. N_FACETS-1, according to their order in VERTICES -- ++ rsp. FACETS.
-- facetsThruVertices: % -> incidence_matrix -- ++ transposed VERTICES_IN_FACETS
-- hasseDiagram: % -> face_lattice -- ++ The face lattice of the polytope organized as a directed graph. Each -- ++ node corresponds to some proper face of the polytope. The nodes -- ++ corresponding to the vertices and facets appear in the same order as -- ++ the elements of VERTICES and FACETS properties. Two special nodes -- ++ represent the whole polytope and the empty face.
-- vertexSizes: % -> array<Cardinal> -- ++ Number of incident facets for each vertex.
-- facetSizes: % -> array<Cardinal> -- ++ Number of incident vertices for each facet. -- -- graph: % -> graph -- ++ Vertex-edge graph. -- -- dualGraph: % -> graph -- ++ Facet-ridge graph. Dual to GRAPH.
nEdges: % -> Cardinal ++ Number of edges.
nRidges: % -> Cardinal ++ Number of ridges.
-- vertexDegrees: % -> array<Cardinal> -- ++ Degrees of vertices in the GRAPH.
-- facetDegrees: % -> array<Cardinal> -- ++ Degrees of facets in the DUAL_GRAPH.
diameter: % -> Cardinal ++ Graph theoretical diameter of GRAPH.
dualDiameter: % -> Cardinal ++ Graph theoretical diameter of DUAL_GRAPH.
triangleFree: % -> Boolean ++ True if GRAPH does not contain a triangle.
dualTriangleFree: % -> Boolean ++ True if DUAL_GRAPH does not contain a triangle.
altshulerDet: % -> Cardinal ++ Let M be the vertex-facet incidence matrix,then the Altshulter ++ determinant is defined as max{det(M?MT), det(MT?M)}.
fVector: % -> Vector Cardinal ++ fk is the number of k-faces.
f2Vector: % -> Matrix Cardinal ++ fik is the number of incident pairs of i-faces and k-faces; the main ++ diagonal contains the F_VECTOR.
flagVector: % -> Vector Cardinal ++ Condensed form of the flag vector. Use Dehn-Sommerville equations,via ++ user function N_FLAGS, to extend.
cdIndexCoefficients: % -> Vector Cardinal ++ Coefficients of the cd-index.
hVector: % -> Vector Cardinal ++ Simplicial h-vector. Defined for simplicial polytopes and also for ++ their duals.
cubicalHVector: % -> Vector Cardinal ++ undocumented
essentiallyGeneric: % -> Boolean ++ all intermediate polytopes (with respect to the given insertion order) ++ in the beneath-and-beyond algorithm are simplicial. We have the ++ ++ implication : VERTICES in general position => ESSENTIALLY_GENERIC => ++ SIMPLICIAL
simplicial: % -> Boolean ++ True if the polytope is simplicial.
simple: % -> Boolean ++ True if the polytope is simple. Dual to SIMPLICIAL.
even: % -> Boolean ++ True if the GRAPH of the polytope is bipartite.
dualEven: % -> Boolean ++ True if the DUAL_GRAPH of the polytope is bipartite. Dual to EVEN.
connectivity: % -> Cardinal ++ Node connectivity of the GRAPH of the polytope,that is, the minimal ++ number of nodes to be removed from the graph such that the result is ++ disconnected.
dualConnectivity: % -> Cardinal ++ Node connectivity of the DUAL_GRAPH of the polytope. Dual to ++ CONNECTIVITY.
simpliciality: % -> Cardinal ++ Maximal dimension in which all faces are simplices.
simplicity: % -> Cardinal ++ Maximal dimension in which all dual faces are simplices.
faceSimplicity: % -> Cardinal ++ Maximal dimension in which all faces are simple polytopes.
cubical: % -> Boolean ++ True if all facets are cubes.
cubicality: % -> Cardinal ++ Maximal dimension in which all facets are cubes.
cocubical: % -> Boolean ++ Dual to CUBICAL.
cocubicality: % -> Cardinal ++ Dual to CUBICALITY.
neighborly: % -> Boolean ++ True if the polytope is neighborly.
neighborliness: % -> Cardinal ++ Maximal dimension in which all facets are neighborly.
balanced: % -> Boolean ++ Dual to NEIGHBORLY.
balance: % -> Cardinal ++ Maximal dimension in which all facets are balanced.
fatness: % -> Scalar ++ Parameter describing the shape of the face-lattice of a 4-polytope.
complexity: % -> Scalar
Implementation == add
polydir: String := "/tmp/"
polytmp: String := polydir "tmp.poly"
polylib: String := "/usr/local/polymake/bin"
polytmpfile:FileName := polytmp::FileName
Rep := String
coerce p == coerce(p)$Rep
polycons: (String,String, String) -> % polycons(rep, cmd, prm) == systemCommand("system " cmd " " polydir rep ".poly " prm)_ $MoreSystemCommands rep::Rep
polyprop: (%,String) -> Void polyprop(rep, cmd) == systemCommand("system polymake " polydir (rep::Rep) ".poly "_ cmd " > " polytmp)$MoreSystemCommands
------------------------------------------------------------------------------- -- polytope constructions -- -------------------------------------------------------------------------------
cube n == polycons("cube" string(n),"cube", string(n))
cross n == polycons("cross" string(n),"cross", string(n))
rand01(d,n) == polycons("rand01" string(d) string(n), "rand01", _ string(d) " " string(n))
randSphere(d,n) == polycons("randsphere" string(d) string(n), "rand__sphere", _ string(d) " " string(n))
------------------------------------------------------------------------------- -- polytope properties -- -------------------------------------------------------------------------------
points s == polyprop(s,"POINTS") getMatrixFraction(polytmpfile)$ReadFile
vertices s == polyprop(s,"VERTICES") getMatrixFraction(polytmpfile)$ReadFile
inequalities s == polyprop(s,"INEQUALITIES") getMatrixFraction(polytmpfile)$ReadFile
facets s == polyprop(s,"FACETS") getMatrixFraction(polytmpfile)$ReadFile
equations s == polyprop(s,"EQUATIONS") getMatrixFraction(polytmpfile)$ReadFile
affineHull s == polyprop(s,"AFFINE__HULL") getMatrixFraction(polytmpfile)$ReadFile
vertexNormals s == polyprop(s,"VERTEX__NORMALS") getMatrixFraction(polytmpfile)$ReadFile
validPoint s == polyprop(s,"VALID__POINT") getVectorFraction(polytmpfile)$ReadFile
dim s == polyprop(s,"DIM") getInteger(polytmpfile)$ReadFile :: Cardinal
ambientDim s == polyprop(s,"AMBIENT__DIM") getInteger(polytmpfile)$ReadFile :: Cardinal
feasible s == polyprop(s,"FEASIBLE") getBoolean(polytmpfile)$ReadFile
pointed s == polyprop(s,"POINTED") getBoolean(polytmpfile)$ReadFile
farFace s == polyprop(s,"FAR__FACE") getSetInteger(polytmpfile)$ReadFile pretend Set Cardinal
unboundedFacets s == polyprop(s,"UNBOUNDED__FACETS") getSetInteger(polytmpfile)$ReadFile pretend Set Cardinal
bounded s == polyprop(s,"BOUNDED") getBoolean(polytmpfile)$ReadFile
centered s == polyprop(s,"CENTERED") getBoolean(polytmpfile)$ReadFile
positive s == polyprop(s,"POSITIVE") getBoolean(polytmpfile)$ReadFile
nPoints s == polyprop(s,"N__POINTS") getInteger(polytmpfile)$ReadFile :: Cardinal
nInequalities s == polyprop(s,"N__INEQUALITIES") getInteger(polytmpfile)$ReadFile :: Cardinal
vertexBarycenter s == polyprop(s,"VERTEX__BARYCENTER") getVectorFraction(polytmpfile)$ReadFile
minimalVertexAngle s == polyprop(s,"MINIMAL__VERTEX__ANGLE") getFraction(polytmpfile)$ReadFile
zonotopeInputVectors s == polyprop(s,"ZONOTOPE__INPUT__VECTORS") getMatrixFraction(polytmpfile)$ReadFile
reverseTransformation s == polyprop(s,"REVERSE__TRANSFORMATION") getMatrixFraction(polytmpfile)$ReadFile
-- vertexLabels: % -> array<label>
-- facetLabels: % -> array<label>
galeTransform s == polyprop(s,"GALE__TRANSFORM") getMatrixFraction(polytmpfile)$ReadFile
steinerPoints s == polyprop(s,"STEINER__POINTS") getMatrixFraction(polytmpfile)$ReadFile
-- Combinatorics
nVertices s == polyprop(s,"N__VERTICES") getInteger(polytmpfile)$ReadFile :: Cardinal
nBoundedVertices s == polyprop(s,"N__BOUNDED__VERTICES") getInteger(polytmpfile)$ReadFile :: Cardinal
nFacets s == polyprop(s,"N__FACETS") getInteger(polytmpfile)$ReadFile :: Cardinal
nVertexFacetInc s == polyprop(s,"N__VERTEX__FACET__INC") getInteger(polytmpfile)$ReadFile :: Cardinal
-- verticesInFacets: % -> incidence_matrix -- ++ Vertex-facet incidence matrix,with rows corresponding to facets and -- ++ columns to vertices. Vertices and facets are numbered from 0 to -- ++ N_VERTICES-1 rsp. N_FACETS-1, according to their order in VERTICES -- ++ rsp. FACETS.
-- facetsThruVertices: % -> incidence_matrix -- ++ transposed VERTICES_IN_FACETS
-- hasseDiagram: % -> face_lattice -- ++ The face lattice of the polytope organized as a directed graph. Each -- ++ node corresponds to some proper face of the polytope. The nodes -- ++ corresponding to the vertices and facets appear in the same order as -- ++ the elements of VERTICES and FACETS properties. Two special nodes -- ++ represent the whole polytope and the empty face.
-- vertexSizes: % -> array<Cardinal> -- ++ Number of incident facets for each vertex.
-- facetSizes: % -> array<Cardinal> -- ++ Number of incident vertices for each facet. -- -- graph: % -> graph -- ++ Vertex-edge graph. -- -- dualGraph: % -> graph -- ++ Facet-ridge graph. Dual to GRAPH.
nEdges s == polyprop(s,"N__EDGES") getInteger(polytmpfile)$ReadFile :: Cardinal
nRidges s == polyprop(s,"N__RIDGES") getInteger(polytmpfile)$ReadFile :: Cardinal
-- vertexDegrees: % -> array<Cardinal> -- ++ Degrees of vertices in the GRAPH.
-- facetDegrees: % -> array<Cardinal> -- ++ Degrees of facets in the DUAL_GRAPH.
diameter s == polyprop(s,"DIAMETER") getInteger(polytmpfile)$ReadFile :: Cardinal
dualDiameter s == polyprop(s,"DUAL__DIAMETER") getInteger(polytmpfile)$ReadFile :: Cardinal
triangleFree s == polyprop(s,"TRIANGLE__FREE") getBoolean(polytmpfile)$ReadFile
dualTriangleFree s == polyprop(s,"DUAL__TRIANGLE__FREE") getBoolean(polytmpfile)$ReadFile
altshulerDet s == polyprop(s,"ALTSHULER__DET") getInteger(polytmpfile)$ReadFile :: Cardinal
fVector s == polyprop(s,"F__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal
f2Vector s == polyprop(s,"F2__VECTOR") getMatrixInteger(polytmpfile)$ReadFile pretend Matrix Cardinal
flagVector s == polyprop(s,"FLAG__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal
cdIndexCoefficients s == polyprop(s,"CD__INDEX__COEFFICIENTS") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal
hVector s == polyprop(s,"H__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal
cubicalHVector s == polyprop(s,"CUBICAL__H__VECTOR") getVectorInteger(polytmpfile)$ReadFile pretend Vector Cardinal
essentiallyGeneric s == polyprop(s,"ESSENTIALLY__GENERIC") getBoolean(polytmpfile)$ReadFile
simplicial s == polyprop(s,"SIMPLICIAL") getBoolean(polytmpfile)$ReadFile
simple s == polyprop(s,"SIMPLE") getBoolean(polytmpfile)$ReadFile
even s == polyprop(s,"EVEN") getBoolean(polytmpfile)$ReadFile
dualEven s == polyprop(s,"DUAL__EVEN") getBoolean(polytmpfile)$ReadFile
connectivity s == polyprop(s,"CONNECTIVITY") getInteger(polytmpfile)$ReadFile :: Cardinal
dualConnectivity s == polyprop(s,"DUAL__CONNECTIVITY") getInteger(polytmpfile)$ReadFile :: Cardinal
simpliciality s == polyprop(s,"SIMPLICIALITY") getInteger(polytmpfile)$ReadFile :: Cardinal
simplicity s == polyprop(s,"SIMPLICITY") getInteger(polytmpfile)$ReadFile :: Cardinal
faceSimplicity s == polyprop(s,"FACE__SIMPLICITY") getInteger(polytmpfile)$ReadFile :: Cardinal
cubical s == polyprop(s,"CUBICAL") getBoolean(polytmpfile)$ReadFile
cubicality s == polyprop(s,"CUBICALITY") getInteger(polytmpfile)$ReadFile :: Cardinal
cocubical s == polyprop(s,"COCUBICAL") getBoolean(polytmpfile)$ReadFile
cocubicality s == polyprop(s,"COCUBICALITY") getInteger(polytmpfile)$ReadFile :: Cardinal
neighborly s == polyprop(s,"NEIGHBORLY") getBoolean(polytmpfile)$ReadFile
neighborliness s == polyprop(s,"NEIGHBORLINESS") getInteger(polytmpfile)$ReadFile :: Cardinal
balanced s == polyprop(s,"BALANCED") getBoolean(polytmpfile)$ReadFile
balance s == polyprop(s,"BALANCE") getInteger(polytmpfile)$ReadFile :: Cardinal
fatness s == polyprop(s,"FATNESS") getFraction(polytmpfile)$ReadFile
complexity s == polyprop(s,"FATNESS") getFraction(polytmpfile)$ReadFile
)abbrev domain TOPAZ SimplicialComplex SimplicialComplex(): Exports == Implementation where Exports == with
coerce: % -> OutputForm
------------------------------------------------------------------------------- -- topaz constructions -- -------------------------------------------------------------------------------
boundaryComplex: Polytope -> %
------------------------------------------------------------------------------- -- topaz properties -- -------------------------------------------------------------------------------
facets: % -> List Set Integer
Implementation == add
polydir: String := "/tmp/"
polytmp: String := polydir "tmp.poly"
polylib: String := "/usr/local/polymake/bin"
polytmpfile:FileName := polytmp::FileName
Rep := String
coerce p == coerce(p)$Rep
topazcons: (String,String, String) -> % topazcons(rep, cmd, prm) == systemCommand("system " cmd " " polydir rep ".top " prm)_ $MoreSystemCommands rep::Rep
topazprop: (%,String) -> Void topazprop(rep, cmd) == systemCommand("system polymake -A topaz " polydir (rep::Rep) ".top "_ cmd " > " polytmp)$MoreSystemCommands
facets s == topazprop(s,"FACETS") getListSetInteger(polytmpfile)$ReadFile
boundaryComplex s == topazcons(s pretend String,"boundary__complex", _ (s pretend String) ".poly") s pretend String :: Rep
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/5224222550985933765-25px002.spad using old system compiler. POLYTOPE abbreviates domain Polytope ------------------------------------------------------------------------ initializing NRLIB POLYTOPE for Polytope compiling into NRLIB POLYTOPE compiling exported coerce : % -> OutputForm Time: 0.01 SEC.
compiling local polycons : (String,String, String) -> % Time: 0 SEC.
compiling local polyprop : (%,String) -> Void Time: 0 SEC.
compiling exported cube : Integer -> % Time: 0 SEC.
compiling exported cross : Integer -> % Time: 0 SEC.
compiling exported rand01 : (Integer,Integer) -> % Time: 0 SEC.
compiling exported randSphere : (Integer,Integer) -> % Time: 0 SEC.
compiling exported points : % -> Matrix Fraction Integer ****** comp fails at level 3 with expression: ****** error in function points
(SEQ (|polyprop| |s| "POINTS") (|exit| 1 | << | ((|Sel| |ReadFile| |getMatrixFraction|) |polytmpfile|) | >> |)) ****** level 3 ****** x:= ((Sel ReadFile getMatrixFraction) polytmpfile) m:= (Matrix (Fraction (Integer))) f:= ((((|s| # #) (|polyprop| #) (|polycons| #) (|#| #) ...)))
>> Apparent user error: ReadFile is an unknown mode
Let's try it out:
c := cube 4
There are no library operations named cube Use HyperDoc Browse or issue )what op cube to learn if there is any operation containing " cube " in its name.
Cannot find a definition or applicable library operation named cube with argument type(s) PositiveInteger
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need.