[BACK]Return to polymake.sm1 CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / trans

File: [local] / OpenXM / src / kan96xx / trans / polymake.sm1 (download)

Revision 1.3, Sat Dec 6 02:49:22 2003 UTC (20 years, 6 months ago) by takayama
Branch: MAIN
CVS Tags: R_1_3_1-2, RELEASE_1_2_3_12, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, KNOPPIX_2006, DEB_REL_1_2_3-9
Changes since 1.2: +50 -16 lines

Supporting -,*,/,^ in the QuoteMode.

% $OpenXM: OpenXM/src/kan96xx/trans/polymake.sm1,v 1.3 2003/12/06 02:49:22 takayama Exp $
% It is a polymake interface

/polymake.start {
  (ox.k0.loaded) boundp {  }
  { [(parse) (ox.sm1) pushfile] extension 
    /@@@polymake.k0.ccc [ ] def
  } ifelse
  @@@polymake.k0.ccc [ ] eq { 
     k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
     @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
  } {  } ifelse
  @@@polymake.k0.ccc 0 get (closed) eq {
     k0connectr /@@@polymake.k0.ccc oxk0.ccc def /oxk0.ccc [ ] def
     @@@polymake.k0.ccc oxsetmathcap @@@polymake.k0.ccc oxmathcap
  } {  } ifelse
  [(which) (polymake)] oxshell tag 0 eq {
     [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell
     [(which) (polymake)] oxshell tag 0 eq {
       (Polymake is not installed in this system.) error
     } {  } ifelse
  } {  } ifelse
  [(which) (polymake2tfb)] oxshell tag 0 eq {
     (polymake2tfb is not installed in this system.) error
  } {  } ifelse
} def

%[(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,0,0]])))]
% doPolymake
% [ tfb-string tree error]
[(doPolymake)
[(It calls polymake to make several construction for polytopes.)
 ([action data_in_polymake_tfb_format] doPolymake )
 (         [result_in_tfb result_in_tree errors])
 (polymake, polymake2tfb, ox_k0 must be installed.)
 (cf. @@@polymake.k0.ccc )
 (Example:)
% ( [(export) (PATH) (=) (/usr/local/polymake/bin:${PATH})] oxshell )
 $ [(FACETS) (polymake.data(polymake.POINTS([[1,0,0],[1,1,0],[1,0,1],[1,1,1]])))]$
 (         doPolymake /rr set )
]] putUsages
/doPolymake {
  /arg1 set
  [/in-doPolymake  /pAction /pData /pNative /ptree
   /pResult  /pError
  ] pushVariables
  [
    arg1 0 get /pAction set
    arg1 1 get /pData set
    polymake.start

    /pError [ ] def
%% step 1:  polymake tfb ===> polymake native data
    @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring 
    @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring 
    @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring 
    @@@polymake.k0.ccc oxpopcmo /ptree set 
    @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring 
    [(treeToPolymake) ptree] extension /pNative set 
%% step 2: calling the polymake
    [(polymake) (stringInOut://pNative.poly) pAction] addStdoutStderr 
    oxshell pop
    pError [@@@stdout @@@stderr] append /pError set
%% step 3: polymake native data to polymake tfb
    [(polymake2tfb) (<) (stringIn://pNative) (>) (stringOut://pResult)
     (2>) (stringOut://@@@stderr)] oxshell pop
    pError [@@@stderr] append /pError set
%% step 4: get also tree style data.
    @@@polymake.k0.ccc ( polymake=Object; ) oxexecutestring 
    @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring 
    @@@polymake.k0.ccc [pResult ( ;)] cat oxexecutestring 
    @@@polymake.k0.ccc oxpopcmo /ptree set 
    @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring 
    [pResult ptree pError] /arg1 set
  ] pop
  popVariables
  arg1
} def

[(tfbToTree)
[(tfb-expression-in-string tfbToTree tree)
 (tfbToTree translates expressions in tfb/2 into tree form.)
 (Bug: the input is parsed by k0, so the symbol name given agrees with)
 (     a k0 symbol, it returns a strange answer.)
 $Example:  ( C+intpath.circle(0,1/2) ) tfbToTree :: $
]] putUsages

/tfbToTree {
  /arg1 set
  [/in-tfbToTree  /pAction /pData /pNative /ptree
   /pResult  /pError /i
  ] pushVariables
  [
    arg1 /pData set
    polymake.start

    /pError [ ] def
%%  tfb ===> CMO tree.
    @@@polymake.k0.ccc ( QuoteMode(1); ) oxexecutestring 
    @@@polymake.k0.ccc [pData ( ;)] cat oxexecutestring 
    @@@polymake.k0.ccc oxpopcmo /ptree set 
    @@@polymake.k0.ccc ( QuoteMode(0); ) oxexecutestring 
    /arg1 ptree def
  ] pop
  popVariables
  arg1
} def