[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] [polymake] (nouveau)
From: |
kratt6 |
Subject: |
[Axiom-developer] [polymake] (nouveau) |
Date: |
Wed, 24 Aug 2005 02:14:43 -0500 |
Changes http://page.axiom-developer.org/zope/mathaction/Polymake/diff
--
This is a trivial wrapper for the wonderful polymake package from Berlin,
http://www.math.tu-berlin.de/polymake/ .
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}
)abbrev domain POLYTOPE Polytope
Polytope(): Exports == Implementation where
Exports == with
coerce: % -> OutputForm
-------------------------------------------------------------------------------
-- polytope constructions --
-------------------------------------------------------------------------------
cube: Integer -> %
cross: Integer -> %
rand01: (Integer, Integer) -> %
randSphere: (Integer, Integer) -> %
-------------------------------------------------------------------------------
-- polytope properties --
-------------------------------------------------------------------------------
fVector: % -> Vector Integer
f2Vector: % -> Matrix Integer
hVector: % -> Vector Integer
facets: % -> Matrix Integer
vertices: % -> Matrix Integer
simple: % -> Boolean
Implementation == add
Rep := String
coerce p == coerce(p)$Rep
String2ListInteger: String -> List Integer
String2ListInteger r ==
map(PARSE_-INTEGER(#1)$Lisp, split(r, char(" "))$String)_
$FiniteLinearAggregateFunctions2(String, List String, Integer, _
List Integer)
getBoolean: () -> Boolean
getBoolean ==
f := open(("tmp.poly")::FileName)$TextFile
read!(f)$TextFile
r:String := read!(f)$TextFile
close!(f)$TextFile
(r="1")
getIntegerList: () -> List Integer
getIntegerList ==
f := open(("tmp.poly")::FileName)$TextFile
read!(f)$TextFile
r:String := read!(f)$TextFile
close!(f)$TextFile
String2ListInteger(r)
getIntegerVector: () -> Vector Integer
getIntegerVector == vector(getIntegerList())$Vector(Integer)
getIntegerMatrix: () -> Matrix Integer
getIntegerMatrix ==
f := open(("tmp.poly")::FileName)$TextFile
read!(f)$TextFile
m: List List Integer := []
r: String
while not endOfFile?(f) repeat
r := read!(f)$TextFile
if not empty? r then
m := cons(String2ListInteger r, m)
close!(f)$TextFile
matrix(reverse m)$Matrix(Integer)
-------------------------------------------------------------------------------
-- polytope constructions --
-------------------------------------------------------------------------------
cube n ==
s: String := "cube" string(n)
systemCommand("system cube " s ".poly " string(n))$MoreSystemCommands
s::Rep
cross n ==
s: String := "cross" string(n)
systemCommand("system cross " s ".poly " string(n))$MoreSystemCommands
s::Rep
rand01(d, n) ==
s: String := "rand01" string(d) string(n)
systemCommand("system rand01 " s ".poly " string(d) " "
string(n))$MoreSystemCommands
s::Rep
randSphere(d, n) ==
s: String := "randsphere" string(d) string(n)
systemCommand("system rand__sphere " s ".poly " string(d) " "
string(n))$MoreSystemCommands
s::Rep
-------------------------------------------------------------------------------
-- polytope properties --
-------------------------------------------------------------------------------
fVector s ==
systemCommand("system polymake " (s::Rep) ".poly F__VECTOR > tmp.poly")_
$MoreSystemCommands
getIntegerVector()
f2Vector s ==
systemCommand("system polymake " (s::Rep) ".poly F2__VECTOR >
tmp.poly")_
$MoreSystemCommands
getIntegerMatrix()
hVector s ==
systemCommand("system polymake " (s::Rep) ".poly H__VECTOR > tmp.poly")_
$MoreSystemCommands
getIntegerVector()
facets s ==
systemCommand("system polymake " (s::Rep) ".poly FACETS > tmp.poly")_
$MoreSystemCommands
getIntegerMatrix()
vertices s ==
systemCommand("system polymake " (s::Rep) ".poly VERTICES > tmp.poly")_
$MoreSystemCommands
getIntegerMatrix()
simple s ==
systemCommand("system polymake " (s::Rep) ".poly SIMPLE > tmp.poly")_
$MoreSystemCommands
getBoolean()
)abbrev domain TOPAZ SimplicialComplex
SimplicialComplex(): Exports == Implementation where
Exports == with
coerce: % -> OutputForm
-------------------------------------------------------------------------------
-- topaz constructions --
-------------------------------------------------------------------------------
boundaryComplex: Polytope -> %
-------------------------------------------------------------------------------
-- topaz properties --
-------------------------------------------------------------------------------
facets: % -> List Set Integer
Implementation == add
Rep := String
coerce p == coerce(p)$Rep
String2SetInteger: String -> Set Integer
String2SetInteger r ==
s: String := delete(delete(r, #r), 1)
brace(map(PARSE_-INTEGER(#1)$Lisp, split(s, char(" "))$String)_
$FiniteLinearAggregateFunctions2(String, List String, Integer, _
List Integer))$Set(Integer)
getListSetInteger: () -> List Set Integer
getListSetInteger ==
f := open(("tmp.poly")::FileName)$TextFile
read!(f)$TextFile
m: List Set Integer := []
r: String
while not endOfFile?(f) repeat
r := read!(f)$TextFile
if not empty? r then
m := cons(String2SetInteger r, m)
close!(f)$TextFile
reverse m
-------------------------------------------------------------------------------
-- topaz properties --
-------------------------------------------------------------------------------
facets s ==
systemCommand("system polymake -A topaz " (s::Rep) ".top FACETS >
tmp.poly")_
$MoreSystemCommands
getListSetInteger()
-------------------------------------------------------------------------------
-- topaz constructions --
-------------------------------------------------------------------------------
boundaryComplex s ==
systemCommand("system boundary__complex " (s pretend String) ".top " (s
pretend String) ".poly")_
$MoreSystemCommands
s pretend String :: Rep
\end{axiom}
--
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] [polymake] (nouveau),
kratt6 <=