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

Diff for /OpenXM/src/kan96xx/Doc/gfan.sm1 between version 1.4 and 1.8

version 1.4, 2004/09/15 07:41:59 version 1.8, 2004/10/13 23:36:52
Line 1 
Line 1 
 %  $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.3 2004/09/14 08:30:47 takayama Exp $  %  $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.7 2004/09/30 07:45:04 takayama Exp $
 % cp cone.sm1 $OpenXM_HOME/src/kan96xx/Doc/gfan.sm1  % cp cone.sm1 $OpenXM_HOME/src/kan96xx/Doc/gfan.sm1
 % $Id$  % $Id$
 % iso-2022-jp  % iso-2022-jp
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% Two examples are given below to get a global Grobner fan and
   %% a local Grobner fan ; cone.sample and cone.sample2
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%  Global Grobner Fan
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% How to input data?  An example.   (cf. test13.sm1)
   %%  Modify the following or copy the /cone.sample { ... } def
   %%  to your own file,
   %%  edit it, and execute if by  " cone.sample ; "
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   /cone.sample {
     cone.load.cohom
   % write a comment about the problem.  "nl" means new line.
   /cone.comment [
     (Toric ideal for 1-simplex x 2-simplex, in k[x]) nl
   ] cat def
   
   % List of variables
   % If cone.type=1, then (H) should be added.
   /cone.vlist [(x11) (x12) (x13) (x21) (x22) (x23)
                (Dx11) (Dx12) (Dx13) (Dx21) (Dx22) (Dx23) (h)] def
   
   % List of variables in the form for define_ring.
   /cone.vv (x11,x12,x13,x21,x22,x23) def
   
   % If cone.type=0, then  x,Dx,
   % If cone.type=1, then  x,Dx,h,H    (Doubly homogenized)
   % If cone.type=2, then  x,Dx,h
   /cone.type 2 def
   
   % Set how to parametrize the weight space.
   % In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33
   %   p q parametrizeSmallFan  (p >= q) : Enumerate Grobner cones in the Small
   %                                       Grobner fan.
   %                                       The weights for the last p-q variables
   %                                       are 0.
   %     Example. 6 2 parametrizeSmallFan   weights for x12,x21,x22,x23 are 0.
   %
   %   p q parametrizeTotalFan  (p = q = number of variables in cone.vv)
   %                             p > q has not yet been implemented.
   %
   /cone.parametrizeWeightSpace {
     6 6 parametrizeSmallFan
   } def
   
   % If you want to enumerate Grobner cones in local order (i.e., x^e <= 0),
   % then  cone.local = 1  else cone.local = 0.
   /cone.local 0 def
   
   % Initial value of the weight in the weight space of which dimension is
   % cone.m
   % If it is null, then a random weight is used.
   /cone.w_start
     null
   def
   
   % If cone.h0=1, then the weight for h is 0.
   % It is usally set to 1.
   /cone.h0 1 def
   
   % Set input polynomials which generate the ideal.
   % Input must be homogenized.
   %    (see also data/test14.sm1 for double homogenization.)
   /cone.input
     [
       (x11 x22 - x12 x21)
       (x12 x23 - x13 x22)
       (x11 x23 - x13 x21)
     ]
   def
   
   % Set a function to compute Grobner basis.
   %  cone.gb_Dh   : For computing in Homogenized Weyl algebra h[1,1](D).
   %  cone.gb_DhH  : For computing in doubly homogenized Weyl algebra.
   %                  ( Computation in ^O and h[0,1](^D) need this
   %                    as the first step.  /cone.local  1 def )
   /cone.gb {
     cone.gb_Dh
   } def
   
   
   cone.comment message
   (cone.input = ) message
   cone.input message
   %%%% Step 1.  Enumerating the Grobner Cones in a global ring.
   %%%%   The result is stored in cone.fan
   getGrobnerFan
   
   %%%% If you want to print the output, then uncomment.
   printGrobnerFan
   
   %%%% If you want to save the data to the file sm1out.txt, then uncomment.
   % /cone.wightGblist 1 def saveGrobnerFan /ff set ff output
   
   %%%% Step 2. Dehomogenize the Grobner Cones
   %%%%  by the equivalence relation in a local ring (uncomment).
   % dhCones_h
   
   %%%% Generate the final data dhcone2.fan (a list of local Grobner cones.)
   % dhcone.rtable
   
   %%%%  Output dhcone2.fan with explanations
   % dhcone.printGrobnerFan
   
   } def
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% End of " How to input data?  An example. "
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%  Local Grobner Fan
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% How to input data?  The example 2 (cf. test14.sm1).
   %%  Modify the following or copy the /cone.sample2 { ... } def
   %%  to your own file,
   %%  edit it, and execute if by  " cone.sample2 ; "
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   /cone.sample2 {
     cone.load.cohom
   % write a comment about the problem.  "nl" means new line.
   /cone.comment [
     (BS for y and y-(x-1)^2, t1, t2 space, in doubly homogenized Weyl algebra.) nl
     (The Grobner cones are dehomogenized to get local Grobner fan.) nl
   ] cat def
   
   % List of variables
   % If cone.type=1, then (H) should be added.
   /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h) (H)] def
   
   % List of variables in the form for define_ring.
   /cone.vv (t1,t2,x,y) def
   
   % If cone.type=0, then  x,Dx,
   % If cone.type=1, then  x,Dx,h,H    (Doubly homogenized)
   % If cone.type=2, then  x,Dx,h
   /cone.type 1 def
   
   % Set how to parametrize the weight space.
   % In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33
   %   p q parametrizeSmallFan  (p >= q) : Enumerate Grobner cones in the Small
   %                                       Grobner fan.
   %                                       The weights for the last p-q variables
   %                                       are 0.
   %     Example. 6 2 parametrizeSmallFan   weights for x12,x21,x22,x23 are 0.
   %
   %   p q parametrizeTotalFan  (p = q = number of variables in cone.vv)
   %                             p > q has not yet been implemented.
   %
   /cone.parametrizeWeightSpace {
     4 2 parametrizeSmallFan
   } def
   
   % If you want to enumerate Grobner cones in local order (i.e., x^e <= 0),
   % then  cone.local = 1  else cone.local = 0.
   /cone.local 1 def
   
   % Initial value of the weight in the weight space of which dimension is
   % cone.m
   % If it is null, then a random weight is used.
   /cone.w_start
     null
   def
   
   % If cone.h0=1, then the weight for h is 0.
   % It is usally set to 1.
   /cone.h0 1 def
   
   % Set input polynomials which generate the ideal.
   % Input must be homogenized.
   %    (see also data/test14.sm1 for double homogenization.)
   /cone.input
     [
       (t1-y) (t2 - (y-(x-1)^2))
       ((-2 x + 2)*Dt2+Dx)
       (Dt1+Dt2+Dy)
     ]
   def
   % homogenize
     [cone.vv ring_of_differential_operators
      [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
     0] define_ring
     dh.begin
     cone.input { . homogenize toString } map /cone.input set
     dh.end
   
   % Set a function to compute Grobner basis.
   %  cone.gb_Dh   : For computing in Homogenized Weyl algebra h[1,1](D).
   %  cone.gb_DhH  : For computing in doubly homogenized Weyl algebra.
   %                  ( Computation in ^O and h[0,1](^D) need this
   %                    as the first step.  /cone.local  1 def )
   /cone.gb {
     cone.gb_DhH
   } def
   
   cone.comment message
   (cone.input = ) message
   cone.input message
   %%%% Step 1.  Enumerating the Grobner Cones in a global ring.
   %%%%   The result is stored in cone.fan
   getGrobnerFan
   
   %%%% If you want to print the output, then uncomment.
   printGrobnerFan
   
   %%%% If you want to save the data to the file sm1out.txt, then uncomment.
   % /cone.wightGblist 1 def saveGrobnerFan /ff set ff output
   
   %%%% Step 2. Dehomogenize the Grobner Cones
   %%%%  by the equivalence relation in a local ring (uncomment).
   dhCones_h
   
   %%%% Generate the final data dhcone2.fan (a list of local Grobner cones.)
   dhcone.rtable
   
   %%%%  Output dhcone2.fan with explanations
   dhcone.printGrobnerFan
   
   } def
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %% End of " How to input data?  The example 2. "
   %% Do not touch below.
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   [(parse) (cgi.sm1) pushfile] extension
   
   % If you use local polymake, then comment out.
   % If you use the cgi/polymake on the net, then uncomment out.
   %/doPolymake {doPolymake.OoHG} def    (Using doPolymake.OoHG ) message
   %/polymake.start {polymake.start.OoHG} def (Using polymake.start.OoHG ) message
   %% Choose it automatically.
   [(which) (polymake)] oxshell tag 0 eq {
     (Polymake is not installed in this system.)  message
     /doPolymake {doPolymake.OoHG} def
     (Using doPolymake.OoHG ) message
     /polymake.start {polymake.start.OoHG} def
     (Using polymake.start.OoHG ) message
   } { (Local polymake will be used.) message } ifelse
   
 /cone.debug 1 def  /cone.debug 1 def
   
 /ox.k0.loaded boundp {  /ox.k0.loaded boundp {
Line 10 
Line 261 
  [(parse) (ox.sm1) pushfile] extension   [(parse) (ox.sm1) pushfile] extension
 } ifelse  } ifelse
   
   /cone.load.cohom {
    /cone.loaded boundp { }
    {
     [(parse) (cohom.sm1) pushfile] extension
   %  [(parse) (cone.sm1) pushfile] extension   % BUG? cone.sm1 overrides a global
                                                % in cohom.sm1?
     [(parse) (dhecart.sm1) pushfile] extension
     /cone.loaded 1 def
     oxNoX
     polymake.start  (  ) message
    } ifelse
   } def
   
   %% Usages:  cone.gb_DhH.  h H (double homogenized) $BMQ$N(B GB.
   %%   dhecart.sm1 $B$r(B load $B$7$F$"$k$3$H(B. $BF~NO$OF1<!$G$J$$$H$$$1$J$$(B.
   %% [cone.vv ring_of_differential_operators
   %%  [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
   %%  0] define_ring
   %%   dh.begin  homogenize dh.end $B$J$I$NJ}K!$GF1<!2=$G$-$k(B.
   /cone.gb_DhH {
     /arg2 set /arg1 set
     [/ff /ww] pushVariables
     [
        /ff arg1 def
        /ww arg2 def
        /dh.gb.verbose 1 def
        /dh.autoHomogenize 0 def
        [(AutoReduce) 1] system_variable
        [ff { toString } map cone.vv
         [ww cone.vv generateD1_1]] dh.gb 0 get /arg1 set
     ] pop
     arg1
   } def
   
 %  %
 % cone.fan, cone.gblist $B$K(B fan $B$N%G!<%?$,$O$$$k(B.  % cone.fan, cone.gblist $B$K(B fan $B$N%G!<%?$,$O$$$k(B.
 %  %
   %%%%<<<<  $B=i4|%G!<%?$N@_DjNc(B. $BF|K\8lHG(B  data/test13 $B$h$j(B.  <<<<<<<<<<<<<<
 %%%%<<<<  $B=i4|%G!<%?$N@_DjNc(B  data/test13 $B$h$j(B.  <<<<<<<<<<<<<<  /cone.sample.test13.ja {
 /cone.sample.test13 {  
  /cone.loaded boundp { }   /cone.loaded boundp { }
  {   {
   [(parse) (cohom.sm1) pushfile] extension    [(parse) (cohom.sm1) pushfile] extension
Line 2935  def   
Line 3219  def   
        [(cones) [ ] cones] arrayToTree         [(cones) [ ] cones] arrayToTree
        [(facets) [ ] facets] arrayToTree         [(facets) [ ] facets] arrayToTree
        [(merged) [ ] merged] arrayToTree         [(merged) [ ] merged] arrayToTree
        [(nextcid) [ ] merged] arrayToTree         [(nextcid) [ ] nextcid] arrayToTree
        [(nextfid) [ ] merged] arrayToTree         [(nextfid) [ ] nextfid] arrayToTree
        [(coneid) [ ] merged] arrayToTree         [(coneid) [ ] coneid] arrayToTree
      ]       ]
    ] arrayToTree /arg1 set     ] arrayToTree /arg1 set
   ] pop    ] pop
Line 2970  def   
Line 3254  def   
   dhcone.fan    dhcone.fan
 } def  } def
   
 % Todo: print, save functions.  Representative of weight & init.  %<
   % Usages: dhcone.rtable
   % dhcone $B$NHV9f$H(B cone $B$NHV9f$N(B $BCV49I=$r@8@.$7(B dhcone2.fan (merge $B$7$?(B cone $B$N>pJs(B)
   % $B$r(B dhcone.fan $B$+$i:n$k(B. dhcone2.gblist $B$b:n$kJd=u4X?t(B.
   % dhCones_h $B$7$F$+$i(B dhcone.rable $B$9$k(B.
   %>
   /dhcone.rtable {
     [/i /j /vv /cones /facets /facets2 /merged /nextcid /nextcid2 /ii /ww] pushVariables
     [
   % $BCV49I=(B dhcone.h2dh $B$r:n$k(B.
       /dhcone.h2dh cone.fan length newVector.with-1 def
       0 1 , dhcone.fan length 1 sub {
         /i set
         dhcone.fan i get , (cones) getNode 2 get /vv set
         0 1 vv length 1 sub {
           /j set
           dhcone.h2dh , vv j get , i to_univNum , put
         } for
       } for
   % merge $B$7$?(B dhcone $B$r@0M}$7$?$b$N(B, dhcone2.fan $B$r:n$k(B.
       /dhcone2.fan dhcone.fan length newVector def
       0 1 , dhcone.fan length 1 sub {
         /i set
         dhcone.fan i get (facets) getNode 2 get /facets set
         dhcone.fan i get (merged) getNode 2 get /merged set
         dhcone.fan i get (nextcid) getNode 2 get /nextcid set
         dhcone.fan i get (cones) getNode 2 get /cones set
         /facets2 [ ] def
         /nextcid2 [ ] def
         0 1 , facets length 1 sub {
            /j set
            merged j get , (3).. eq {
               facets2 [ facets j get ] join /facets2 set
   % $B$H$J$j$N(B cone $B$,$"$k$H$-(B $BJQ49I=$K$7$?$,$$(B, cone $BHV9f$rJQ49(B
               nextcid2 [ dhcone.h2dh , nextcid j get , get ] join /nextcid2 set
            } {  } ifelse
            merged j get , (2).. eq {
               facets2 [ facets j get ] join /facets2 set
   % $B6-3&$N$H$-(B -2 $B$rF~$l$k(B.
               nextcid2 [ (-2).. ] join /nextcid2 set
            } { } ifelse
         } for
   
         dhcone2.fan i ,
         [(dhcone) [ ]
          [
            [(facets) [ ] facets2] arrayToTree
            [(nextcid) [ ] nextcid2] arrayToTree
            [(cones) [ ] cones] arrayToTree
          ]
         ] arrayToTree , put
   
       } for
   
   % $B:G8e$K(B dhcone2.gblist $B$r:n$k(B.
       /dhcone2.gblist , dhcone2.fan length newVector , def
       0 1 , dhcone2.fan length 1 sub {
         /i set
         dhcone2.fan i get (cones) getNode 2 get /cones set
         cone.grGblist , cones 0 get , get , /ii set % GB of initial (H->1).
         cone.gblist i get , (weight) getNode , [ 2 0 2 ] get  /ww set
   
         dhcone2.gblist i,
         [(gbasis) [ ]
          [
            [(initial) [ ] ii] arrayToTree
            [(weight) [ ] ww] arrayToTree
          ]
         ] arrayToTree , put
   
       } for
       (dhcone2.fan, dhcone2.gblist, dhcone.h2dh are set.) message
   
     ] pop
     popVariables
   } def
   
   %<
   % $BI=$N8+J}$N2r@b$r0u:~$9$k4X?t(B.
   % Usages: dhcone.explain
   %>
   /dhcone.explain {
     [
       ( ) nl
       (Data format in << dhcone2.fan >>, which is a dehomogenized Grobner fan.) nl nl
       (<< cone.vlist >> is the list of the variables.) nl
       @@@.Hsymbol  ( is the homogenization variable to be dehomogenized.) nl nl
       (<< cone.input >> is generators of a given ideal.) nl nl
       (<< cone.d >> is the dimension of parametrization space of the weights P_w) nl
       (    P_w is a cone in R^m  where the number m is stored in << cone.m >>) nl
       (    P_w --- W --->  R^n [weight space].  ) nl
       (    W is stored in << cone.W >> ) nl
       (    << u   cone.W  mul >> gives the weight vector standing for u) nl nl
       (All cones in the data lie in the weight parametrization space P_w.) nl
       ( "facets" are the inner normal vector of the cone. )  nl
       ( "nextcid" is a list of the cone id's of the adjacent cones.) nl
       (   -2 in "nextcid" means that this facet lies on the border of the weight space.) nl
       ( "cones" is a list of the cone id's of the NON-dehomonized Grobner fan) nl
       (                                               stored in << cone.fan >>) nl
     ] cat
   } def
   
   %<
   %  dhcone.printGrobnerFan
   %  dhcone $B$N0u:~4X?t(B
   %>
   /dhcone.printGrobnerFan {
     [/i] pushVariables
     [
     (==========  Grobner Fan (for dehomogenized cones) ============) message
      [
         (cone.comment)
         (cone.vlist) (cone.vv)
         (cone.input)
         (cone.type)  (cone.local) (cone.h0)
         (cone.n) (cone.m) (cone.d)
         (cone.W) (cone.Wpos) (cone.Wt)
         (cone.L) (cone.Lp) (cone.Lpt)
         (cone.weightBorder)
         (cone.incidence)
      ] { printGrobnerFan.1 } map
      (   ) message
      (The number of cones = ) messagen dhcone.fan length message
      (   ) message
      0 1 dhcone2.fan length 1 sub {
        /ii set
        ii messagen ( : ) messagen
        dhcone2.fan ii get printTree
      } for
      1 {
       0 1 dhcone2.gblist length 1 sub {
         /ii set
         ii messagen ( : ) messagen
         dhcone2.gblist ii get printTree
       } for
     } {  } ifelse
   
   
     (=========================================) message
     %(cone.withGblist = ) messagen cone.withGblist message
     dhcone.explain message
     (  ) message
     ] pop
     popVariables
   } def
   
   %
   % $B;n$7J}(B  test14, 22, 25
   %
   %  (data/test14.sm1) run (data/test14-data.sm1) run
   %   printGrobnerFan ;  % H $BIU$-$G0u:~(B.
   %   dhCones_h ;   %  dehomogenize Cones.
   %   dhcone.rtable ; % dhcone2.fan $BEy$r@8@.(B.
   %   dhcone.printGrobnerFan ; % $B0u:~(B.
   %   $B0u:~$7$?$b$N$O(B  test*-print.txt $B$X3JG<$7$F$"$k(B.
   %
   
   % Todo: save functions.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>