Annotation of OpenXM/src/kan96xx/trans/polymake.sm1, Revision 1.9
1.9 ! takayama 1: % $OpenXM: OpenXM/src/kan96xx/trans/polymake.sm1,v 1.8 2013/09/25 07:30:52 takayama Exp $
1.1 takayama 2: % It is a polymake interface
3:
1.7 takayama 4: /@@@polymake.ask.which 1 def
1.8 takayama 5: /polymake.start { polymake.start.local } def
6: /polymake.start.local {
1.1 takayama 7: (ox.k0.loaded) boundp { }
1.3 takayama 8: { [(parse) (ox.sm1) pushfile] extension
9: /@@@polymake.k0.ccc [ ] def
10: } ifelse
11: @@@polymake.k0.ccc [ ] eq {
12: k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
13: @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1 takayama 14: } { } ifelse
1.3 takayama 15: @@@polymake.k0.ccc 0 get (closed) eq {
16: k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
17: @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
1.1 takayama 18: } { } ifelse
1.6 takayama 19: [(parse) ( 1 )] extension pop % BUG, dummy to avoid bus error on mac.2013.09.21
1.7 takayama 20: @@@polymake.ask.which {
1.1 takayama 21: [(which) (polymake)] oxshell tag 0 eq {
22: [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell
23: [(which) (polymake)] oxshell tag 0 eq {
24: (Polymake is not installed in this system.) error
25: } { } ifelse
26: } { } ifelse
1.7 takayama 27: } { } ifelse
1.1 takayama 28: [(which) (polymake2tfb)] oxshell tag 0 eq {
29: (polymake2tfb is not installed in this system.) error
30: } { } ifelse
31: } def
32:
33: %[(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,0,0]])))]
34: % doPolymake
35: % [ tfb-string tree error]
36: [(doPolymake)
1.4 takayama 37: [(It calls polymake via oxshell and ox_k0 to make several construction for polytopes.)
1.1 takayama 38: ([action data_in_polymake_tfb_format] doPolymake )
39: ( [result_in_tfb result_in_tree errors])
40: (polymake, polymake2tfb, ox_k0 must be installed.)
1.4 takayama 41: (cf. @@@polymake.k0.ccc, kan96xx/Doc/oxshell.*, kan96xx/trans/polymake.sm1, oxshell )
42: (The variable @@@doPolymake.vars keeps session logs with the polymake)
1.8 takayama 43: (See also usePolymake.local, usePolymake.OoHG.native and usePolymake.OoHG.curl in cgi.sm1)
1.1 takayama 44: (Example:)
45: % ( [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell )
1.9 ! takayama 46: $ usePolymake.OoHG.curl polymake.start ; $
1.5 takayama 47: $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1/2]])))]$
1.1 takayama 48: ( doPolymake /rr set )
1.5 takayama 49: ( Keys---properties are FACETS, CONE_DIM, LINEARITY_DIM, FEASIBLE, AFFINE_FULL, ... )
1.1 takayama 50: ]] putUsages
1.8 takayama 51: /doPolymake { doPolymake.local } def
52: /doPolymake.local {
1.1 takayama 53: /arg1 set
54: [/in-doPolymake /pAction /pData /pNative /ptree
55: /pResult /pError
56: ] pushVariables
57: [
58: arg1 0 get /pAction set
59: arg1 1 get /pData set
60: polymake.start
61:
62: /pError [ ] def
63: %% step 1: polymake tfb ===> polymake native data
1.3 takayama 64: @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
65: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
66: @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
67: @@@polymake.k0.ccc oxpopcmo /ptree set
68: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1 takayama 69: [(treeToPolymake) ptree] extension /pNative set
1.5 takayama 70: [ptree pNative pAction] /@@@doPolymake.vars set %for debug
1.1 takayama 71: %% step 2: calling the polymake
1.4 takayama 72: [(polymake) (stringInOut://pNative) pAction] addStdoutStderr
1.1 takayama 73: oxshell pop
74: pError [@@@stdout @@@stderr] append /pError set
1.4 takayama 75: @@@doPolymake.vars [pNative @@@stdout] append /@@@doPolymake.vars set %for debug
76: @@@stdout /pNative set %output file of polymake is XML file. Use old output format.
1.1 takayama 77: %% step 3: polymake native data to polymake tfb
78: [(polymake2tfb) (<) (stringIn://pNative) (>) (stringOut://pResult)
79: (2>) (stringOut://@@@stderr)] oxshell pop
80: pError [@@@stderr] append /pError set
81: %% step 4: get also tree style data.
1.3 takayama 82: @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring
83: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
84: @@@polymake.k0.ccc [pResult ( ;)] cat oxexecutestring
85: @@@polymake.k0.ccc oxpopcmo /ptree set
86: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
1.1 takayama 87: [pResult ptree pError] /arg1 set
1.3 takayama 88: ] pop
89: popVariables
90: arg1
91: } def
92:
93: [(tfbToTree)
94: [(tfb-expression-in-string tfbToTree tree)
95: (tfbToTree translates expressions in tfb/2 into tree form.)
96: (Bug: the input is parsed by k0, so the symbol name given agrees with)
97: ( a k0 symbol, it returns a strange answer.)
98: $Example: ( C+intpath.circle(0,1/2) ) tfbToTree :: $
99: ]] putUsages
100:
101: /tfbToTree {
102: /arg1 set
103: [/in-tfbToTree /pAction /pData /pNative /ptree
104: /pResult /pError /i
105: ] pushVariables
106: [
107: arg1 /pData set
108: polymake.start
109:
110: /pError [ ] def
111: %% tfb ===> CMO tree.
112: @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring
113: @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring
114: @@@polymake.k0.ccc oxpopcmo /ptree set
115: @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring
116: /arg1 ptree def
1.1 takayama 117: ] pop
118: popVariables
119: arg1
120: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>