Annotation of OpenXM/src/kan96xx/Doc/gfan.sm1, Revision 1.12
1.12 ! takayama 1: % $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.11 2005/07/07 06:07:46 takayama Exp $
1.1 takayama 2: % cp cone.sm1 $OpenXM_HOME/src/kan96xx/Doc/gfan.sm1
1.12 ! takayama 3: % $Id: cone.sm1,v 1.81 2005/07/07 07:53:27 taka Exp $
1.1 takayama 4: % iso-2022-jp
1.9 takayama 5: %%Ref: @s/2004/08/21-note.pdf
1.1 takayama 6:
1.6 takayama 7: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8: %% Two examples are given below to get a global Grobner fan and
9: %% a local Grobner fan ; cone.sample and cone.sample2
10: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11: %%% Global Grobner Fan
12: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13: %% How to input data? An example. (cf. test13.sm1)
14: %% Modify the following or copy the /cone.sample { ... } def
15: %% to your own file,
1.9 takayama 16: %% edit it, and execute it by " cone.sample ; "
1.6 takayama 17: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18: /cone.sample {
19: cone.load.cohom
1.11 takayama 20: /cone.ckmFlip 1 def
1.6 takayama 21: % write a comment about the problem. "nl" means new line.
22: /cone.comment [
23: (Toric ideal for 1-simplex x 2-simplex, in k[x]) nl
24: ] cat def
25:
26: % List of variables
27: % If cone.type=1, then (H) should be added.
28: /cone.vlist [(x11) (x12) (x13) (x21) (x22) (x23)
29: (Dx11) (Dx12) (Dx13) (Dx21) (Dx22) (Dx23) (h)] def
30:
31: % List of variables in the form for define_ring.
32: /cone.vv (x11,x12,x13,x21,x22,x23) def
33:
34: % If cone.type=0, then x,Dx,
35: % If cone.type=1, then x,Dx,h,H (Doubly homogenized)
36: % If cone.type=2, then x,Dx,h
37: /cone.type 2 def
38:
39: % Set how to parametrize the weight space.
40: % In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33
41: % p q parametrizeSmallFan (p >= q) : Enumerate Grobner cones in the Small
42: % Grobner fan.
43: % The weights for the last p-q variables
44: % are 0.
45: % Example. 6 2 parametrizeSmallFan weights for x12,x21,x22,x23 are 0.
46: %
47: % p q parametrizeTotalFan (p = q = number of variables in cone.vv)
48: % p > q has not yet been implemented.
49: %
50: /cone.parametrizeWeightSpace {
51: 6 6 parametrizeSmallFan
52: } def
53:
54: % If you want to enumerate Grobner cones in local order (i.e., x^e <= 0),
55: % then cone.local = 1 else cone.local = 0.
56: /cone.local 0 def
57:
58: % Initial value of the weight in the weight space of which dimension is
59: % cone.m
60: % If it is null, then a random weight is used.
61: /cone.w_start
62: null
63: def
64:
65: % If cone.h0=1, then the weight for h is 0.
66: % It is usally set to 1.
67: /cone.h0 1 def
68:
69: % Set input polynomials which generate the ideal.
70: % Input must be homogenized.
71: % (see also data/test14.sm1 for double homogenization.)
72: /cone.input
73: [
74: (x11 x22 - x12 x21)
75: (x12 x23 - x13 x22)
76: (x11 x23 - x13 x21)
77: ]
78: def
79:
1.10 takayama 80: /cone.DhH 0 def
1.6 takayama 81: % Set a function to compute Grobner basis.
82: % cone.gb_Dh : For computing in Homogenized Weyl algebra h[1,1](D).
83: % cone.gb_DhH : For computing in doubly homogenized Weyl algebra.
84: % ( Computation in ^O and h[0,1](^D) need this
85: % as the first step. /cone.local 1 def )
86: /cone.gb {
87: cone.gb_Dh
88: } def
89:
90:
91: cone.comment message
92: (cone.input = ) message
93: cone.input message
94: %%%% Step 1. Enumerating the Grobner Cones in a global ring.
95: %%%% The result is stored in cone.fan
96: getGrobnerFan
97:
98: %%%% If you want to print the output, then uncomment.
99: printGrobnerFan
100:
101: %%%% If you want to save the data to the file sm1out.txt, then uncomment.
1.9 takayama 102: % /cone.withGblist 1 def saveGrobnerFan /ff set ff output
1.6 takayama 103:
104: %%%% Step 2. Dehomogenize the Grobner Cones
105: %%%% by the equivalence relation in a local ring (uncomment).
106: % dhCones_h
107:
108: %%%% Generate the final data dhcone2.fan (a list of local Grobner cones.)
109: % dhcone.rtable
110:
111: %%%% Output dhcone2.fan with explanations
112: % dhcone.printGrobnerFan
113:
114: } def
115: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117: %% End of " How to input data? An example. "
118: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120:
121:
122:
123: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124: %%% Local Grobner Fan
125: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126: %% How to input data? The example 2 (cf. test14.sm1).
127: %% Modify the following or copy the /cone.sample2 { ... } def
128: %% to your own file,
129: %% edit it, and execute if by " cone.sample2 ; "
130: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131: /cone.sample2 {
132: cone.load.cohom
1.11 takayama 133: /cone.ckmFlip 1 def
1.6 takayama 134: % write a comment about the problem. "nl" means new line.
135: /cone.comment [
136: (BS for y and y-(x-1)^2, t1, t2 space, in doubly homogenized Weyl algebra.) nl
137: (The Grobner cones are dehomogenized to get local Grobner fan.) nl
138: ] cat def
139:
140: % List of variables
141: % If cone.type=1, then (H) should be added.
142: /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h) (H)] def
143:
144: % List of variables in the form for define_ring.
145: /cone.vv (t1,t2,x,y) def
146:
147: % If cone.type=0, then x,Dx,
148: % If cone.type=1, then x,Dx,h,H (Doubly homogenized)
149: % If cone.type=2, then x,Dx,h
150: /cone.type 1 def
151:
152: % Set how to parametrize the weight space.
153: % In the example below, 6 means the number of variables x11,x12,x13,x21,x22,x33
154: % p q parametrizeSmallFan (p >= q) : Enumerate Grobner cones in the Small
155: % Grobner fan.
156: % The weights for the last p-q variables
157: % are 0.
158: % Example. 6 2 parametrizeSmallFan weights for x12,x21,x22,x23 are 0.
159: %
160: % p q parametrizeTotalFan (p = q = number of variables in cone.vv)
161: % p > q has not yet been implemented.
162: %
163: /cone.parametrizeWeightSpace {
164: 4 2 parametrizeSmallFan
165: } def
166:
167: % If you want to enumerate Grobner cones in local order (i.e., x^e <= 0),
168: % then cone.local = 1 else cone.local = 0.
169: /cone.local 1 def
170:
171: % Initial value of the weight in the weight space of which dimension is
172: % cone.m
173: % If it is null, then a random weight is used.
174: /cone.w_start
175: null
176: def
177:
178: % If cone.h0=1, then the weight for h is 0.
179: % It is usally set to 1.
180: /cone.h0 1 def
181:
182: % Set input polynomials which generate the ideal.
183: % Input must be homogenized.
184: % (see also data/test14.sm1 for double homogenization.)
185: /cone.input
186: [
187: (t1-y) (t2 - (y-(x-1)^2))
188: ((-2 x + 2)*Dt2+Dx)
189: (Dt1+Dt2+Dy)
190: ]
191: def
192: % homogenize
193: [cone.vv ring_of_differential_operators
194: [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
195: 0] define_ring
196: dh.begin
197: cone.input { . homogenize toString } map /cone.input set
198: dh.end
199:
1.10 takayama 200: /cone.DhH 1 def
1.6 takayama 201: % Set a function to compute Grobner basis.
202: % cone.gb_Dh : For computing in Homogenized Weyl algebra h[1,1](D).
203: % cone.gb_DhH : For computing in doubly homogenized Weyl algebra.
204: % ( Computation in ^O and h[0,1](^D) need this
205: % as the first step. /cone.local 1 def )
206: /cone.gb {
207: cone.gb_DhH
208: } def
209:
210: cone.comment message
211: (cone.input = ) message
212: cone.input message
213: %%%% Step 1. Enumerating the Grobner Cones in a global ring.
214: %%%% The result is stored in cone.fan
215: getGrobnerFan
216:
217: %%%% If you want to print the output, then uncomment.
218: printGrobnerFan
219:
220: %%%% If you want to save the data to the file sm1out.txt, then uncomment.
1.9 takayama 221: % /cone.withGblist 1 def saveGrobnerFan /ff set ff output
1.6 takayama 222:
223: %%%% Step 2. Dehomogenize the Grobner Cones
224: %%%% by the equivalence relation in a local ring (uncomment).
225: dhCones_h
226:
227: %%%% Generate the final data dhcone2.fan (a list of local Grobner cones.)
228: dhcone.rtable
229:
230: %%%% Output dhcone2.fan with explanations
231: dhcone.printGrobnerFan
232:
233: } def
234: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236: %% End of " How to input data? The example 2. "
237: %% Do not touch below.
238: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240:
241:
242: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246:
247: [(parse) (cgi.sm1) pushfile] extension
248:
249: % If you use local polymake, then comment out.
250: % If you use the cgi/polymake on the net, then uncomment out.
1.8 takayama 251: %/doPolymake {doPolymake.OoHG} def (Using doPolymake.OoHG ) message
252: %/polymake.start {polymake.start.OoHG} def (Using polymake.start.OoHG ) message
253: %% Choose it automatically.
254: [(which) (polymake)] oxshell tag 0 eq {
255: (Polymake is not installed in this system.) message
256: /doPolymake {doPolymake.OoHG} def
257: (Using doPolymake.OoHG ) message
258: /polymake.start {polymake.start.OoHG} def
259: (Using polymake.start.OoHG ) message
260: } { (Local polymake will be used.) message } ifelse
1.6 takayama 261:
1.1 takayama 262: /cone.debug 1 def
263:
264: /ox.k0.loaded boundp {
265: } {
266: [(parse) (ox.sm1) pushfile] extension
267: } ifelse
268:
1.6 takayama 269: /cone.load.cohom {
270: /cone.loaded boundp { }
271: {
272: [(parse) (cohom.sm1) pushfile] extension
1.8 takayama 273: % [(parse) (cone.sm1) pushfile] extension % BUG? cone.sm1 overrides a global
274: % in cohom.sm1?
1.6 takayama 275: [(parse) (dhecart.sm1) pushfile] extension
276: /cone.loaded 1 def
1.8 takayama 277: oxNoX
278: polymake.start ( ) message
1.6 takayama 279: } ifelse
280: } def
281:
282: %% Usages: cone.gb_DhH. h H (double homogenized) $BMQ$N(B GB.
283: %% dhecart.sm1 $B$r(B load $B$7$F$"$k$3$H(B. $BF~NO$OF1<!$G$J$$$H$$$1$J$$(B.
284: %% [cone.vv ring_of_differential_operators
285: %% [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
286: %% 0] define_ring
287: %% dh.begin homogenize dh.end $B$J$I$NJ}K!$GF1<!2=$G$-$k(B.
288: /cone.gb_DhH {
289: /arg2 set /arg1 set
290: [/ff /ww] pushVariables
291: [
292: /ff arg1 def
293: /ww arg2 def
294: /dh.gb.verbose 1 def
295: /dh.autoHomogenize 0 def
296: [(AutoReduce) 1] system_variable
297: [ff { toString } map cone.vv
1.9 takayama 298: [ww cone.vv generateD1_1]] ff getAttributeList setAttributeList
299: dh.gb 0 get /arg1 set
1.6 takayama 300: ] pop
1.9 takayama 301: popVariables
1.6 takayama 302: arg1
303: } def
304:
1.3 takayama 305: %
306: % cone.fan, cone.gblist $B$K(B fan $B$N%G!<%?$,$O$$$k(B.
307: %
1.6 takayama 308: %%%%<<<< $B=i4|%G!<%?$N@_DjNc(B. $BF|K\8lHG(B data/test13 $B$h$j(B. <<<<<<<<<<<<<<
309: /cone.sample.test13.ja {
1.2 takayama 310: /cone.loaded boundp { }
311: {
312: [(parse) (cohom.sm1) pushfile] extension
313: [(parse) (cone.sm1) pushfile] extension
314: /cone.loaded 1 def
315: } ifelse
316: /cone.comment [
317: (Toric ideal for 1-simplex x 2-simplex, in k[x]) nl
318: ] cat def
319: %------------------Globals----------------------------------------
320: % Global: cone.type
321: % $B$I$N(B exponents $B$r<h$j=P$9$N$+;XDj$9$k(B.
322: % cf. exponents, gbext h $B$d(B H $B$b8+$k$+(B?
323: % 0 : x,y,Dx,Dy
324: % 1 : x,y,Dx,Dy,h,H
325: % 2 : x,y,Dx,Dy,h
326: /cone.type 2 def
327:
328: % Global: cone.local
329: % cone.local: Local $B$+(B? 1 $B$J$i(B local
330: /cone.local 0 def
331:
332:
333: % Global: cone.h0
334: % cone.h0: 1 $B$J$i(B h $B$N(B weight 0 $B$G$N(B Grobner fan $B$r7W;;$9$k(B.
335: /cone.h0 1 def
336:
337: % --------------- $BF~NO%G!<%?MQBg0hJQ?t$N@_Dj(B --------------------------
338: %
339: % cone.input : $BF~NOB?9`<07O(B
340: /cone.input
341: [
342: (x11 x22 - x12 x21) (x12 x23 - x13 x22)
343: (x11 x23 - x13 x21)
344: ]
345: def
346:
347: % cone.vlist : $BA4JQ?t$N%j%9%H(B
348: /cone.vlist [(x11) (x12) (x13) (x21) (x22) (x23)
349: (Dx11) (Dx12) (Dx13) (Dx21) (Dx22) (Dx23) (h)] def
350:
351: % cone.vv : define_ring $B7A<0$NJQ?t%j%9%H(B.
352: /cone.vv (x11,x12,x13,x21,x22,x23) def
353:
354: % cone.parametrizeWeightSpace : weight $B6u4V$r(B parametrize $B$9$k4X?t(B.
355: % $BBg0hJQ?t(B cone.W , cone.Wpos $B$b$-$^$k(B.
356: /cone.parametrizeWeightSpace {
357: 6 6 parametrizeSmallFan
358: } def
359:
360: % cone.w_start : weight$B6u4V$K$*$1$k(B weight $B$N=i4|CM(B.
361: % $B$3$NCM$G(B max dim cone $B$,F@$i$l$J$$$H(B random weight $B$K$h$k(B $B%5!<%A$,;O$^$k(B.
362: % random $B$K$d$k$H$-$O(B null $B$K$7$F$*$/(B.
363: /cone.w_start
364: [9 8 5 4 5 6]
365: def
366:
367: % cone.gb : gb $B$r7W;;$9$k4X?t(B.
368: /cone.gb {
369: cone.gb_Dh
370: } def
371:
372:
373:
374: ( ) message
375: cone.comment message
376: (cone.input = ) messagen cone.input message
377: (Type in getGrobnerFan) message
378: (Do clearGlobals if necessary) message
379: (printGrobnerFan ; saveGrobnerFan /ff set ff output ) message
380:
381: } def
382: %%%%%%>>>>> $B=i4|%G!<%?$N@_DjNc$*$o$j(B >>>>>>>>>>>>>>>>>>>>>>
383:
1.1 takayama 384: % Global: cone.type
385: % $B$I$N(B exponents $B$r<h$j=P$9$N$+;XDj$9$k(B.
386: % cf. exponents, gbext h $B$d(B H $B$b8+$k$+(B?
387: % 0 : x,y,Dx,Dy
388: % 1 : x,y,Dx,Dy,h,H
389: % 2 : x,y,Dx,Dy,h
390: /cone.type 2 def
391:
392: % Global: cone.local
393: % cone.local: Local $B$+(B? 1 $B$J$i(B local
394: /cone.local 1 def
395:
396: % Global: cone.h0
397: % cone.h0: 1 $B$J$i(B h $B$N(B weight 0 $B$G$N(B Grobner fan $B$r7W;;$9$k(B.
398: /cone.h0 1 def
399:
400: % Global: cone.n (number of variables in GB)
401: % cone.m (freedom of the weight space. cf. cone.W)
402: % cone.d (pointed cones lies in this space. cf. cone.Lp)
403: % These are set during getting the cone.startingCone
404:
1.10 takayama 405: %<
406: % global
407: %cone.ckmFlip. Collar-Kalkbrener-Mall $B$N(B flip $B%"%k%4%j%:%`$r;H$o$J$$(B 0. $B;H$&(B 1.
408: % Default $B$O(B 0.
409: %>
410: /cone.ckmFlip 0 def
411:
412: %<
413: % global
414: % cone.DhH dx x = x dx + h H $B$J$i(B 1. dx x = x dx + h^2 $B$J$i(B 0. Default 0.
415: %>
416: /cone.DhH 0 def
417:
1.12 ! takayama 418: %<
! 419: % Global
! 420: % gbCheck $B$r$9$k$+(B? $B$7$J$$$H7k2L$O$"$d$U$d(B. $B$7$+$7%a%b%j(B exhaust $B$OKI$2$k(B.
! 421: % $B;H$&$H$-$O(B /cone.epsilon, /cone.epsilon.limit $B$r==J,>.$5$/$7$F$*$/(B.
! 422: %>
! 423: /cone.do_gbCheck 1 def
! 424:
1.10 takayama 425: % Default $B$N(B cone.gb $B$NDj5A(B. $B3F%W%m%0%i%`$G:FEYDj5A$7$F$b$h$$(B.
426: /cone.gb {
427: cone.DhH {
428: cone.gb_DhH
429: } {
430: cone.gb_Dh
431: } ifelse
432: } def
1.1 takayama 433:
434: %<
435: % Usage: wv g coneEq1
436: % in(f) $B$,(B monomial $B@lMQ(B. in_w(f) = LT(f) $B$H$J$k(B weight w $B$NK~$?$9(B
437: % $BITEy<0@)Ls$r5a$a$k(B.
438: %>
439: /coneEq1 {
440: /arg1 set
441: [/g /eqs /gsize /i /j /n /f /exps /m % Do not use "eq" as a variable
442: /expsTop
443: ] pushVariables
444: [
445: /g arg1 def % Reduced Grobner basis
446: /eqs [ ] def % $BITEy<07O$N78?t(B
447: /gsize g length def
448: 0 1 gsize 1 sub {
449: /i set
450: g i get /f set % f $B$O(B i $BHVL\$N(B reduced Grobner basis $B$N85(B
451: [(exponents) f cone.type] gbext /exps set % exps $B$O(B f $B$N(B exponent vector
452: exps length /m set
453: m 1 eq not {
454: /expsTop exps 0 get def % expsTop $B$O(B f $B$N@hF,$N(B exponent vector.
455: 1 1 exps length 1 sub {
456: /j set
457: eqs [expsTop exps j get sub] join /eqs set
458: % exps[0]-exps[j] $B$r(B eqs $B$X3JG<$7$F$$$/$@$1(B.
459: % Cone $B$N(B closure $B$r$@$9$N$G(B >= $B$G(B OK.
460: } for
461: } { } ifelse
462: } for
463: /arg1 eqs def
464: ] pop
465: popVariables
466: arg1
467: } def
468:
469: %<
470: % Usage: ww g coneEq
471: % ww $B$O(B [v1 w1 v2 w2 ... ] $B7A<0(B. (v-w $B7A<0(B) w1, w2 $B$O(B univNumber $B$G$b$$$$(B.
472: % g $B$O(B reduced Grobner basis
473: % in(f) $B$,(B monomial $B$G$J$$>l9g$b07$&(B.
474: % in_w(f) = in_ww(f) $B$H$J$k(B weight w $B$NK~$?$9(B
475: % $BITEy<0@)Ls$r5a$a$k(B.
476: % ord_w, init (weightv) $B$rMQ$$$k(B.
477: %>
478: /coneEq {
479: /arg2 set
480: /arg1 set
481: [/g /eqs /gsize /i /j /n /f /exps /m
482: /expsTop /ww /ww2 /iterms
483: ] pushVariables
484: [
485: /g arg2 def % Reduced Grobner basis
486: /ww arg1 def % weight vector. v-w $B7A<0(B
487: ww to_int32 /ww set % univNum $B$,$"$l$P(B int32 $B$KD>$7$F$*$/(B.
488: /ww2 ww weightv def % v-w $B7A<0$r(B $B?t;z$N%Y%/%H%k$K(B. (init $BMQ(B)
489:
1.3 takayama 490: /eqs null def % $BITEy<07O$N78?t(B
1.1 takayama 491: /gsize g length def
492: 0 1 gsize 1 sub {
493: /i set
494: g i get /f set % f $B$O(B i $BHVL\$N(B reduced Grobner basis $B$N85(B
495: [(exponents) f cone.type] gbext /exps set % exps $B$O(B f $B$N(B exponent vector
496: exps length /m set
497: m 1 eq not {
498: /expsTop exps 0 get def % expsTop $B$O(B f $B$N@hF,$N(B exponent vector.
499: /iterms f ww2 init length def % f $B$N(B initial term $B$N9`$N?t(B.
500: % in_ww(f) > f_j $B$H$J$k9`$N=hM}(B.
501: iterms 1 exps length 1 sub {
502: /j set
1.3 takayama 503: expsTop exps j get sub eqs cons /eqs set
1.1 takayama 504: % exps[0]-exps[j] $B$r(B eqs $B$X3JG<$7$F$$$/(B.
505: } for
506: % in_ww(f) = f_j $B$H$J$k9`$N=hM}(B.
507: [(exponents) f ww2 init cone.type] gbext /exps set % exps $B$O(B in(f)
508: 1 1 iterms 1 sub {
509: /j set
1.3 takayama 510: exps j get expsTop sub eqs cons /eqs set
511: expsTop exps j get sub eqs cons /eqs set
1.1 takayama 512: % exps[j]-exps[0], exps[0]-exps[j] $B$r3JG<(B.
513: % $B7k2LE*$K(B (exps[j]-exps[0]).w = 0 $B$H$J$k(B.
514: } for
515: } { } ifelse
516: } for
1.3 takayama 517: eqs listToArray reverse /eqs set
1.1 takayama 518: /arg1 eqs def
519: ] pop
520: popVariables
521: arg1
522: } def
523:
524: %<
525: % Usage: wv g coneEq genPo
526: % polymake $B7A<0$N(B INEQUALITIES $B$r@8@.$9$k(B. coneEq -> genPo $B$HMxMQ(B
527: %>
528: /genPo {
529: /arg1 set
530: [/outConeEq /rr /nn /ii /mm /jj /ee] pushVariables
531: [
532: /outConeEq arg1 def
533: /rr [(INEQUALITIES) nl] cat def % $BJ8;zNs(B rr $B$KB-$7$F$$$/(B.
534: outConeEq length /nn set
535: 0 1 nn 1 sub {
536: /ii set
537: outConeEq ii get /ee set
538: [ rr
539: (0 ) % $BHs$;$$$8MQ$N(B 0 $B$r2C$($k(B.
540: 0 1 ee length 1 sub {
541: /jj set
542: ee jj get toString ( )
543: } for
544: nl
545: ] cat /rr set
546: } for
547: /arg1 rr def
548: ] pop
549: popVariables
550: arg1
551: } def
552:
553: %<
554: % Usage: wv g coneEq genPo2
555: % doPolyamke $B7A<0$N(B INEQUALITIES $B$r@8@.$9$k(B. coneEq -> genPo2 $B$HMxMQ(B
556: % tfb $B7A<0J8;zNs(B.
557: %>
558: /genPo2 {
559: /arg1 set
560: [/outConeEq /rr /nn /ii /mm /jj /ee] pushVariables
561: [
562: /outConeEq arg1 def
563: /rr $polymake.data(polymake.INEQUALITIES([$ def
564: % $BJ8;zNs(B rr $B$KB-$7$F$$$/(B.
565: outConeEq length /nn set
566: 0 1 nn 1 sub {
567: /ii set
568: outConeEq ii get /ee set
569: [ rr
570: ([0,) % $BHs$;$$$8MQ$N(B 0 $B$r2C$($k(B.
571: 0 1 ee length 1 sub {
572: /jj set
573: ee jj get toString
574: jj ee length 1 sub eq { } { (,) } ifelse
575: } for
576: (])
577: ii nn 1 sub eq { } { (,) } ifelse
578: ] cat /rr set
579: } for
580: [rr $]))$ ] cat /rr set
581: /arg1 rr def
582: ] pop
583: popVariables
584: arg1
585: } def
586:
587: /test1 {
588: [(x,y) ring_of_differential_operators 0] define_ring
589: [ (x + y + Dx + Dy).
590: (x ^2 Dx^2 + y^2 Dy^2).
591: (x).
592: ] /gg set
593: gg coneEq1 /ggc set
594: gg message
595: ggc pmat
596:
597: ggc genPo message
598: } def
599:
600: /test2 {
601: [(parse) (dhecart.sm1) pushfile] extension
602: dh.test.p1 /ff set
603: ff 0 get coneEq1 /ggc set
604: ggc message
605: ggc genPo /ss set
606: ss message
607: (Data is in ss) message
608: } def
609:
610:
611: /test3 {
612: % [(parse) (cohom.sm1) pushfile] extension
613: /ww [(Dx) 1 (Dy) 1] def
614: [(x,y) ring_of_differential_operators
615: [ww] weight_vector
616: 0] define_ring
617: [ (x Dx + y Dy -1).
618: (y^2 Dy^2 + 2 + y Dy ).
619: ] /gg set
620: gg {homogenize} map /gg set
621: [gg] groebner 0 get /gg set
622: ww message
623: ww gg coneEq /ggc set
624: gg message
625: ggc pmat
626:
627: ggc genPo message
628: } def
629:
630: %<
631: % Usage: test3b
632: % Grobner cone $B$r7hDj$7$F(B, polymake $BMQ$N%G!<%?$r@8@.$9$k%F%9%H(B.
633: % weight (0,0,1,1) $B$@$H(B max dim cone $B$G$J$$(B.
634: %>
635: /test3b {
636: % [(parse) (cohom.sm1) pushfile] extension
637: /ww [(Dx) 1 (Dy) 2] def
638: [(x,y) ring_of_differential_operators
639: [ww] weight_vector
640: 0] define_ring
641: [ (x Dx + y Dy -1).
642: (y^2 Dy^2 + 2 + y Dy ).
643: ] /gg set
644: gg {homogenize} map /gg set
645: [gg] groebner 0 get /gg set
646: ww message
647: ww gg coneEq /ggc set
648: gg message
649: ggc pmat
650:
651: % ggc genPo /ggs set % INEQ $B$rJ8;zNs7A<0$G(B
652: % ggs message
653: % ggs output
654: % (mv sm1out.txt test3b.poly) system
655: % (Type in polymake-pear.sh test3b.poly FACETS) message
656:
657: ggc genPo2 /ggs set % INEQ $B$rJ8;zNs7A<0(B for doPolymake
658: ggs message
659:
660: } def
661:
662: % commit (dr.sm1): lcm, denominator, ngcd, to_univNum, numerator, reduce
663: % 8/22, changelog-ja $B$^$@(B.
664: % to do : nnormalize_vec, sort_vec --> shell $B$G(B OK.
665: % 8/27, getNode
666:
667: /test4 {
668: $polymake.data(polymake.INEQUALITIES([[0,1,0,0],[0,0,1,0]]))$ /ff set
669: [(FACETS) ff] doPolymake /rr set
670:
671: rr 1 get /rr1 set
672: rr1 getLinearitySubspace pmat
673:
674: } def
675:
676: %<
677: % Usage: vv ineq isInLinearSpace
678: % vv $B$,(B ineq[i] > 0 $B$GDj5A$5$l$kH>6u4V$N$I$l$+$K$O$$$C$F$$$k$J$i(B 0
679: % vv $B$,(B $BA4$F$N(B i $B$K$D$$$F(B ineq[i] = 0 $B$K$O$$$C$F$$$?$i(B 1.
680: %>
681: /isInLinearSpace {
682: /arg2 set
683: /arg1 set
684: [/vv /ineq /ii /rr] pushVariables
685: [
686: /vv arg1 def
687: /ineq arg2 def
688: /rr 1 def
689: {
690: 0 1 ineq length 1 sub {
691: /ii set
692: % vv . ineq[ii] != 0 $B$J$i(B vv $B$O(B linearity space $B$N85$G$J$$(B.
693: vv ineq ii get mul to_univNum isZero {
694: } { /rr 0 def exit} ifelse
695: } for
696: exit
697: } loop
698: /arg1 rr def
699: ] pop
700: popVariables
701: arg1
702: } def
703:
704: %<
705: % Usages: doPolymakeObj getLinearitySubspace
706: % INEQUALITIES $B$H(B VERTICES $B$+$i(B maximal linearity subspace
707: % $B$N@8@.%Y%/%H%k$r5a$a$k(B.
708: % $BNc(B: VERTICES [[0,1,0,0],[0,0,1,0],[0,0,0,-1],[0,0,0,1]]]
709: % $BNc(B: INEQUALITIES [[0,1,0,0],[0,0,1,0]]
710: % $BF~NO$O(B polymake $B$N(B tree (doPolymake $B$N(B 1 get)
711: %>
712: /getLinearitySubspace {
713: /arg1 set
714: [/pdata /vv /ineq /rr /ii] pushVariables
715: [
716: /pdata arg1 def
717: {
718: /rr [ ] def
719: % POINTED $B$J$i(B max lin subspace $B$O(B 0.
720: pdata (POINTED) getNode tag 0 eq { } { exit} ifelse
721:
722: pdata (INEQUALITIES) getNode 2 get 0 get /ineq set
723: pdata (VERTICES) getNode 2 get 0 get /vv set
724: 0 1 vv length 1 sub {
725: /ii set
726: % -vv[ii] $B$,(B ineq $B$rK~$?$9$+D4$Y$k(B.
727: vv ii get ineq isInLinearSpace {
728: rr [vv ii get] join /rr set
729: } { } ifelse
730: } for
731: exit
732: } loop
733: /arg1 rr def
734: ] pop
735: popVariables
736: arg1
737: } def
738:
739: %<
740: % Usages: mm asir_matrix_image
741: % $B@8@.85$h$j@~7A6u4V$N4pDl$rF@$k(B.
742: %>
743: /asir_matrix_image {
744: /arg1 set
745: [/mm /rr] pushVariables
746: [(CurrentRingp)] pushEnv
747: [
748: /mm arg1 def
749: mm to_univNum /mm set
750: oxasir.ccc [ ] eq {
751: (Starting ox_asir server.) message
752: ox_asirConnectMethod
753: } { } ifelse
754: {
755: oxasir.ccc [(matrix_image) mm] asir
756: /rr set
757: rr null_to_zero /rr set
758: exit
759:
760: (asir_matrix_image: not implemented) error exit
761: } loop
762:
763: rr numerator /rr set
764: /arg1 rr def
765: ] pop
766: popEnv
767: popVariables
768: arg1
769: } def
770: [(asir_matrix_image)
771: [(Calling the function matrix_image of asir. It gets a reduced basis of a given matrix.)
772: (Example: [[1 2 3] [2 4 6]] asir_matrix_image)
773: ]] putUsages
774:
775: %<
776: % Usages: mm asir_matrix_kernel
777: % $BD>8r$9$k6u4V$N4pDl(B.
778: %>
779: /asir_matrix_kernel {
780: /arg1 set
781: [/mm /rr] pushVariables
782: [(CurrentRingp)] pushEnv
783: [
784: /mm arg1 def
785: mm to_univNum /mm set
786: oxasir.ccc [ ] eq {
787: (Starting ox_asir server.) message
788: ox_asirConnectMethod
789: } { } ifelse
790: {
791: oxasir.ccc [(matrix_kernel) mm] asir
792: /rr set
793: rr null_to_zero /rr set
794: exit
795:
796: (asir_matrix_image: not implemented) error exit
797: } loop
798: rr 1 get numerator /rr set
799: /arg1 rr def
800: ] pop
801: popEnv
802: popVariables
803: arg1
804: } def
805: [(asir_matrix_kernel)
806: [(Calling the function matrix_kernel of asir.)
807: (It gets a reduced basis of the kernel of a given matrix.)
808: (Example: [[1 2 3] [2 4 6]] asir_matrix_kernel)
809: ]] putUsages
810:
811: %<
812: % Usages: v null_to_zero
813: %>
814: /null_to_zero {
815: /arg1 set
816: [/pp /rr] pushVariables
817: [
818: /pp arg1 def
819: {
820: /rr pp def
821: pp isArray {
822: pp {null_to_zero} map /rr set
823: exit
824: }{ } ifelse
825:
826: pp tag 0 eq {
827: /rr (0).. def
828: exit
829: }{ } ifelse
830: exit
831: } loop
832: /arg1 rr def
833: ] pop
834: popVariables
835: arg1
836: } def
837: [(null_to_zero)
838: [(obj null_to_zero rob)
839: $It translates null to (0)..$
840: ]] putUsages
841:
1.4 takayama 842: %<
843: % Usages: newVector.with-1
844: % (-1).. $B$GKd$a$?%Y%/%H%k$r:n$k(B.
845: %>
846: /newVector.with-1 {
847: newVector { pop (-1).. } map
848: } def
849:
850:
1.1 takayama 851: % [2 0] lcm $B$O(B 0 $B$r$b$I$9$,$$$$$+(B? --> OK.
852:
853: %<
854: % Usages: mm addZeroForPolymake
855: % $B0J2<$NFs$D$N4X?t$O(B, toQuotientSpace $B$K$bMxMQ(B.
856: % Polymake INEQUALITIES $BMQ$K(B 0 $B$r;O$a$KB-$9(B.
857: % $BF~NO$O(B $B%j%9%H$N%j%9%H(B
858: % [[1,2], [3,4],[5,6]] --> [[0,1,2],[0,3,4],[0,5,6]]
859: %>
860: /addZeroForPolymake {
861: /arg1 set
862: [/mm /rr] pushVariables
863: [
864: /mm arg1 def
865: mm to_univNum /mm set
866: mm { [(0)..] 2 1 roll join } map /mm set
867: /arg1 mm def
868: ] pop
869: popVariables
870: arg1
871: } def
872:
873: %<
874: % Usages: mm cone.appendZero
875: %>
876: /cone.appendZero {
877: /arg1 set
878: [/mm /rr] pushVariables
879: [
880: /mm arg1 def
881: mm to_univNum /mm set
882: mm { [(0)..] join } map /mm set
883: /arg1 mm def
884: ] pop
885: popVariables
886: arg1
887: } def
888:
889: %<
890: % Usages: mm removeFirstFromPolymake
891: % $B;O$a$N(B 0 $B$r<h$j=|$/(B.
892: % $BF~NO$O(B $B%j%9%H$N%j%9%H(B
893: % [[0,1,2],[0,3,4],[0,5,6]] ---> [[1,2], [3,4],[5,6]]
894: %>
895: /removeFirstFromPolymake {
896: /arg1 set
897: [/mm /rr] pushVariables
898: [
899: /mm arg1 def
900: mm to_univNum /mm set
901: mm {rest} map /mm set
902: /arg1 mm def
903: ] pop
904: popVariables
905: arg1
906: } def
907:
908: %<
909: % Usages: mm genUnit
910: % [1,0,0,...] $B$r2C$($k$?$a$K@8@.(B.
911: % [[0,1,2], [0,3,4],[0,5,6]]--> [1,0,0]
912: %>
913: /genUnit {
914: /arg1 set
915: [/mm /rr /i] pushVariables
916: [
917: /mm arg1 def
918: mm 0 get length newVector /rr set
919: rr null_to_zero /rr set
920: rr 0 (1).. put
921: /arg1 rr def
922: ] pop
923: popVariables
924: arg1
925: } def
926:
927: %<
928: % Usages: mm genUnitMatrix
929: % [[0,1,2], [0,3,4],[0,5,6]]--> [[1,0,0],[0,1,0],[0,0,1]]
930: %>
931: /genUnitMatrix {
932: /arg1 set
933: [/mm /rr /nn /i] pushVariables
934: [
935: /mm arg1 def
936: mm 0 get length /nn set
937: [
938: 0 1 nn 1 sub {
939: /i set
940: nn newVector null_to_zero /mm set
941: mm i (1).. put
942: mm
943: } for
944: ]
945: /arg1 set
946: ] pop
947: popVariables
948: arg1
949: } def
950:
951: %<
952: %%note: 2004, 8/29 (sun)
953: % toQuotientSpace : Linearity space $B$G3d$k(B.
954: % Usages: ineq mm toQuotientSpace
955: % $BF~NO$O(B coneEq $B$N=PNO(B ineq
956: % $B$*$h$S(B doPolymake --> getLinearitySubspace ==> L
957: % [L,[1,0,0,...]] asir_matrix_kernel removeFirstFromPolymake $B$GF@$i$l$?(B mm
958: % $B=PNO$+$i(B 0 $B%Y%/%H%k$O:o=|(B.
959: % $B=PNO$b(B coneEq $B7A<0(B. $BFC$K(B polymake $BMQ$K(B 0 $B$r2C$($k$N$,I,MW(B.
960: % ref: getUnit, removeFirstFromPolymake, addZeroForPolymake,
961: % asir_matrix_kernel, getLinearitySubspace
962: %>
963: /toQuotientSpace {
964: /arg2 set
965: /arg1 set
966: [/ineq /mm /rr] pushVariables
967: [
968: /ineq arg1 def
969: /mm arg2 def
970:
971: ineq mm transpose mul /rr set
972:
973: /arg1 rr def
974: ] pop
975: popVariables
976: arg1
977: } def
978:
979: /test5.data
980: $polymake.data(polymake.INEQUALITIES([[0,1,-1,1,-1,0],[0,0,-1,0,-1,2],[0,0,-1,0,-1,2],[0,0,-2,0,-2,4],[0,-1,0,-1,0,2],[0,-2,0,-2,0,4]]),polymake.VERTICES([[0,0,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,0,-1,0,0],[0,-1,0,1,0,0],[0,0,1,0,-1,0],[0,0,-1,0,1,0],[0,-2,-2,0,0,-1],[0,2,2,0,0,1]]),polymake.FACETS([[0,1,-1,1,-1,0],[0,-1,0,-1,0,2]]),polymake.AFFINE_HULL(),polymake.FEASIBLE(),polymake.NOT__POINTED(),polymake.FAR_FACE([polymake._set([0,1,2,3,4,5,6,7])]),polymake.VERTICES_IN_INEQUALITIES([polymake._set([1,2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([0,2,3,4,5,6,7]),polymake._set([0,2,3,4,5,6,7])]),polymake.DIM([[5]]),polymake.AMBIENT_DIM([[5]]))$
981: def
982: %<
983: % Usages: test5
984: %% getConeInfo $B$rJQ99$9$l$P(B polymake $B$r8F$P$:$K%F%9%H$G$-$k(B.
985: %>
986: /test5 {
987: % test3b $B$h$j(B
988: /ww [(Dx) 1 (Dy) 2] def
989: % /ww [(x) 1 (y) -2 (Dx) 3 (Dy) 6] def
990: [(x,y) ring_of_differential_operators
991: [ww] weight_vector
992: 0] define_ring
993: [ (x Dx + y Dy -1).
994: (y^2 Dy^2 + 2 + y Dy ).
995: ] /gg set
996: gg {homogenize} map /gg set
997: [(AutoReduce) 1] system_variable
998: [gg] groebner 0 get /gg set
999: ww message
1000:
1001: ww gg coneEq getConeInfo /rr set
1002: (Type in rr 0 get :: ) message
1003: } def
1004: %[5, [[1,0,1,0,-2],[0,1,0,1,-2]], $NOT__POINTED$ ]
1005: % $B$3$N>l9g$O(B 2 $B<!85$^$GMn$9$H(B pointed cone $B$K$J$k(B.
1006: % coneEq mmc transpose $B$r$b$H$K(B FACETS $B$r7W;;$9$l$P$h$$(B.
1007:
1008: %<
1009: % Usage: ceq getConeInfo
1010: % vw $B$O(B [v1 w1 v2 w2 ... ] $B7A<0(B. (v-w $B7A<0(B) w1, w2 $B$O(B univNumber $B$G$b$$$$(B.
1011: % g $B$O(B reduced Grobner basis $B$H$7$F(B vw g coneEq $B$r7W;;(B. $B$3$l$r(B getConeInfo $B$X(B.
1012: % Grobner cone $B$N(B $B<!85(B cdim (DIM), $BJd6u4V(B (linearity space ) $B$X$N9TNs(B mmc
1013: % linearity space $B<+BN(B, pointed or not__pointed
1014: % $B$D$^$j(B [cdim, L', L, PointedQ]
1015: % $B$r7W;;$7$FLa$9(B. (polymake $B7A<0$NM>J,$JItJ,$J$7(B)
1016: % polymake $BI,MW(B.
1017: % ref: coneEq
1018: % Global:
1019: % cone.getConeInfo.rr0, cone.getConeInfo.rr1 $B$K(B polymake $B$h$j$NLa$jCM$,$O$$$k(B.
1020: %>
1021: /getConeInfo {
1022: /arg1 set
1023: [/ww /g /ceq /ceq2 /cdim /mmc /mmL /rr /ineq /ppt] pushVariables
1024: [
1025: /ceq arg1 def
1026: ceq pruneZeroVector /ceq set
1027: ceq genPo2 /ceq2 set
1028: % ceq2 $B$O(B polymake.data(polymake.INEQUALITIES(...)) $B7A<0(B
1029: % polymake $B$G(B ceq2 $B$N<!85$N7W;;(B.
1030: /getConeInfo.ceq ceq def /getConeInfo.ceq2 ceq2 def
1031:
1032: cone.debug { (Calling polymake DIM.) message } { } ifelse
1033: [(DIM) ceq2] doPolymake 1 get /rr set
1034: cone.debug {(Done.) message } { } ifelse
1035: % test5 $B$K$O<!$N%3%a%s%H$H$j$5$k(B. $B>e$N9T$r%3%a%s%H%"%&%H(B.
1036: % test5.data tfbToTree /rr set
1037: /cone.getConeInfo.rr0 rr def
1038:
1039: rr (DIM) getNode /cdim set
1040: cdim 2 get 0 get 0 get 0 get to_univNum /cdim set
1041: % polymake $B$N(B DIM $B$O0l$D>.$5$$$N$G(B 1 $BB-$9(B.
1042: cdim (1).. add /cdim set
1043:
1044: rr (FACETS) getNode tag 0 eq {
1045: % FACETS $B$r;}$C$F$$$J$$$J$i:FEY7W;;$9$k(B.
1046: % POINTED, NOT__POINTED $B$bF@$i$l$k(B
1047: cone.debug { (Calling polymake FACETS.) message } { } ifelse
1048: [(FACETS) ceq2] doPolymake 1 get /rr set
1049: cone.debug { (Done.) message } { } ifelse
1050: } { } ifelse
1051:
1052: rr (VERTICES) getNode tag 0 eq {
1053: (internal error: VERTICES is not found.) error
1054: } { } ifelse
1055:
1056: /cone.getConeInfo.rr1 rr def
1057:
1058: rr (NOT__POINTED) getNode tag 0 eq {
1059: % cone $B$,(B pointed $B$N;~$O(B mmc $B$OC10L9TNs(B. genUnitMatrix $B$r;H$&(B.
1060: % VERTICES $B$h$j0l$D>.$5$$%5%$%:(B.
1061: /mmc
1062: [ rr (VERTICES) getNode 2 get 0 get 0 get rest]
1063: genUnitMatrix
1064: def
1065: /mmL [ ] def
1066: /ppt (POINTED) def
1067: } {
1068: % pointed $B$G$J$$>l9g(B,
1069: % cone $B$N@~7AItJ,6u4V$r7W;;(B.
1070: rr getLinearitySubspace /mmL set
1071: [mmL genUnit] mmL join /mmc set % [1,0,0,...] $B$rB-$9(B.
1072: mmc asir_matrix_kernel /mmc set % $BJd6u4V(B
1073: mmc removeFirstFromPolymake /mmc set % $B$R$H$D>.$5$$%5%$%:$K(B.
1074:
1075: [mmL genUnit] mmL join asir_matrix_image
1076: removeFirstFromPolymake /mmL set
1077: mmL asir_matrix_image /mmL set % Linearity space $B$r5a$a$k(B. rm 0vector
1078: /ppt (NOT__POINTED) def
1079: } ifelse
1080: /arg1 [[cdim mmc mmL ppt] rr] def
1081: ] pop
1082: popVariables
1083: arg1
1084: } def
1085:
1086:
1087: /test.put {
1088: /dog [(dog) [[(legs) 4] ] [1 2 3 ]] [(class) (tree)] dc def
1089: /man [(man) [[(legs) 2] ] [1 2 3 ]] [(class) (tree)] dc def
1090: /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def
1091: /fan [ma 1 copy] def
1092: ma (dog) getNode /dd set
1093: dd 2 get /dd2 set
1094: dd2 1 0 put
1095: ma message
1096:
1097: fan message
1098: } def
1099:
1100: /test6.data
1101: $polymake.data(polymake.INEQUALITIES([[0,1,-1,1,-1,0],[0,0,-1,0,-1,2],[0,0,-1,0,-1,2],[0,0,-2,0,-2,4],[0,-1,0,-1,0,2],[0,-2,0,-2,0,4]]),polymake.VERTICES([[0,0,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,0,-1,0,0],[0,-1,0,1,0,0],[0,0,1,0,-1,0],[0,0,-1,0,1,0],[0,-2,-2,0,0,-1],[0,2,2,0,0,1]]),polymake.FACETS([[0,1,-1,1,-1,0],[0,-1,0,-1,0,2]]),polymake.AFFINE_HULL(),polymake.FEASIBLE(),polymake.NOT__POINTED(),polymake.FAR_FACE([polymake._set([0,1,2,3,4,5,6,7])]),polymake.VERTICES_IN_INEQUALITIES([polymake._set([1,2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([2,3,4,5,6,7]),polymake._set([0,2,3,4,5,6,7]),polymake._set([0,2,3,4,5,6,7])]))$
1102: def
1103: % tfbToTree
1104:
1105: /arrayToTree { [(class) (tree)] dc } def
1106:
1107: %<
1108: % polymake $B$h$jF@$i$l$?(B TreeObject $B$+$i(B TreeObject cone $B$r@8@.$9$k(B.
1109: % Usages: test6.data tfbToTree newCone $B$GF0:n%F%9%H(B
1110: %>
1111: /test6 {
1112: test6.data tfbToTree /rr set
1113: rr newCone /rr2 set
1114: } def
1115:
1116: %<
1117: % Usages: doPolymakeObj newCone
1118: %>
1119: /newCone {
1120: /arg1 set
1121: [/polydata /cone /facets /vertices /flipped /ineq
1122: /facetsv /rr] pushVariables
1123: [
1124: /polydata arg1 def
1125: polydata (FACETS) getNode tag 0 eq {
1126: (newCone : no FACETS data.) error
1127: } { } ifelse
1128: % facets $B$OM-M}?t$N>l9g@55,2=$9$k(B. data/test11 $B$G(B $BM-M}?t$G$k(B.
1129: polydata (FACETS) getNode 2 get 0 get to_univNum
1130: { nnormalize_vec} map /facets set
1131: [[ ] ] facets join shell rest removeFirstFromPolymake /facets set
1.2 takayama 1132: facets length 0 eq
1133: {(Internal error. Facet data is not obtained. See OpenXM_tmp.) error} { } ifelse
1.1 takayama 1134: % vertices $B$O(B cone $B$N>e$K$"$k$N$G@0?tG\(B OK. $B@55,$+$9$k(B.
1135: polydata (VERTICES) getNode 2 get 0 get to_univNum
1136: { nnormalize_vec} map /vertices set
1137: [[ ] ] vertices join shell rest removeFirstFromPolymake /vertices set
1138: % inequalities $B$OM-M}?t$N>l9g@55,2=$9$k(B.
1139: polydata (INEQUALITIES) getNode 2 get 0 get to_univNum
1140: { nnormalize_vec } map /ineq set
1141: [[ ] ] ineq join shell rest removeFirstFromPolymake /ineq set
1142:
1.4 takayama 1143: % nextcid, nextfid $B$r2C$($k(B. nextcid $B$O(B nextConeId $B$NN,(B. $B$H$J$j$N(B cone $BHV9f(B.
1144: % nextfid $B$O(B nextFacetId $B$NN,(B. $B$H$J$j$N(B cone $B$N(B facet
1145: % $BHV9f(B.
1.1 takayama 1146: [(cone) [ ]
1147: [
1148: [(facets) [ ] facets] arrayToTree
1149: [(flipped) [ ] facets length newVector null_to_zero] arrayToTree
1150: [(facetsv) [ ] facets vertices newCone_facetsv] arrayToTree
1.4 takayama 1151: [(nextcid) [ ] facets length newVector.with-1 ] arrayToTree
1152: [(nextfid) [ ] facets length newVector.with-1 ] arrayToTree
1.1 takayama 1153: [(vertices) [ ] vertices] arrayToTree
1154: [(inequalities) [ ] ineq] arrayToTree
1155: ]
1156: ] arrayToTree /cone set
1157: /arg1 cone def
1158: ] pop
1159: popVariables
1160: arg1
1161: } def
1162:
1163: %<
1164: % Usages: newCone_facetv
1165: % facet vertices newCone_facetv
1166: % facet $B$K$N$C$F$$$k(B vertices $B$r$9$Y$FNs5s(B.
1167: %>
1168: /newCone_facetv {
1169: /arg2 set
1170: /arg1 set
1171: [/facet /vertices] pushVariables
1172: [
1173: /facet arg1 def /vertices arg2 def
1174: [
1175: 0 1 vertices length 1 sub {
1176: /ii set
1177: facet vertices ii get mul isZero
1178: { vertices ii get } { } ifelse
1179: } for
1180: ]
1181: /arg1 set
1182: ] pop
1183: popVariables
1184: arg1
1185: } def
1186:
1187: %<
1188: % Usages: newCone_facetsv
1189: % facets vertices newCone_facetv
1190: % facets $B$K$N$C$F$$$k(B vertices $B$r$9$Y$FNs5s(B. $B%j%9%H$r:n$k(B.
1191: %>
1192: /newCone_facetsv {
1193: /arg2 set
1194: /arg1 set
1195: [/facets /vertices] pushVariables
1196: [
1197: /facets arg1 def /vertices arg2 def
1198: facets { vertices newCone_facetv } map
1199: /arg1 set
1200: ] pop
1201: popVariables
1202: arg1
1203: } def
1204:
1205: %<
1.2 takayama 1206: % Usages: [gb weight] newConeGB
1207: % gb $B$H(B weight $B$r(B tree $B7A<0$K$7$F3JG<$9$k(B.
1208: %>
1209: /newConeGB {
1210: /arg1 set
1211: [/gbdata /gg /ww /rr] pushVariables
1212: [
1213: /gbdata arg1 def
1214: % gb
1215: gbdata 0 get /gg set
1216: % weight
1217: gbdata 1 get /ww set
1218: %
1219: [(coneGB) [ ]
1220: [
1221: [(grobnerBasis) [ ] gg] arrayToTree
1222: [(weight) [ ] [ww]] arrayToTree
1223: [(initial) [ ] gg { ww 2 get weightv init } map ] arrayToTree
1224: ]
1225: ] arrayToTree /rr set
1226: /arg1 rr def
1227: ] pop
1228: popVariables
1229: arg1
1230: } def
1231:
1232: %<
1.1 takayama 1233: % Usages: cone_random
1234: %>
1235: /cone_random.start (2).. def
1236: /cone_random {
1237: [(tdiv_qr)
1238: cone_random.start (1103515245).. mul
1239: (12345).. add
1240:
1241: (2147483646)..
1242: ] mpzext 1 get /cone_random.start set
1243: cone_random.start
1244: } def
1245:
1246: /cone_random.limit 40 def
1247: /cone_random_vec {
1248: /arg1 set
1249: [/nn /rr] pushVariables
1250: [
1251: /nn arg1 def
1252: [
1253: 0 1 nn 1 sub {
1254: pop
1255: [(tdiv_qr) cone_random cone_random.limit] mpzext 1 get
1256: } for
1257: ] /arg1 set
1258: ] pop
1259: popVariables
1260: arg1
1261: } def
1262:
1263: %<
1264: % Usages: getNewRandomWeight
1265: %% max dim $B$N(B cone $B$r@8@.$9$k$?$a$K(B, random $B$J(B weight $B$r@8@.$9$k(B.
1266: %% h, H $B$N=hM}$bI,MW(B.
1267: %% $B@)Ls>r7o(B u+v >= 2t $B$r$_$?$9(B weight $B$,I,MW(B. $B$3$l$r$I$N$h$&$K:n$k$N$+(B?
1268: %>
1269: /getNewRandomWeight {
1270: /arg1 set
1271: [/vv /vvd /rr] pushVariables
1272: [
1273: /vv arg1 def
1274: vv { (D) 2 1 roll 2 cat_n } map /vvd set
1275: ] pop
1276: popVariables
1277: arg1
1278: } def
1279:
1280: % test7 : univNum $B$N(B weight $B$,@5$7$/G'<1$5$l$k$+$N%F%9%H(B
1281: % aux-cone.sm1
1282:
1283: %<
1284: % Usages: n d coneEqForSmallFan.2 (cone.type 2 $B@lMQ(B: x,y,Dx,Dy,h)
1285: % n $BJQ?t$N?t(B, d zero $B$K$7$J$$JQ?t$N?t(B. d $B$O(B max dim cone $B$N<!85$H$J$k(B.
1286: % $B$O$8$a$+$i(B d $B8D$NJQ?t(B.
1287: % 4, 2 , s,t,x,y $B$J$i(B weight $B$O(B s,t,Ds,Dt $B$N$_(B.
1288: % u_i + v_i >= 0 , u_i = v_i = 0.
1289: % homog $BJQ?t$N>r7o(B u_i+v_i >= t, i.e, -t >= 0 $B$bF~$l$k(B.
1290: % coneEq $B$N7k2L$H(B coneEqForSmallFan.2 $B$N7k2L$r(B join $B$7$F(B
1291: % getConeInfo or newCone
1292: % note-cone.sm1 2004.8.31 $B$r8+$h(B. w_ineq $B$"$?$j(B.
1293: % cone.local $B$,@_Dj$5$l$F$$$k$H(B u_i <= 0 $B$b>r7o$KF~$k(B.
1294: %>
1295: /coneEqForSmallFan.2 {
1296: /arg2 set
1297: /arg1 set
1298: [/n /d /nn /dd /ii /tt] pushVariables
1299: [
1300: /n arg1 def
1301: /d arg2 def
1302: n to_int32 /n set
1303: d to_int32 /d set
1304: /dd n d add def
1305: /nn n n add def
1306:
1307: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i = 0
1308: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1309: % -t >= 0
1310: [
1311: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1312: d 1 n 1 sub {
1313: /ii set
1314: % [ 0,0, ..., 0,1,0,... ; 0] $B$r@8@.(B
1315: nn 1 add newVector null_to_zero /tt set
1316: tt ii (1).. put
1317: tt
1318: % [ 0,0, ..., 0,-1,0,... ; 0] $B$r@8@.(B
1319: nn 1 add newVector null_to_zero /tt set
1320: tt ii (-1).. put
1321: tt
1322: } for
1323: dd 1 nn 1 sub {
1324: /ii set
1325: nn 1 add newVector null_to_zero /tt set
1326: tt ii (1).. put
1327: tt
1328: nn 1 add newVector null_to_zero /tt set
1329: tt ii (-1).. put
1330: tt
1331: } for
1332:
1333: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i = 0
1334: 0 1 d 1 sub {
1335: /ii set
1336: nn 1 add newVector null_to_zero /tt set
1337: tt ii (1).. put
1338: tt ii n add (1).. put
1339: tt
1340:
1341: nn 1 add newVector null_to_zero /tt set
1342: tt ii (-1).. put
1343: tt ii n add (-1).. put
1344: tt
1345:
1346: } for
1347:
1348: % -t >= 0
1349: cone.h0 {
1350: % t = 0
1351: nn 1 add newVector null_to_zero /tt set
1352: tt nn (1).. put
1353: tt
1354: nn 1 add newVector null_to_zero /tt set
1355: tt nn (-1).. put
1356: tt
1357: }
1358: {
1359: % -t >= 0
1360: nn 1 add newVector null_to_zero /tt set
1361: tt nn (-1).. put
1362: tt
1363: } ifelse
1364:
1365: % cone.local $B$,(B 1 $B$N;~(B
1366: % 0 ~ d-1 $B$G$O(B -u_i >= 0
1367: cone.local {
1368: 0 1 d 1 sub {
1369: /ii set
1370: nn 1 add newVector null_to_zero /tt set
1371: tt ii (-1).. put
1372: tt
1373: } for
1374: } { } ifelse
1375: ] /rr set
1376: /arg1 rr to_univNum def
1377: ] pop
1378: popVariables
1379: arg1
1380: } def
1381:
1382: %<
1383: % Usages: n d coneEqForSmallFan.1 (cone.type 1 $B@lMQ(B: x,y,Dx,Dy,h,H)
1384: % cone.type 2 $B$G$O(B x,y,Dx,Dy,h
1385: % coneEqForSmallFan.2 $B$N7k2L$rMQ$$$F@8@.(B.
1386: % H $B$N>r7o$r2C$($k(B.
1387: %>
1388: /coneEqForSmallFan.1 {
1389: /arg2 set
1390: /arg1 set
1391: [/n /d /i /j /rr /tt /tt2] pushVariables
1392: [
1393: /n arg1 def /d arg2 def
1394: n d coneEqForSmallFan.2 /rr set
1395: rr cone.appendZero /rr set
1396: % H $BMQ$N(B 0 $B$r2C$($k(B.
1397: % $B$H$j$"$($:(B t' = 0 $B$G$-$a$&$A(B.
1398: cone.h0 { } { (cone.h0 = 0 has not yet been implemented.) error } ifelse
1399: n 2 mul 2 add newVector null_to_zero /tt set
1400: tt n 2 mul 2 add 1 sub (-1).. put
1401: n 2 mul 2 add newVector null_to_zero /tt2 set
1402: tt2 n 2 mul 2 add 1 sub (1).. put
1403: rr [tt tt2] join /rr set
1404: /arg1 rr to_univNum def
1405: ] pop
1406: popVariables
1407: arg1
1408: } def
1409:
1410: %<
1411: % Usages: vv ineq toQuotientCone
1412: % weight space $B$N(B $B%Q%i%a!<%?$D$1$N$?$a$K;H$&(B.
1413: % cone.V $B$r5a$a$?$$(B. vv $B$O(B doPolymakeObj (VERTICES) getNode 2 get 0 get $B$GF@$k(B.
1414: % vertices $B$N(B non-negative combination $B$,(B cone.
1415: % vertice cone.w_ineq isInLinearSubspace $B$J$i<h$j=|$/(B.
1416: % $B$D$^$j(B vertice*cone.w_ineq = 0 $B$J$i<h$j=|$/(B.
1417: %
1418: % $B$3$l$G@5$7$$(B? $B>ZL@$O(B? $B$^$@ESCf(B. cone.W $B$r5a$a$k$N$K;H$&(B. (BUG)
1419: % cone.w_cone 1 get (VERTICES) getNode :: $B$HHf3S$;$h(B.
1420: % $B$3$N4X?t$r8F$s$G(B cone.W $B$r:n$k$N$OITMW$+$b(B.
1421: %
1422: % Example: cf. parametrizeSmallFan
1423: % 4 2 coneEqForSmallFan.2 /cone.w_ineq set cone.w_ineq getConeInfo /rr set
1424: % rr 1 get (VERTICES) getNode 2 get 0 get removeFirstFromPolymake /vv set
1425: % vv cone.w_ineq toQuotientCone pmat
1426: %>
1427: /toQuotientCone {
1428: /arg2 set /arg1 set
1429: [/vv /ineq /rr] pushVariables
1430: [
1431: /vv arg1 def /ineq arg2 def
1432: vv {
1433: dup
1434: ineq isInLinearSpace 1 eq { pop }
1435: { } ifelse
1436: } map /arg1 set
1437: ] pop
1438: popVariables
1439: arg1
1440: } def
1441:
1442: %<
1443: % Usages: n d parametrizeSmallFan
1444: % n : x $BJQ?t$N?t(B.
1445: % d : 0 $B$K$7$J$$(B weight $B$N?t(B.
1446: % $B<!$NBg0hJQ?t$b@_Dj$5$l$k(B.
1447: % cone.W : weight $B$r%Q%i%a!<%?$E$1$9$k%Y%/%H%k$NAH(B.
1448: % cone.Wpos : i $B$,(B 0 ~ Wpos-1 $B$NHO0O$N$H$-(B V[i] $B$X$O(B N $B$N85$r3]$1;;$7$F$h$$(B,
1449: % i $B$,(B Wpos ~ $B$NHO0O$N$H$-(B V[i] $B$X$O(B Z $B$N85$r3]$1;;$7$F$h$$(B.
1450: % cone.w_ineq : weight space $B$NITEy<0@)Ls(B. $B0J8e$N7W;;$G>o$KIU2C$9$k(B.
1451: % cone.w_cone : w_ineq $B$r(B polymake $B$G(B getConeInfo $B$7$?7k2L(B.
1452: % Example: /cone.local 1 def ; 4 2 parametrizeSmallFan pmat
1453: % Example: /cone.local 0 def ; 4 2 parametrizeSmallFan pmat
1454: %>
1455: /parametrizeSmallFan {
1456: /arg2 set /arg1 set
1457: [/n /d /vv /coneray] pushVariables
1458: [
1459: /n arg1 def /d arg2 def
1460: {
1461: cone.type 1 eq {
1462: n d coneEqForSmallFan.1 /cone.w_ineq set
1463: exit
1464: } { } ifelse
1465: cone.type 2 eq {
1466: n d coneEqForSmallFan.2 /cone.w_ineq set
1467: exit
1468: } { } ifelse
1469: (This cone.type has not yet been implemented.) error
1470: } loop
1471: cone.w_ineq getConeInfo /cone.w_cone set
1472: cone.w_cone 1 get (VERTICES) getNode 2 get 0 get
1473: removeFirstFromPolymake /vv set
1474:
1475: vv cone.w_ineq toQuotientCone /coneray set
1476: coneray length /cone.Wpos set
1477:
1478: coneray cone.w_cone 0 get 2 get join /cone.W set
1479: /arg1 cone.W def
1480: ] pop
1481: popVariables
1482: arg1
1483: } def
1484:
1485: %<
1486: % Usages: n d coneEqForTotalFan.2 (cone.type 2 $B@lMQ(B: x,y,Dx,Dy,h)
1487: % n $BJQ?t$N?t(B,
1488: % d 0 $B$K$7$J$$JQ?t(B.
1489: % u_i + v_i >= 0 ,
1490: % homog $BJQ?t$N>r7o(B u_i+v_i >= 0, t = 0 $B$bF~$l$k(B.
1491: % coneEq $B$N7k2L$H(B coneEqForSmallFan.2 $B$N7k2L$r(B join $B$7$F(B
1492: % getConeInfo or newCone
1493: % cone.local $B$,@_Dj$5$l$F$$$k$H(B u_i <= 0 $B$b>r7o$KF~$k(B.
1494: %>
1495: /coneEqForTotalFan.2 {
1496: /arg2 set
1497: /arg1 set
1498: [/n /nn /dd /ii /tt] pushVariables
1499: [
1500: /n arg1 def
1501: /d arg2 def
1502: n to_int32 /n set
1503: d to_int32 /d set
1504: /nn n n add def
1505: /dd n d add def
1506:
1507: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i >= 0
1508: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1509: % t = 0
1510: [
1511: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1512: d 1 n 1 sub {
1513: /ii set
1514: % [ 0,0, ..., 0,1,0,... ; 0] $B$r@8@.(B
1515: nn 1 add newVector null_to_zero /tt set
1516: tt ii (1).. put
1517: tt
1518: % [ 0,0, ..., 0,-1,0,... ; 0] $B$r@8@.(B
1519: nn 1 add newVector null_to_zero /tt set
1520: tt ii (-1).. put
1521: tt
1522: } for
1523: dd 1 nn 1 sub {
1524: /ii set
1525: nn 1 add newVector null_to_zero /tt set
1526: tt ii (1).. put
1527: tt
1528: nn 1 add newVector null_to_zero /tt set
1529: tt ii (-1).. put
1530: tt
1531: } for
1532:
1533: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i >= 0
1534: 0 1 d 1 sub {
1535: /ii set
1536: nn 1 add newVector null_to_zero /tt set
1537: tt ii (1).. put
1538: tt ii n add (1).. put
1539: tt
1540:
1541: } for
1542:
1543: % t = 0
1544: cone.h0 {
1545: % t = 0
1546: nn 1 add newVector null_to_zero /tt set
1547: tt nn (1).. put
1548: tt
1549: nn 1 add newVector null_to_zero /tt set
1550: tt nn (-1).. put
1551: tt
1552: }
1553: {
1554: (coneForTotalFan.2. Not implemented.) error
1555: } ifelse
1556:
1557: % cone.local $B$,(B 1 $B$N;~(B
1558: % 0 ~ d-1 $B$G$O(B -u_i >= 0
1559: cone.local {
1560: 0 1 d 1 sub {
1561: /ii set
1562: nn 1 add newVector null_to_zero /tt set
1563: tt ii (-1).. put
1564: tt
1565: } for
1566: } { } ifelse
1567: ] /rr set
1568: /arg1 rr to_univNum def
1569: ] pop
1570: popVariables
1571: arg1
1572: } def
1573:
1574: %<
1575: % Usages: n d parametrizeTotalFan
1576: % n : x $BJQ?t$N?t(B.
1577: % d : 0 $B$K$7$J$$?t(B.
1578: % $B<!$NBg0hJQ?t$b@_Dj$5$l$k(B.
1579: % cone.W : weight $B$r%Q%i%a!<%?$E$1$9$k%Y%/%H%k$NAH(B.
1580: % cone.Wpos : i $B$,(B 0 ~ Wpos-1 $B$NHO0O$N$H$-(B V[i] $B$X$O(B N $B$N85$r3]$1;;$7$F$h$$(B,
1581: % i $B$,(B Wpos ~ $B$NHO0O$N$H$-(B V[i] $B$X$O(B Z $B$N85$r3]$1;;$7$F$h$$(B.
1582: % cone.w_ineq : weight space $B$NITEy<0@)Ls(B. $B0J8e$N7W;;$G>o$KIU2C$9$k(B.
1583: % cone.w_ineq $B$r(B getConeInfo $B$7$?7k2L$O(B cone.w_cone
1584: % Example: /cone.local 1 def ; 3 parametrizeSmallFan pmat
1585: % Example: /cone.local 0 def ; 3 parametrizeSmallFan pmat
1586: % local $B$,(B 1 $B$@$H(B u_i <= 0 $B$K$J$k(B.
1587: %>
1588: /parametrizeTotalFan {
1589: /arg2 set
1590: /arg1 set
1591: [/n /d /vv /coneray] pushVariables
1592: [
1593: /n arg1 def /d arg2 def
1594: {
1595: cone.type 2 eq { n d coneEqForTotalFan.2 /cone.w_ineq set exit}
1596: { } ifelse
1597: (This cone.type has not yet been implemented.) error
1598: } loop
1599: cone.w_ineq getConeInfo /cone.w_cone set
1600: cone.w_cone 1 get (VERTICES) getNode 2 get 0 get
1601: removeFirstFromPolymake /vv set
1602:
1603: vv cone.w_ineq toQuotientCone /coneray set
1604: coneray length /cone.Wpos set
1605:
1606: coneray cone.w_cone 0 get 2 get join /cone.W set
1607: /arg1 cone.W def
1608: ] pop
1609: popVariables
1610: arg1
1611: } def
1612:
1613: %<
1614: % Usages: vlist wlist cone_wtowv
1615: % [x y Dx Dy h] [-1 0 1 0 0] ==> [(x) -1 (Dx) 1] $B$r:n$k(B.
1616: %>
1617: /cone_wtowv {
1618: /arg2 set /arg1 set
1619: [/vlist /wlist /ii] pushVariables
1620: [
1621: /vlist arg1 def
1622: /wlist arg2 def
1623: wlist length vlist length eq {
1624: } { (cone_wtowv: length of the argument must be the same.) error} ifelse
1625:
1626: wlist to_int32 /wlist set
1627: [
1628: 0 1 wlist length 1 sub {
1629: /ii set
1630: wlist ii get 0 eq { }
1631: { vlist ii get wlist ii get } ifelse
1632: } for
1633: ] /arg1 set
1634: ] pop
1635: popVariables
1636: arg1
1637: } def
1638:
1639: %<
1640: % Usages: pruneZeroVector
1641: % genPo, getConeInfo $BEy$NA0$K;H$&(B. 0 $B%Y%/%H%k$O0UL#$N$J$$@)Ls$J$N$G=|$/(B.
1.2 takayama 1642: % $BF1$8@)Ls>r7o$b$N$>$/(B. polymake FACET $B$,@5$7$/F0$+$J$$>l9g$,$"$k$N$G(B.
1643: % cf. pear/OpenXM_tmp/x3y2.poly, x^3+y^2, x^2+y^3 data/test15.sm1
1.1 takayama 1644: %>
1645: /pruneZeroVector {
1646: /arg1 set
1647: [/mm /ii /jj /tt] pushVariables
1648: [
1649: /mm arg1 def
1650: mm to_univNum /mm set
1.2 takayama 1651: [ [ ] ] mm join shell rest uniq /mm set
1.1 takayama 1652: [
1653: 0 1 mm length 1 sub {
1654: /ii set
1655: mm ii get /tt set
1656: {
1657: 0 1 tt length 1 sub {
1658: /jj set
1659: tt jj get (0).. eq { }
1660: { tt exit } ifelse
1661: } for
1662: exit
1663: } loop
1664: } for
1665: ] /arg1 set
1666: ] pop
1667: arg1
1668: } def
1669:
1670: %<
1671: % Usages: a projectIneq v , dim(a) = n, dim(v) = d
1672: % a*cone.Wt*cone.Lpt
1673: %>
1674: /projectIneq {
1675: cone.Wt mul cone.Lpt mul
1676: } def
1677:
1678: %<
1679: % Usages: v liftWeight [w vw], dim(v) = d, dim(w) = n, vw : vw $B7A<0$N(B weight
1680: % v*cone.Lp*cone.W cone.vlist w cone_wtowv
1681: %>
1682: /liftWeight {
1683: /arg1 set
1684: [/v /w /vw] pushVariables
1685: [
1686: /v arg1 def
1687: v cone.Lp mul cone.W mul /w set
1688: [w cone.vlist w cone_wtowv] /arg1 set
1689: ] pop
1690: popVariables
1691: arg1
1692: } def
1693:
1694: %<
1695: % Usage: m isZero
1696: % dr.sm1 $B$X0\$9(B.
1697: %>
1698: /isZero {
1699: /arg1 set
1700: [/mm /ans /ii] pushVariables
1701: [
1702: /mm arg1 def
1703: /ans 1 def
1704: mm isArray {
1705: 0 1 mm length 1 sub {
1706: /ii set
1707: mm ii get isZero /ans set
1708: ans 0 eq { exit } { } ifelse
1709: } for
1710: } {
1711: {
1712: mm tag 1 eq {/ans mm 0 eq def exit} { } ifelse
1713: mm isPolynomial { /ans mm (0). eq def exit } { } ifelse
1714: mm isUniversalNumber { /ans mm (0).. eq def exit } { } ifelse
1715: /ans 0 def exit
1716: } loop
1717: } ifelse
1718: /arg1 ans def
1719: ] pop
1720: popVariables
1721: arg1
1722: } def
1723: [(isZero)
1724: [(m isZero bool)]] putUsages
1725:
1726: %<
1727: % Usage: m isNonNegative
1728: % dr.sm1 $B$X0\$9(B.
1729: %>
1730: /isNonNegative {
1731: /arg1 set
1732: [/mm /ans /ii] pushVariables
1733: [
1734: /mm arg1 def
1735: /ans 1 def
1736: mm isArray {
1737: 0 1 mm length 1 sub {
1738: /ii set
1739: mm ii get isNonNegative /ans set
1740: ans 0 eq { exit } { } ifelse
1741: } for
1742: } {
1743: {
1744: mm tag 1 eq {/ans mm 0 gt mm 0 eq or def exit} { } ifelse
1745: mm isUniversalNumber { /ans mm (0).. gt mm (0).. eq or def exit }
1746: { } ifelse
1747: mm isRational { mm (numerator) dc mm (denominator) dc mul /mm set
1748: /ans mm (0).. gt mm (0).. eq or def exit } { } ifelse
1749: /ans 0 def exit
1750: } loop
1751: } ifelse
1752: /arg1 ans def
1753: ] pop
1754: popVariables
1755: arg1
1756: } def
1757: [(isNonNegative)
1758: [(m isNonNegative bool)
1759: (In case of matrix, m[i,j] >= 0 must hold for all i,j.)
1760: ]] putUsages
1761:
1762: % Global variable: cone.weightBorder
1763: % /cone.weightBorder null def $BITMW$G$"$m$&(B. getStartingCone $B$G@_Dj$5$l$k(B.
1764:
1765: %<
1766: % Usages: cone i isOnWeigthBorder
1767: % cone $B$N(B i $BHVL\$N(B facet $B$,(B weight $B6u4V$N6-3&$K$"$k$+(B?
1768: % $BBg0hJQ?t(B cone.weightBorder $B$,@_Dj$5$l$F$k$3$H(B.
1769: % $B$3$NJQ?t$O(B cone $B$N(B facet $B%Y%/%H%k$N%j%9%H(B.
1770: % $B$3$NJQ?t$O(B setWeightBorder $B$G@_Dj(B
1771: % cone.weightBorder[0] or cone.weightBorder[1] or ...
1772: % /ccone cone.startingCone def ccone 0 isOnWeightBorder
1773: % ccone 1 isOnWeightBorder
1774: %>
1775: /isOnWeightBorder {
1776: /arg2 set /arg1 set
1777: [/cone /facet_i /i /j /vv /co /ans] pushVariables
1778: [
1779: /cone arg1 def /facet_i arg2 def
1780: facet_i to_int32 /facet_i set
1781: /ans 0 def
1782: cone (facetsv) getNode 2 get facet_i get /vv set % Facet $B$r(B vertex $BI=8=(B.
1783: {
1784: 0 1 cone.weightBorder length 1 sub {
1785: /i set
1786: cone.weightBorder i get /co set % co $B$K@)Ls>r7o(B
1787: vv cone.Lp mul % vv $B$r(B weight space $B$X(B lift.
1788: co mul isZero
1789: { /ans 1 def exit } { } ifelse
1790: } for
1791: exit
1792: } loop
1793: /arg1 ans def
1794: ] pop
1795: popVariables
1796: arg1
1797: } def
1798:
1799: %<
1800: % Usages: cone i markFlipped
1801: % cone $B$N(B i $BHVL\$N(B facet $B$K(B flipped $B$N0u$r$D$1$k(B. cone $B<+BN$,JQ99$5$l$k(B.
1802: % cone $B$O(B class-tree. Constructor $B$O(B newCone
1803: %>
1804: /markFlipped {
1805: /arg2 set /arg1 set
1806: [/cone /facet_i /vv] pushVariables
1807: [
1808: /cone arg1 def /facet_i arg2 def
1809: facet_i to_int32 /facet_i set
1810: cone (flipped) getNode 2 get /vv set
1811: vv facet_i (1).. put
1812: ] pop
1813: popVariables
1814: } def
1815:
1.4 takayama 1816: %<
1817: % Usages: cone i [cid fid] markNext
1818: % cone $B$N(B i $BHVL\$N(B facet $B$N$H$J$j$N(B cone id (cid) $B$H(B face id (fid) $B$r@_Dj$9$k(B.
1819: % cone $B$N(B nextcid[i] = cid; nextfid[i] = fid $B$H$J$k(B.
1820: % cone $B<+BN$,JQ99$5$l$k(B.
1821: % cone $B$O(B class-tree.
1822: %>
1823: /markNext {
1824: /arg3 set /arg2 set /arg1 set
1825: [/cone /facet_i /vv /nextid] pushVariables
1826: [
1827: /cone arg1 def /facet_i arg2 def /nextid arg3 def
1828: facet_i to_int32 /facet_i set
1829: cone (nextcid) getNode 2 get /vv set
1830: vv facet_i , nextid 0 get to_univNum , put
1831:
1832: cone (nextfid) getNode 2 get /vv set
1833: vv facet_i , nextid 1 get to_univNum , put
1834: ] pop
1835: popVariables
1836: } def
1837:
1.1 takayama 1838:
1839:
1840: %<
1841: % Usages: cone getNextFacet i
1842: % flipped $B$N(B mark $B$N$J$$(B facet $B$N(B index facet_i $B$rLa$9(B.
1843: % $B$=$l$,$J$$$H$-$O(B null
1844: %>
1845: /getNextFacet {
1846: /arg1 set
1847: [/cone /facet_i /vv /ii] pushVariables
1848: [
1849: /cone arg1 def
1850: /facet_i null def
1851: cone (flipped) getNode 2 get /vv set
1852: 0 1 vv length 1 sub {
1853: /ii set
1854: vv ii get to_int32 0 eq { /facet_i ii def exit }
1855: { } ifelse
1856: } for
1857: /arg1 facet_i def
1858: ] pop
1859: popVariables
1860: arg1
1861: } def
1862:
1863: %<
1864: % Usages: cone i epsilon flipWeight
1865: % cone $B$N(B i $BHVL\$N(B facet $B$K$+$s$7$F(B flip $B$9$k(B.
1866: % $B?7$7$$(B weight $B$r5a$a$k(B. cf. liftWeight
1867: %>
1868: /flipWeight {
1869: /arg3 set /arg2 set /arg1 set
1870: [/cone /facet_i /ep /vp /v /v /ii] pushVariables
1871: [
1872: /cone arg1 def /facet_i arg2 def
1873: facet_i to_int32 /facet_i set
1874: /ep arg3 def
1875:
1876: ep to_univNum (1).. div /ep set
1877:
1878: % note: 2004.9.2
1879: cone (facetsv) getNode 2 get facet_i get /v set
1880: cone (facets) getNode 2 get facet_i get /f set
1881: /vp v 0 get def
1882: 1 1 v length 1 sub {
1883: /ii set
1884: vp v ii get add /vp set
1885: } for
1886: vp ep f mul sub /vp set
1887: vp nnormalize_vec /vp set
1888: /arg1 vp def
1889: ] pop
1890: popVariables
1891: arg1
1892: } def
1893:
1894: %<
1895: % Usages: cone1 cone2 isSameCone bool
1896: % cone1 cone2 $B$,Ey$7$$$+(B? facet $B$GHf$Y$k(B.
1897: % cone1, cone2 $B$O(B pointed cone $B$G$J$$$H$$$1$J$$(B.
1898: %>
1899: /isSameCone {
1900: /arg2 set /arg1 set
1901: [/cone1 /cone2 /facets1 /facets2 /ans] pushVariables
1902: [
1903: /cone1 arg1 def
1904: /cone2 arg2 def
1905: /facets1 cone1 (facets) getNode 2 get def
1906: /facets2 cone2 (facets) getNode 2 get def
1907: facets1 length facets2 length eq {
1908: facets1 facets2 sub isZero /ans set
1909: } {
1910: /ans 0 def
1911: } ifelse
1912: /arg1 ans def
1913: ] pop
1914: popVariables
1915: arg1
1916: } def
1917:
1918: %<
1919: % Usages: cone1 cone2 getCommonFacet list
1920: % cone1 $B$NCf$G(B cone2 $B$K4^$^$l$k(B facet $B$N%j%9%H(B
1921: % cone2 $B$NCf$G(B cone1 $B$K4^$^$l$k(B facet $B$N%j%9%H$r$b$I$9(B.
1922: % [1 [i] [j]] $B$"$k$H$-(B. [0 [ ] [ ]] $B$J$$$H$-(B.
1923: % cone1 $B$N(B facetsv[i] $B$,(B cone2 $B$K4^$^$l$k$+D4$Y$k(B.
1924: % cone2 $B$N(B facetsv[i] $B$,(B cone1 $B$K4^$^$l$k$+D4$Y$k(B.
1925: % cone1, cone2 $B$O(B pointed cone $B$G$J$$$H$$$1$J$$(B.
1926: %>
1927: /getCommonFacet {
1928: /arg2 set /arg1 set
1929: [/cone1 /cone2 /facets /ineq /ans1 /ans2 /i /tt] pushVariables
1930: [
1931: /cone1 arg1 def
1932: /cone2 arg2 def
1933:
1934: /facets cone1 (facetsv) getNode 2 get def
1935: /ineq cone2 (inequalities) getNode 2 get def
1936: /ans1 [
1937: 0 1 facets length 1 sub {
1938: /i set
1939: facets i get /tt set % facetsv[i] $B$r(B tt $B$X(B.
1940: ineq tt transpose mul isNonNegative {
1941: i
1942: } { } ifelse
1943: } for
1944: ] def
1945:
1946: /facets cone2 (facetsv) getNode 2 get def
1947: /ineq cone1 (inequalities) getNode 2 get def
1948: /ans2 [
1949: 0 1 facets length 1 sub {
1950: /i set
1951: facets i get /tt set % facetsv[i] $B$r(B tt $B$X(B.
1952: ineq tt transpose mul isNonNegative {
1953: i
1954: } { } ifelse
1955: } for
1956: ] def
1957: ans1 length 1 gt ans2 length 1 gt or {
1958: (getCommonFacet found more than 1 common facets.) error
1959: } { } ifelse
1960: % $B6&DL(B facet $B$,$"$l$P(B 1, $B$J$1$l$P(B 0.
1961: ans1 length 1 eq ans2 length 1 eq and {
1962: /tt 1 def
1963: } {
1964: /tt 0 def
1965: } ifelse
1966: /arg1 [tt ans1 ans2] def
1967: ] pop
1968: popVariables
1969: arg1
1970: } def
1971:
1972: %
1973: % -------------------------------------------------
1974: % test8 $B$O(B aux-cone.sm1 $B$X0\F0(B.
1975: % $B0J2<$$$h$$$h0lHL$N%W%m%0%i%`$N:n@.3+;O(B.
1976: % -------------------------------------------------
1977: %
1978:
1979: %<
1980: % Usages: setWeightBorder
1981: % cone.weightBorder (weight cone $B$N(B facet $B%Y%/%H%k$N=89g(B) $B$r@_Dj$9$k(B.
1982: % $B$"$HI{;:J*$H$7$F(B cone.w_cone_projectedWt (doPolymakeObj)
1983: % cone.w_ineq_projectedWt
1984: % cone.m $B<!85$N%Y%/%H%k(B.
1985: % cone.W, cone.Wt, cone.w_ineq $B$,$9$G$K7W;;$:$_$G$J$$$H$$$1$J$$(B.
1986: %>
1987: /setWeightBorder {
1988: [
1989: (Entering setWeightBorder ) message
1990: cone.w_ineq cone.Wt mul pruneZeroVector /cone.w_ineq_projectedWt set
1991: {
1992: cone.w_ineq_projectedWt length 0 eq {
1993: % weight $B$N6u4V$K(B border $B$,$J$$>l9g(B.
1994: /cone.weightBorder [ ] def
1995: exit
1996: } { } ifelse
1997: % weight $B$N6u4V$K(B border $B$,$"$k>l9g(B.
1998: cone.w_ineq_projectedWt getConeInfo /cone.w_cone_projectedWt set
1999: cone.w_cone_projectedWt 0 get 0 get to_int32 cone.m to_int32 eq {
2000: } {
2001: (setWeightBorder : internal error.) message
2002: } ifelse
2003: cone.w_cone_projectedWt 1 get (FACETS) getNode 2 get 0 get
2004: removeFirstFromPolymake /cone.weightBorder set
2005: exit
2006: } loop
2007: (cone.weightBorder=) message
2008: cone.weightBorder pmat
2009: ] pop
2010: } def
2011:
2012: %
2013: % -------------------------------------------------
2014: % $B%W%m%0%i%`$NN.$l(B.
2015: % Global: cone.fan cone $B$rG[Ns$H$7$F3JG<$9$k(B.
2016: %
2017: % ncone (next cone) $B$,?75,$KF@$i$l$?(B cone $B$G$"$k$H$9$k(B.
2018: % $B$3$N$H$-<!$NA`:n$r$9$k(B.
2019: % 0. ncone $B$,(B cone.fan $B$K$9$G$K$J$$$+D4$Y$k(B. $B$"$l$P(B, internal error.
2020: % 1. ncone markBorder ; ncone $B$NCf$N(B border $B>e$N(B facet $B$r(B mark
2021: % 2. cone.fan $B$NCf$N(B cone $B$H6&DL(B facet $B$,$J$$$+D4$Y(B (getCommonFacet),
2022: % $B$"$l$P$=$l$i$r(B mark $B$9$k(B.
2023: % global: cone.incidence $B$K(B $B6&DL(Bfacet $B$r;}$DAH$_$N>pJs$r2C$($k(B.
2024: % 3. ncone $B$r(B cone.fan $B$N:G8e$K2C$($k(B.
2025: % $B0J>e$NA`:n$r$^$H$a$?$b$N$,(B ncone updateFan
2026: %
2027: % getNextFlip $B$O(B cone.fan $B$NCf$+$i(B flip $B$7$F$J$$(B cone $B$H(B facet $B$NAH$rLa$9(B.
2028: % $B$J$1$l$P(B null $B$rLa$9(B. null $B$,La$l$P%W%m%0%i%`=*N;(B.
2029: %
2030: % getStargingCone $B$O7W;;$r=PH/$9$Y$-?75,$N(B cone $B$r7W;;$9$k(B. $BBg0hJQ?t(B cone.Lt, cone.W
2031: % $B$J$I$b$3$NCf$G@_Dj$9$k(B.
2032: % $BJQ?t%j%9%H(B, weight space $B$r@8@.$9$k4X?t(B, $BF~NOB?9`<0(B, weight $B$N8uJd(B $BEy$OBg0hJQ?t(B
2033: % $B$H$7$FF~NO$7$F$*$/(B.
2034: %
2035: % reduced gb $B$O(B $B4X?t(B input weight cone.gb reduced_G $B$G7W;;$9$k(B.
2036: %
2037: %
2038: % [ccone i] getNextCone ncone : flip $B$K$h$j<!$N(B cone $B$rF@$k(B.
2039: %
2040: % 1. clearGlobals ; $BF~NOBg0hJQ?t$N@_Dj(B.
2041: % 2. getStartingCone /ncone set
2042: % 3. { ncone updateFan
2043: % 4. getNextFlip /cone.nextflip set
2044: % 6. cone.nextflip isNull { exit } { } ifelse
2045: % 7. cone.nextflip getNextCone /ncone set
2046: % 8. } loop
2047: %
2048: %
2049: % -------------------------------------------------
2050: %
2051:
2052: %<
2053: % Usages: input weight cone.gb_Dh reduced_G
2054: % gb in h[1,1](D)
2055: %>
2056: /cone.gb_Dh {
2057: /arg2 set /arg1 set
1.12 ! takayama 2058: [/ff /ww /gg /gbopt] pushVariables
1.1 takayama 2059: [
2060: /ff arg1 def
2061: /ww arg2 def
2062: [(AutoReduce) 1] system_variable
2063: [cone.vv ring_of_differential_operators
2064: [ww] weight_vector 0] define_ring
1.12 ! takayama 2065: %(---) messagen ff getAttributeList message
! 2066: ff getAttributeList tag 0 eq {/gbopt [ ] def }
! 2067: {
! 2068: /gbopt ff getAttributeList def
! 2069: } ifelse
! 2070: [ff {toString .} map gbopt]
! 2071: groebner 0 get /gg set %% groenber $B$O(B attribute $B$r<u$1IU$1$J$$(B.
1.1 takayama 2072: /cone.gb_Dh.g gg def
2073: /arg1 gg def
2074: ] pop
2075: popVariables
2076: arg1
2077: } def
2078:
2079: %<
2080: % Usages: cone.boundp
2081: %
2082: /cone.boundp {
2083: dup boundp 2 1 roll tag 0 eq not and
2084: } def
2085:
2086: %<
2087: % Usages: clearGlobals
2088: % cf. cone.boundp
2089: % polymake $B$r:FEY8F$V$?$a$K(B global $BJQ?t$r%/%j%"$9$k(B.
2090: % $B$^$@ESCf(B.
2091: %>
2092: /clearGlobals {
2093: /cone.W null def
2094: /cone.Wt null def
2095:
2096: /cone.cinit null def
2097: /cone.weightBorder null def
2098:
2099: } def
2100:
2101: %<
2102: % Usages: getStartingCone ncone
2103: % getStargingCone $B$O7W;;$r=PH/$9$Y$-?75,$N(B cone $B$r7W;;$9$k(B.
2104: % $B@_Dj$9$Y$-Bg0hJQ?t$O0J2<$r8+$h(B.
2105: %>
2106:
2107: /getStartingCone.test {
2108: %------------------Globals----------------------------------------
2109: % --------------- $BF~NO%G!<%?MQBg0hJQ?t$N@_Dj(B --------------------------
2110: %
2111: % cone.input : $BF~NOB?9`<07O(B
2112: /cone.input
2113: [(t1-x-y) (h*t2-x^2-y^2) (2*x*Dt2+h*Dt1+h*Dx) (2*y*Dt2+h*Dt1+h*Dy)]
2114: def
2115:
2116: % cone.vlist : $BA4JQ?t$N%j%9%H(B
2117: /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h)] def
2118:
2119: % cone.vv : define_ring $B7A<0$NJQ?t%j%9%H(B.
2120: % t1,t2, x,y : t-space $B$N(B Grobner fan (local) $B$r5a$a$k(B.
2121: /cone.vv (t1,t2,x,y) def
2122:
2123: % cone.parametrizeWeightSpace : weight $B6u4V$r(B parametrize $B$9$k4X?t(B.
2124: % $BBg0hJQ?t(B cone.W , cone.Wpos $B$b$-$^$k(B.
2125: /cone.parametrizeWeightSpace {
2126: 4 2 parametrizeSmallFan
2127: } def
2128:
2129: % cone.w_start : weight$B6u4V$K$*$1$k(B weight $B$N=i4|CM(B.
2130: % $B$3$NCM$G(B max dim cone $B$,F@$i$l$J$$$H(B random weight $B$K$h$k(B $B%5!<%A$,;O$^$k(B.
2131: /cone.w_start
2132: [ 1 4 ]
2133: def
2134:
2135: % cone.gb : gb $B$r7W;;$9$k4X?t(B.
2136: /cone.gb {
2137: cone.gb_Dh
2138: } def
2139:
2140: %
2141: % ----------------- $B$*$o$j(B ---------------------------
2142: %
2143: } def % end of getStartingCone.test
2144:
2145: /getStartingCone {
2146: [/wv_start /w_start /reduced_G] pushVariables
2147: [
2148: % cone.n $B$O<+F0E*$K$-$a$i$l$k(B.
2149: % cone.n $B$O(B GB $B$r7W;;$9$k6u4V$N<!85(B.
2150: /cone.n cone.vlist length def
2151: %[1] cone.W, cone.Wpos $B$r5a$a$k(B. cone.m $B$O(B cone.W $B$h$j<+F0E*$K$-$^$k(B.
2152: % cone.m $B$O(B weight $B6u4V$N<+M3EY(B. cone.W $B$G<M1F$5$l$k@h$N<!85(B.
2153: /cone.W cone.boundp {
2154: (Skip cone.parametrizeWeightSpace. cf. clearGlobals) message
2155: } {
2156: cone.parametrizeWeightSpace
2157: } ifelse
2158: (parametrizing weight space: cone.W = ) messagen cone.W message
2159: /cone.Wt cone.W transpose def
2160: /cone.m cone.W length def
2161: % WeightBorder $B$N>r7oH=Dj(B facet $B$r@_Dj(B.
2162: /cone.weightBorder cone.boundp {
2163: (Skip setWeightBorder cf. clearGlobals) message
2164: } {
2165: setWeightBorder
2166: } ifelse
2167:
2168: %[2] weight vector wv_start $B$r@8@.$9$k(B.
2169: % wv_start $B$r@_Dj(B.
2170: cone.w_start tag 0 eq {
2171: % cone.w_start $B$,(B null $B$J$i(B random $B$K(B weight $B$r@_Dj(B.
2172: /cone.w_start cone.m cone_random_vec def
2173: } {
2174: cone.w_start length cone.m to_int32 eq {
2175: } {
2176: (Error: cone.w_start has wrong length.) error
2177: /cone.w_start cone.m cone_random_vec def
2178: } ifelse
2179: } ifelse
2180: /w_start cone.w_start cone.W mul def
2181:
2182: {
2183: cone.vlist w_start cone_wtowv /wv_start set
2184: (Trying a starting weight vector : ) messagen
2185: wv_start pmat
2186: %[3] reduced GB $B$N7W;;(B.
2187: cone.input wv_start cone.gb /reduced_G set
1.2 takayama 2188: (Reduced GB is obtained: ) message
2189: %reduced_G pmat
2190: /cone.cgb reduced_G def
2191: [cone.w_start w_start wv_start] /cone.cgb_weight set
1.1 takayama 2192:
2193: %[4] $B<M1F$7$F$+$i(B polytope $B$N%G!<%?$r7W;;(B.
2194: wv_start reduced_G coneEq /cone.g_ineq set
2195: cone.g_ineq cone.w_ineq join /cone.gw_ineq set
2196: cone.gw_ineq cone.Wt mul /cone.gw_ineq_projectedWt set % $B<M1F(B
2197: /cone.cinit cone.boundp {
2198: (Skipping cone.gw_ineq_projectedWt getConeInfo. cf. clearGlobals) message
2199: } {
2200: cone.gw_ineq_projectedWt getConeInfo /cone.cinit set
2201: } ifelse
2202:
2203: (cone.cinit is --- the first number is the dim of cone.) messagen
2204: cone.cinit 0 get pmat
2205: % Maximal dimensional cone $B$+$I$&$+$N8!::(B. $B8!::$K%Q%9$9$l$P(B loop $B$r(B exit
2206: % $B%Q%9$7$J$$>l9g(B w_start $B$r(B cone_random_vec $B$rMQ$$$FJQ99$9$k(B.
2207: cone.cinit 0 get 0 get to_int32 cone.m eq { exit }
2208: {
2209: (Failed to get the max dim cone. Updating the weight ...) messagen
1.2 takayama 2210: cone.m cone_random_vec /cone.w_start set
2211: /w_start cone.w_start cone.W mul def
1.1 takayama 2212: % cone.cinit $B$r:FEY7W;;$9$k$?$a$K(B clear $B$9$k(B.
2213: /cone.cinit null def
2214: } ifelse
2215: } loop
2216:
2217: (cone.m = ) messagen cone.m message
2218: (Suceeded to get the maximal dimensional startingCone.) message
2219:
2220: % Linearity subspace $B$N(B orth complement $B$X$N<M1F9TNs(B.
2221: % $BBg0hJQ?t(B cone.Lp, cone.Lpt $B$r@_Dj(B
2222: cone.cinit 0 get 1 get /cone.Lp set
2223: cone.Lp transpose /cone.Lpt set
2224: % Linearity subspace $B$N9TNs$r@_Dj(B.
2225: % $BBg0hJQ?t(B cone.L $B$r@_Dj(B
2226: cone.cinit 0 get 2 get /cone.L set
2227: % cone.d $B$O(B cone.W $B$*$h$S(B Linearity space $B$G3d$C$?8e(B, cone $B$r9M$($k$H$-$N<!85(B.
2228: % $BBg0hJQ?t(B cone.d $B$N@_Dj(B.
2229: /cone.d cone.Lp length def
2230:
2231: cone.m cone.d eq {
2232: (There is no linearity space) message
2233: } {
2234: (Dim of the linearity space is ) messagen cone.m cone.d sub message
2235: (cone.Lp = ) messagen cone.Lp pmat
2236: } ifelse
2237:
2238: %[5] cone.g_ineq * cone.Wt * cone.Lpt
2239: % cone.w_ineq * cone.Wt * cone.Lpt
2240: % $B$G@)Ls$r(B d $B<!85%Y%/%H%k$KJQ49(B.
2241: % W (R^m) $B6u4V$NITEy<0@)Ls$r(B L' (R^d) $B6u4V$X<M1F(B
2242: % cone.gw_ineq_projectedWtLpt
2243: % = cone.g_ineq*cone.Wt*cone.Lpt \/ cone.w_ineq*coneWt*cone.Lpt
2244:
2245: /cone.gw_ineq_projectedWtLpt
2246: cone.gw_ineq_projectedWt cone.Lpt mul
2247: def
2248:
2249: cone.m cone.d eq {
2250: /cone.cinit.d cone.cinit def
2251: } {
2252: % cone.m > cone.d $B$J$i$P(B, $B:FEY(B cone $B$N7W;;$,I,MW(B.
2253: % R^d $B$N(B cone $B$O(B cone.cinit.d $B$XF~$l$k(B.
2254: cone.gw_ineq_projectedWtLpt getConeInfo /cone.cinit.d set
2255: } ifelse
2256:
2257: cone.cinit.d 1 get newCone /cone.startingCone set
2258:
2259: (cone.startingCone is ) message
2260: cone.startingCone message
2261: ] pop
2262: popVariables
2263: cone.startingCone
2264: } def
2265:
2266: %
2267: % data/test9.sm1 $B$N(B test9 1-simplex X 2-simplex
2268: %
2269: % data/test10.sm1 1-simplex X 3-simplex
2270: % data/test11.sm1 SST, p.59
2271: %
2272: % $B$$$h$$$h(B, cone enumeration $B$N%W%m%0%i%`=q$-3+;O(B
2273: %
2274:
2275: %<
2276: % Usages: cone markBorder
2277: % cone->facets[i] $B$,(B weight space $B$N(B border $B$K$"$k$H$-(B
2278: % cone->flipped[i] = 2 $B$H$9$k(B.
2279: % $B$3$l$r(B cone $B$N$9$Y$F$N(B facet $B$KBP$7$F7W;;(B.
2280: %>
2281: /markBorder {
2282: /arg1 set
1.4 takayama 2283: [/cone /facets_t /flipped_t /kk /nextcid_t /nextfid_t] pushVariables
1.1 takayama 2284: [
2285: /cone arg1 def
2286: cone (facets) getNode 2 get /facets_t set
2287: cone (flipped) getNode 2 get /flipped_t set
1.4 takayama 2288: cone (nextcid) getNode 2 get /nextcid_t set
2289: cone (nextfid) getNode 2 get /nextfid_t set
1.1 takayama 2290: 0 1 flipped_t length 1 sub {
2291: /kk set
2292: flipped_t kk get (0).. eq {
2293: cone kk isOnWeightBorder {
2294: % Border $B$N>e$K$"$k$N$G(B flip $B:Q$N%^!<%/$r$D$1$k(B.
2295: flipped_t kk (2).. put
1.4 takayama 2296: % $B$H$J$j$N(B cone $B$N(B id (nextcid, nextfid) $B$O(B -2 $B$H$9$k(B.
2297: nextcid_t kk (-2).. put
2298: nextfid_t kk (-2).. put
1.1 takayama 2299: } { } ifelse
2300: } { } ifelse
2301: } for
2302: ] pop
2303: popVariables
2304: } def
2305:
2306: %<
2307: % Usages: ncone updateFan
2308: % $B%0%m!<%P%kJQ?t(B cone.fan $B$r99?7$9$k(B.
2309: %>
2310: %
2311: % updateFan $B$N(B debug $B$O(B data/test8 $B$G$H$j$"$($:$d$k(B.
2312: % test8 /ncone set $B$r<B9T$7$F$+$i(B ncone updateFan
2313:
2314: % global: cone.fan
2315: /cone.fan [ ] def
2316: % global: cone.incidence
2317: /cone.incidence [ ] def
1.2 takayama 2318: % global: cone.gblist gb's standing for each cones in cone.fan.
2319: /cone.gblist [ ] def
1.1 takayama 2320:
2321: /updateFan {
2322: /arg1 set
2323: [/ncone /kk /cfacet /ii /jj /tcone /flipped_t] pushVariables
2324: [
2325: /ncone arg1 def
2326: /cone.fan.n cone.fan length def
1.2 takayama 2327: % -1. cone.cgb ($BD>A0$K7W;;$5$l$?(B gb) $B$H(B cone.cgb_weight ($BD>A0$N7W;;$N(B weight)
2328: % $B$r(B cone.gblist $B$X3JG<$9$k(B.
2329: cone.gblist [ [cone.cgb cone.cgb_weight] newConeGB ] join /cone.gblist set
1.1 takayama 2330: % 0. ncone $B$,(B cone.fan $B$K$9$G$K$"$l$P%(%i!<(B
2331: 0 1 cone.fan.n 1 sub {
2332: /kk set
2333: ncone cone.fan kk get isSameCone {
2334: (Internal error updateFan: ncone is already in cone.fan) error
2335: } { } ifelse
2336: } for
2337:
2338: % 1. ncone $B$NCf$N(B border $B>e$N(B facet $B$r$9$Y$F(B mark.
2339: ncone markBorder
2340:
2341: % 2. ncone /\ cone.fan[kk] $B$,$"$k$+D4$Y$k(B. $B$"$l$P(B Mark $B$9$k(B. incidence graph $B$K2C$($k(B
2342: 0 1 cone.fan.n 1 sub {
2343: /kk set
2344: ncone cone.fan kk get getCommonFacet /cfacet set
2345: cfacet 0 get
2346: {
2347: % $B6&DL(B facet $B$,$"$k>l9g(B. [[cone$BHV9f(B face$BHV9f(B] [cone$BHV9f(B face$BHV9f(B]] $B$N7A<0$G3JG<(B.
2348: /ii cfacet 1 get 0 get def
2349: /jj cfacet 2 get 0 get def
2350: cone.incidence [ [[cone.fan.n ii] [kk jj]] ] join /cone.incidence set
2351: % flipped $B$r(B mark $B$9$k(B.
2352: ncone ii markFlipped
2353: cone.fan kk get /tcone set
2354: tcone jj markFlipped
1.4 takayama 2355: % nextcid, nextfid $B$r@_Dj$9$k(B.
2356: ncone ii [kk jj] markNext
2357: tcone jj [cone.fan.n ii] markNext
1.1 takayama 2358: } { } ifelse
2359: } for
2360: % 3. ncone $B$r2C$($k(B.
2361: cone.fan [ncone] join /cone.fan set
2362: ] pop
2363: popVariables
2364: } def
2365:
2366: %<
1.9 takayama 2367: % usages: getNextFlip [cone, k, cid]
1.1 takayama 2368: % cone.fan $B$r8!:w$7$F(B $B$^$@(B flip $B$7$F$J$$(B cone $B$H(B facet $B$NAH$rLa$9(B.
2369: % $B$b$&$J$$$H$-$K$O(B null $B$rLa$9(B.
1.9 takayama 2370: % cid $B$O(B cone $B$,(B cone.fan $B$N(B $B2?HVL\$G$"$k$+$N(B index. cone.gblist $B$N8!:wEy$K(B
2371: % $BMQ$$$k(B.
1.1 takayama 2372: %>
2373: /getNextFlip {
1.9 takayama 2374: [/tcone /ans /ii /cid] pushVariables
1.1 takayama 2375: [
1.9 takayama 2376: /ans null def /cid -1 def
1.1 takayama 2377: 0 1 cone.fan length 1 sub {
2378: /ii set
2379: cone.fan ii get /tcone set
1.9 takayama 2380: /cid ii def
1.1 takayama 2381: tcone getNextFacet /ans set
2382: ans tag 0 eq { } { exit } ifelse
2383: } for
2384: ans tag 0 eq { /arg1 null def }
1.9 takayama 2385: { /arg1 [tcone ans cid] def } ifelse
1.1 takayama 2386: ] pop
2387: popVariables
2388: arg1
2389: } def
2390:
2391: % global variable : cone.epsilon , cone.epsilon.limit
2392: % flip $B$N;~$N(B epsilon
2393: /cone.epsilon (1).. (10).. div def
2394: /cone.epsilon.limit (1).. (100).. div def
1.9 takayama 2395: % cone.epsilon.limit $B$rIi$K$9$l$PDd;_$7$J$$(B.
1.1 takayama 2396:
2397: %<
2398: % Usages: result_getNextFlip getNextCone ncone
2399: % flip $B$7$F?7$7$$(B ncone $B$rF@$k(B.
2400: %>
1.11 takayama 2401: /getNextCone.orig {
1.1 takayama 2402: /arg1 set
2403: [/ncone /ccone /kk /w /next_weight_w_wv] pushVariables
2404: [
2405: /ccone arg1 def
2406: /ncone null def
2407: /kk ccone 1 get def
2408: ccone 0 get /ccone set
2409: {
2410: ccone tag 0 eq { exit } { } ifelse
2411:
2412: % ccone $B$N(B kk $BHVL\$N(B facet $B$K$D$$$F(B flip $B$9$k(B.
2413: ccone kk cone.epsilon flipWeight /w set
2414: (Trying new weight is ) messagen w message
2415: w liftWeight /next_weight_w_wv set
2416: (Trying new weight [w,wv] is ) messagen next_weight_w_wv message
2417:
2418: cone.input next_weight_w_wv 1 get cone.gb /cone.cgb set
1.2 takayama 2419: [w] next_weight_w_wv join /cone.cgb_weight set
1.1 takayama 2420: next_weight_w_wv 1 get cone.cgb coneEq /cone.g_ineq set
2421: cone.g_ineq cone.w_ineq join cone.Wt mul cone.Lpt mul
2422: pruneZeroVector /cone.gw_ineq_projectedWtLpt set
2423:
2424: (cone.gw_ineq_projectedWtLpt is obtained.) message
2425:
2426: cone.gw_ineq_projectedWtLpt getConeInfo /cone.nextConeInfo set
2427: % $B<!85$rD4$Y$k(B. $B$@$a$J$i(B retry
2428: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
2429: cone.nextConeInfo 1 get newCone /ncone set
2430: ccone ncone getCommonFacet 0 get {
2431: (Flip succeeded.) message
2432: exit
2433: } { } ifelse
2434: } { } ifelse
2435: % common face $B$,$J$1$l$P(B $B$d$O$j(B epsilon $B$r>.$5$/(B.
2436: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
2437: (ccone and ncone do not have a common facet.) message
2438: } {
2439: (ncone is not maximal dimensional. ) message
2440: } ifelse
2441: (Decreasing epsilon to ) messagen
2442: cone.epsilon (1).. (2).. div mul /cone.epsilon set
2443: cone.epsilon cone.epsilon.limit sub numerator (0).. lt {
2444: (Too small cone.epsilon ) error
2445: } { } ifelse
2446: cone.epsilon message
2447: } loop
2448: /arg1 ncone def
2449: ] pop
2450: popVariables
2451: arg1
2452: } def
2453:
2454: %<
2455: % Usages: set globals and getGrobnerFan
2456: % cf. clearGlobals
2457: % getStartingCone $B$9$k$H(B weightSpace $B$H$+$N7W;;$,$G$-$k(B. isOnWeightBorder $B$,(B
2458: % $B7h$a$i$l$k(B.
2459: %>
2460: % $B$H$j$"$($:(B (data/test8.sm1) run $B$7$F$+$i(B getGrobnerFan
2461: /getGrobnerFan {
2462: getStartingCone /cone.ncone set
2463: {
2464: cone.ncone updateFan
2465: ( ) message
2466: (----------------------------------------------------------) message
2467: (getGrobnerFan #cone.fan=) messagen cone.fan length message
2468: cone.ncone /cone.ccone set
2469: getNextFlip /cone.nextflip set
2470: cone.nextflip tag 0 eq { exit } { } ifelse
2471: cone.nextflip getNextCone /cone.ncone set
2472: } loop
1.2 takayama 2473: (Construction is completed. See cone.fan, cone.incidence and cone.gblist.)
2474: message
2475: } def
2476:
2477: %<
2478: % Usages: vlist generateD1_1
2479: % -1,1 weight $B$r@8@.$9$k(B.
2480: % vlist $B$O(B (t,x,y) $B$+(B [(t) (x) (y)]
2481: %
2482: %>
2483: /generateD1_1 {
2484: /arg1 set
2485: [/vlist /rr /rr /ii /vv] pushVariables
2486: [
2487: /vlist arg1 def
2488: vlist isString {
2489: [vlist to_records pop] /vlist set
2490: } { } ifelse
2491: [
2492: 0 1 vlist length 1 sub {
2493: /ii set
2494: vlist ii get /vv set
2495: vv -1
2496: [@@@.Dsymbol vv] cat 1
2497: } for
2498: ] /rr set
2499: /arg1 rr def
2500: ] pop
2501: popVariables
2502: arg1
2503: } def
2504:
2505: /listNodes {
2506: /arg1 set
2507: [/in-listNodes /ob /rr /rr /ii] pushVariables
2508: [
2509: /ob arg1 def
2510: /rr [ ] def
2511: {
2512: ob isClass {
2513: ob (array) dc /ob set
2514: } { exit } ifelse
2515: rr [ob 0 get] join /rr set
2516: ob 2 get /ob set
2517: 0 1 ob length 1 sub {
2518: /ii set
2519: rr ob ii get listNodes join /rr set
2520: } for
2521: exit
2522: } loop
2523: /arg1 rr def
2524: ] pop
2525: popVariables
2526: arg1
2527: } def
2528: [(listNodes)
2529: [(ob listNodes)
2530: (cf. getNode)
2531: (Example:)
2532: ( /dog [(dog) [[(legs) 4] ] [ ]] [(class) (tree)] dc def)
2533: ( /man [(man) [[(legs) 2] ] [ ]] [(class) (tree)] dc def)
2534: ( /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def)
2535: ( ma listNodes )
2536: ]] putUsages
2537:
2538: %<
2539: % Usages: obj printTree
2540: %>
2541: /printTree {
2542: /arg1 set
2543: [/ob /rr /rr /ii /keys /tt] pushVariables
2544: [
2545: /ob arg1 def
2546: /rr [ ] def
2547: /keys ob listNodes def
2548: keys 0 get /tt set
2549: keys rest /keys set
2550: keys { ob 2 1 roll getNode } map /rr set
2551: (begin ) messagen tt messagen
2552: ( ---------------------------------------) message
2553: 0 1 rr length 1 sub {
2554: /ii set
2555: keys ii get messagen (=) message
2556: rr ii get 2 get pmat
2557: } for
2558: (--------------------------------------- end ) messagen
2559: tt message
2560: /arg1 rr def
2561: ] pop
2562: popVariables
2563: arg1
2564: } def
2565:
2566: %<
2567: % Usages $B$O(B (inputForm) usages $B$r$_$h(B.
2568: %>
2569: /inputForm {
2570: /arg1 set
2571: [/ob /rr /i ] pushVariables
2572: [
2573: /ob arg1 def
2574: /rr [ ] def
2575: {
2576: ob isArray {
2577: rr [ ([) ] join /rr set
2578: 0 1 ob length 1 sub {
2579: /i set
2580: i ob length 1 sub lt {
2581: rr [ob i get inputForm $ , $] join /rr set
2582: } {
2583: rr [ob i get inputForm] join /rr set
2584: } ifelse
2585: } for
2586: rr [ (]) ] join cat /rr set
2587: exit
2588: } { } ifelse
2589: ob isClass {
2590: ob etag 263 eq { % tree
2591: /rr ob inputForm.tree def exit
2592: } { /rr [( $ this etag is not implemented $ )] cat def exit } ifelse
2593: } { } ifelse
2594: ob isUniversalNumber {
2595: [$($ ob toString $)..$] cat /rr set
2596: exit
2597: } { } ifelse
2598: ob isPolynomial {
2599: [$($ ob toString $).$] cat /rr set
2600: exit
2601: } { } ifelse
2602: ob isRational {
2603: [$ $ ob (numerator) dc inputForm $ $
2604: ob (denominator) dc inputForm $ div $ ] cat /rr set
2605: exit
2606: } { } ifelse
2607: ob isString {
2608: [$($ ob $)$ ] cat /rr set
2609: exit
2610: } { } ifelse
2611: ob toString /rr set
2612: exit
2613: } loop
2614: rr /arg1 set
2615: ] pop
2616: popVariables
2617: arg1
2618: } def
2619: [(inputForm)
2620: [(obj inputForm str)
2621: ]] putUsages
2622: % should be moved to dr.sm1
2623:
2624: /inputForm.tree {
2625: /arg1 set
2626: [/ob /key /rr /rr /ii] pushVariables
2627: [
2628: /ob arg1 def
2629: /rr [ ] def
2630: {
2631: ob (array) dc /ob set
2632: /rr [ $[$ ob 0 get inputForm $ , $
2633: ob 1 get inputForm $ , $
2634: ] def
2635: rr [ob 2 get inputForm ] join /rr set
2636: rr [$ ] $] join /rr set
2637: rr [ $ [(class) (tree)] dc $ ] join /rr set
2638: rr cat /rr set
2639: exit
2640: } loop
2641: /arg1 rr def
2642: ] pop
2643: popVariables
2644: arg1
2645: } def
2646:
2647: %<
2648: % Usages: str inputForm.value str
2649: %>
2650: /inputForm.value {
2651: /arg1 set
2652: [/key /val /valstr /rr] pushVariables
2653: [
2654: arg1 /key set
2655: key isString { } {(inputForm.value: argument must be a string) error } ifelse
2656: key boundp {
2657: [(parse) key] extension pop
2658: /val set
2659: val inputForm /valstr set
2660: [( ) valstr ( /) key ( set )] cat /rr set
2661: } {
2662: /valstr [] cat /rr set
2663: } ifelse
2664: rr /arg1 set
2665: ] pop
2666: popVariables
2667: arg1
2668: } def
2669:
2670: % global: cone.withGblist
2671: /cone.withGblist 0 def
2672: %<
2673: % Usages: saveGrobnerFan str
2674: % GrobnerFan $B$N%G!<%?$r(B inputForm $B$KJQ99$7$FJ8;zNs$KJQ$($k(B.
2675: % $B$3$N%G!<%?$r(B parse $B$9$k$H(B GrobnerFan $B$rF@$k$3$H$,2DG=(B.
2676: % BUG: $BB?9`<0$NB0$9$k4D$N%G!<%?$NJ]B8$O$^$@$7$F$J$$(B.
2677: %>
2678: /saveGrobnerFan {
2679: [/rr] pushVariables
2680: [
2681: (cone.withGblist=) messagen cone.withGblist message
2682: [
2683: % $B%f!<%6$N@_Dj$9$k%Q%i%a!<%?(B. cone.gb, cone.parametrizeWeightSpace $BEy$N4X?t$b$"$j(B.
2684: (cone.comment)
2685: (cone.type) (cone.local) (cone.h0)
2686: (cone.vlist) (cone.vv)
2687: (cone.input)
2688:
2689: % $B%W%m%0%i%`Cf$GMxMQ$9$k(B, $BBg;v$JBg0hJQ?t(B. weight vector $B$N<M1F9TNs$,=EMW(B.
2690: (cone.n) (cone.m) (cone.d)
2691: (cone.W) (cone.Wpos) (cone.Wt)
2692: (cone.L) (cone.Lp) (cone.Lpt)
2693: (cone.weightBorder)
2694: (cone.w_ineq)
2695: (cone.w_ineq_projectedWt)
2696: (cone.epsilon)
2697:
2698: % $B7k2L$NMWLs(B.
2699: (cone.fan)
2700: cone.withGblist { (cone.gblist) } { } ifelse
2701: (cone.incidence)
2702:
2703: ] { inputForm.value nl } map /rr set
1.3 takayama 2704: rr cat /rr set
2705: % ring $B$r(B save $B$7$F$J$$$N$GEv:B$NBP=h(B.
2706: [ ([) cone.vv inputForm ( ring_of_differential_operators 0 ] define_ring )
2707: nl nl rr] cat /arg1 set
1.2 takayama 2708: ] pop
2709: popVariables
2710: arg1
2711: } def
2712:
2713: /printGrobnerFan.1 {
2714: /arg1 set
2715: [/key /rr] pushVariables
2716: [
2717: /key arg1 def
2718: key boundp {
2719: [(parse) key] extension pop /rr set
2720: rr isArray {
2721: key messagen ( = ) message rr pmat
2722: } {
2723: key messagen ( = ) messagen rr message
2724: } ifelse
2725: }{
2726: key messagen ( = ) message
2727: } ifelse
2728: ] pop
2729: popVariables
2730: } def
2731:
2732: /printGrobnerFan {
2733: [/i] pushVariables
2734: [
2735: (========== Grobner Fan ====================) message
2736: [
2737: (cone.comment)
2738: (cone.vlist) (cone.vv)
2739: (cone.input)
2740: (cone.type) (cone.local) (cone.h0)
2741: (cone.n) (cone.m) (cone.d)
2742: (cone.W) (cone.Wpos) (cone.Wt)
2743: (cone.L) (cone.Lp) (cone.Lpt)
2744: (cone.weightBorder)
2745: (cone.incidence)
2746: ] { printGrobnerFan.1 } map
2747: ( ) message
2748: 0 1 cone.fan length 1 sub {
2749: /ii set
2750: ii messagen ( : ) messagen
2751: cone.fan ii get printTree
2752: } for
2753: cone.withGblist {
2754: 0 1 cone.gblist length 1 sub {
2755: /ii set
2756: ii messagen ( : ) messagen
2757: cone.gblist ii get printTree
2758: } for
2759: } { } ifelse
2760:
2761:
2762: (=========================================) message
2763: (cone.withGblist = ) messagen cone.withGblist message
2764: ( ) message
2765: ] pop
2766: popVariables
2767: } def
2768:
2769: %<
2770: % Usages: m uniq
2771: % Remove duplicated lines.
2772: %>
2773: /uniq {
2774: /arg1 set
2775: [/mm /prev /i /rr] pushVariables
2776: [
2777: /mm arg1 def
2778: {
2779: mm length 0 eq { [ ] /rr set exit } { } ifelse
2780: /prev mm 0 get def
2781: [
2782: prev
2783: 1 1 mm length 1 sub {
2784: /i set
2785: mm i get prev sub isZero { }
2786: { /prev mm i get def prev } ifelse
2787: } for
2788: ] /rr set
2789: exit
2790: } loop
2791: rr /arg1 set
2792: ] pop
2793: popVariables
2794: arg1
2795: } def
1.3 takayama 2796:
2797: %<
2798: % Usages: [vlist vw_vector] getGrRing [vlist vGlobal sublist]
2799: % example: [(x,y,z) [(x) -1 (Dx) 1 (y) 1 (Dy) 2]] getGrRing
2800: % [(x,y,z,y') [(x)] [[(Dy) (y')]]]
2801: % h[0,1](D_0) $B@lMQ$N(B getGrRing.
2802: % u_i + v_i > 0 $B$J$i(B Dx_i ==> x_i' ($B2D49$JJQ?t(B). sublist $B$X(B.
2803: % u_i < 0 $B$J$i(B x_i $B$O(B vGlobal $B$X(B.
2804: % ii [vlist vGlobal sublist] toGrRing /ii set
2805: % [ii jj vlist [(partialEcartGlobalVarX) vGlobal]] ecart.isSameIdeal $B$H;H$&(B.
2806: %>
2807: /getGrRing {
2808: /arg1 set
2809: [/vlist /vw_vector /ans /vGlobal /sublist /newvlist
2810: /dlist /tt /i /u /v /k
2811: ] pushVariables
2812: [
2813: /vlist arg1 0 get def
2814: /vw_vector arg1 1 get def
2815:
2816: vlist isString { [vlist to_records pop] /vlist set } { } ifelse
2817: vlist { toString } map /vlist set
2818: % dlist $B$O(B [(Dx) (Dy) (Dz)] $B$N%j%9%H(B.
2819: vlist { /tt set [@@@.Dsymbol tt] cat } map /dlist set
2820:
2821: /newvlist [ ] def /sublist [ ] def /vGlobal [ ] def
2822: % $B2D49$J?7$7$$JQ?t$r(B newvlist $B$X(B. $BCV49I=$r(B sublist $B$X(B.
2823: 0 1 vlist length 1 sub {
2824: /i set
2825: % (u,v) $B$O(B (x_i, Dx_i) $B$KBP$9$k(B weight vector
2826: /u vlist i get , vw_vector getGrRing.find def
2827: u -1 gt {
2828: vw_vector , u 1 add , get /u set
2829: } { /u 0 def } ifelse
2830:
2831: /v dlist i get , vw_vector getGrRing.find def
2832: v -1 gt {
2833: vw_vector , v 1 add , get /v set
2834: } { /v 0 def } ifelse
2835: u to_int32 /u set , v to_int32 /v set
2836:
2837: u v add , 0 gt {
2838: newvlist [vlist i get] join /newvlist set
2839: } { } ifelse
2840: u 0 lt {
2841: vGlobal [vlist i get] join /vGlobal set
2842: } { } ifelse
2843: } for
2844:
2845: newvlist { /tt set [ [@@@.Dsymbol tt] cat [tt (')] cat ] } map
2846: /sublist set
2847:
2848: /ans [ vlist , newvlist { /tt set [tt (')] cat } map , join from_records
2849: vGlobal sublist] def
2850: /arg1 ans def
2851: ] pop
2852: popVariables
2853: arg1
2854: } def
2855:
2856: %<
2857: % Usages: a uset getGrRing.find index
2858: %>
2859: /getGrRing.find {
2860: /arg2 set /arg1 set
2861: [/a /uset /ans /i] pushVariables
2862: [
2863: /a arg1 def /uset arg2 def
2864: /ans -1 def
2865: { /ans -1 def
2866: 0 1 , uset length 1 sub {
2867: /i set
2868: a tag , uset i get tag eq {
2869: a , uset i get eq {
2870: /ans i def exit
2871: } { } ifelse
2872: } { } ifelse
2873: } for
2874: exit
2875: } loop
2876: /arg1 ans def
2877: ] pop
2878: popVariables
2879: arg1
2880: } def
2881:
2882: %<
2883: % Usages: g1 g2 isSameGrRing bool
2884: % g1, g2 $B$O(B getGrRing $B$NLa$jCM(B.
2885: %>
2886: /isSameGrRing {
2887: /arg2 set /arg1 set
2888: [/g1 /g2 /ans] pushVariables
2889: [
2890: /g1 arg1 def /g2 arg2 def
2891: {
2892: /ans 1 def
2893: g1 0 get , g2 0 get eq { } { /ans 0 def exit } ifelse
2894: exit
2895: g1 1 get , g2 1 get eq { } { /ans 0 def exit } ifelse
2896: } loop
2897: /arg1 ans def
2898: ] pop
2899: popVariables
2900: arg1
2901: } def
2902:
2903: %<
2904: % Usages: [[ii i_vw_vector] [jj j_vw_vector] vlist] isSameInGrRing_h
1.4 takayama 2905: % It computes gb.
1.3 takayama 2906: %>
2907: /isSameInGrRing_h {
2908: /arg1 set
2909: [/ii /i_vw_vector /jj /j_vw_vector /vlist
2910: /i_gr /j_gr /rrule /ans] pushVariables
2911: [
2912: /ii arg1 [0 0] get def
2913: /i_vw_vector arg1 [0 1] get def
2914: /jj arg1 [1 0] get def
2915: /j_vw_vector arg1 [1 1] get def
2916: /vlist arg1 2 get def
2917: {
2918: [vlist i_vw_vector] getGrRing /i_gr set
2919: [vlist j_vw_vector] getGrRing /j_gr set
2920: i_gr j_gr isSameGrRing { } { /ans [0 [i_gr j_gr]] def exit} ifelse
2921:
2922: % bug: in case of module
2923: [i_gr 0 get , ring_of_differential_operators 0] define_ring
2924:
2925: % H $B$r(B 1 $B$K(B.
2926: /rrule [ [@@@.Hsymbol . (1).] ] def
2927:
2928: i_gr 2 get length 0 eq {
2929: } {
2930: rrule i_gr 2 get { { . } map } map join /rrule set
2931: } ifelse
2932: ii { toString . rrule replace toString } map /ii set
2933: jj { toString . rrule replace toString } map /jj set
2934:
2935: [ii jj i_gr 0 get , i_gr 1 get] ecartd.isSameIdeal_h /ans set
2936: [ans [i_gr] rrule ecartd.isSameIdeal_h.failed] /ans set
2937:
2938: exit
2939: } loop
2940: /arg1 ans def
2941: ] pop
2942: popVariables
2943: arg1
2944: } def
2945:
2946: /test1.isSameInGrRing_h {
2947: [(parse) (data/test8-data.sm1) pushfile] extension
2948:
2949: cone.gblist 0 get (initial) getNode 2 get /ii set
2950: cone.gblist 0 get (weight) getNode [2 0 2] get /iiw set
2951:
2952: cone.gblist 1 get (initial) getNode 2 get /jj set
2953: cone.gblist 1 get (weight) getNode [2 0 2] get /jjw set
2954:
2955: (Doing [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ff set) message
2956: [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ff set
2957:
2958: ff pmat
2959:
2960: } def
2961:
2962:
2963: %<
1.4 takayama 2964: % Usages: i j isSameCone_h.0 [bool, ...]
2965: % $B%F%9%HJ}K!(B. (data/test8.sm1) run (data/test8-data.sm1) run 0 1 isSameCone_h.0
2966: % gb $B$r:FEY7W;;$9$k(B stand alone $BHG(B. gr(Local ring) $B$GHf3S(B.
1.3 takayama 2967: %>
1.4 takayama 2968: /isSameCone_h.0 {
1.3 takayama 2969: /arg2 set /arg1 set
2970: [/i /j /ans /ii /iiw /jj /jjw] pushVariables
2971: [
2972: /i arg1 def /j arg2 def
1.4 takayama 2973: i to_int32 /i set , j to_int32 /j set
1.3 takayama 2974: cone.debug { (Comparing ) messagen [i j] message } { } ifelse
2975:
2976: cone.gblist i get (initial) getNode 2 get /ii set
2977: cone.gblist i get (weight) getNode [2 0 2] get /iiw set
2978:
2979: cone.gblist j get (initial) getNode 2 get /jj set
2980: cone.gblist j get (weight) getNode [2 0 2] get /jjw set
2981:
2982: [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ans set
2983:
2984: ans /arg1 set
2985: ] pop
2986: popVariables
2987: arg1
2988: } def
2989:
1.4 takayama 2990: %<
2991: % Usages: [ii vv i_vw_vector] getGbInGrRing_h [ii_gr i_gr]
2992: % Get Grobner Basis of ii in the graded ring.
2993: % The graded ring is obtained automatically from vv and i_vw_vector.
2994: % ii_gr is the Grobner basis. i_gr is the output of getGrRing.
2995: % cf. isSameInGrRing_h, ecart.isSameIdeal_h with [(noRecomputation) 1]
2996: %>
2997: /getGbInGrRing_h {
2998: /arg1 set
2999: [/ii /i_vw_vector /vlist /rng /vv /vvGlobal /wv /iigg
3000: /i_gr /rrule /ans] pushVariables
3001: [
3002: /ii arg1 0 get def
3003: /vlist arg1 1 get def
3004: /i_vw_vector arg1 2 get def
3005: [vlist i_vw_vector] getGrRing /i_gr set
3006:
3007: % bug: in case of module
3008: [i_gr 0 get , ring_of_differential_operators 0] define_ring
3009:
3010: % H $B$r(B 1 $B$K(B.
3011: /rrule [ [@@@.Hsymbol . (1).] ] def
3012:
3013: i_gr 2 get length 0 eq {
3014: } {
3015: rrule i_gr 2 get { { . } map } map join /rrule set
3016: } ifelse
3017: /vvGlobal i_gr 1 get def
3018: /vv i_gr 0 get def
3019:
3020: ii { toString . rrule replace toString } map /ii set
3021:
3022: [vv vvGlobal] ecart.stdBlockOrder /wv set
3023: vvGlobal length 0 eq {
3024: /rng [vv wv ] def
3025: }{
3026: /rng [vv wv [(partialEcartGlobalVarX) vvGlobal]] def
3027: } ifelse
3028: /save-cone.autoHomogenize ecart.autoHomogenize def
3029: /ecart.autoHomogenize 0 def
3030: [ii] rng join ecartd.gb /iigg set
3031: save-cone.autoHomogenize /ecart.autoHomogenize set
3032: /ans [iigg 0 get i_gr] def
3033: /arg1 ans def
3034: ] pop
3035: popVariables
3036: arg1
3037: } def
3038:
3039: /test1.getGbInGrRing_h {
3040: [(parse) (data/test8-data.sm1) pushfile] extension
3041:
3042: cone.gblist 0 get (initial) getNode 2 get /ii set
3043: cone.gblist 0 get (weight) getNode [2 0 2] get /iiw set
3044: [ii cone.vv iiw] getGbInGrRing_h /ff1 set
3045:
3046: cone.gblist 1 get (initial) getNode 2 get /jj set
3047: cone.gblist 1 get (weight) getNode [2 0 2] get /jjw set
3048: [jj cone.vv jjw] getGbInGrRing_h /ff2 set
3049:
3050: (ff1 and ff2) message
3051:
3052: } def
3053:
3054:
3055: %<
3056: % setGrGblist
3057: % cone.grGblist $B$r@_Dj$9$k(B.
3058: %>
3059: /setGrGblist {
3060: [/ii /ww /gg] pushVariables
3061: [
3062: cone.gblist {
3063: /gg set
3064: gg (initial) getNode 2 get /ii set
3065: gg (weight) getNode [2 0 2] get /ww set
3066: [ii cone.vv ww] getGbInGrRing_h
3067: } map /cone.grGblist set
3068: ] pop
3069: popVariables
3070: } def
3071:
3072: %<
3073: % Usages: i j isSameCone_h.2 [bool, ...]
3074: % gb $B$r:FEY7W;;$7$J$$(B.
3075: %>
3076: /isSameCone_h.2 {
3077: /arg2 set /arg1 set
3078: [/i /j /ans /ii /iiw /jj /jjw] pushVariables
3079: [
3080: /i arg1 def /j arg2 def
3081: i to_int32 /i set , j to_int32 /j set
3082: (cone.grGblist) boundp { } { setGrGblist } ifelse
3083: cone.debug { (Comparing ) messagen [i j] message } { } ifelse
3084:
3085: cone.grGblist i get /ii set
3086: cone.grGblist j get /jj set
3087:
3088: ii 1 get , jj 1 get isSameGrRing { }
3089: { /ans [0 [ii 1 get jj 1 get]] def exit} ifelse
3090:
3091: [ii 0 get , jj 0 get cone.vv [[(noRecomputation) 1]] ]
3092: ecartd.isSameIdeal_h /ans set
3093: [ans [ii 1 get] ii 1 get , ecartd.isSameIdeal_h.failed] /ans set
3094:
3095: ans /arg1 set
3096: ] pop
3097: popVariables
3098: arg1
3099: } def
3100:
3101: %<
3102: % test1.isSameCone_h.2 $B$O(B cone.grGblist $B$K(B initial $B$N(B gb $B$r(B graded ring
3103: % $B$G$^$:7W;;$7(B, $B$=$l$+$i(B ideal $B$NHf3S$r$*$3$J$&(B. isSameCone_h.1 $B$KHf$Y$F(B
3104: % gb $B$N:FEY$N7W;;$,$J$$$N$G7P:QE*(B.
3105: %>
3106: /test1.isSameCone_h.2 {
3107: /cone.loaded boundp { }
3108: {
3109: [(parse) (cohom.sm1) pushfile] extension
3110: [(parse) (dhecart.sm1) pushfile] extension
3111: /cone.loaded 1 def
3112: } ifelse
3113: %[(parse) (cone.sm1) pushfile] extension
3114: [(parse) (data/test8-data.sm1) pushfile] extension
3115: setGrGblist
3116: (cone.grGblist is set.) message
3117: 0 1 isSameCone_h.2 pmat
3118: } def
3119:
3120: %<
3121: % dhcone $B$O(B DeHomogenized Cone $B$NN,(B. H->1 $B$H$7$F(B cone $B$r(B merge $B$7$F$$$/4X?t(B
3122: % $B$dBg0hJQ?t$K;H$&(B.
3123: % cone.gblist, cone.fan $B$,@5$7$/@_Dj$5$l$F$$$k$3$H(B.
3124: % (setGrGblist $B$r<B9T:Q$G$"$k$3$H(B. $B<+F0<B9T$5$l$k$,(B... )
3125: %
3126: %>
3127:
3128: /isSameCone_h { isSameCone_h.2 } def
3129:
3130: %<
3131: % Usages: genDhcone.init
3132: % dhcone.checked (dehomogenized $B:Q$N(B cone$BHV9f(B), dhcone.unchecked $B$N=i4|2=(B.
3133: %>
3134: /genDhcone.init {
3135: /dhcone.checked [ ] def
3136: /dhcone.unchecked [
3137: 0 1 cone.fan length 1 sub {
3138: to_univNum
3139: } for
3140: ] def
3141: } def
3142:
3143: %<
3144: % Usages: k genDhcone dhcone
3145: % cone.fan[k] $B$r=PH/E@$H$7$F(B cone $B$r(B dehomogenize $B$9$k(B (merge $B$9$k(B).
3146: %
3147: % $B%F%9%H(B1. (data/test14.sm1) run (data/test14-data.sm1) run
3148: % genDhcone.init
3149: % 0 genDhcone /ff set
3150: %>
3151:
3152: /genDhcone {
3153: /arg1 set
3154: [/k /facets /merged /nextcid /nextfid /coneid
3155: /newfacets /newmerged /newnextcid /newnextfid /newconeid /vv
3156: /i /j /p /q /rr /cones /differentC
3157: ] pushVariables
3158: [
3159: /k arg1 def
3160: /facets [ ] def /merged [ ] def /nextcid [ ] def
3161: /nextfid [ ] def /coneid [ ] def
3162: /cones [ ] def
3163: /differentC [ ] def
3164:
3165: k to_univNum /k set
3166:
3167: {
3168: % Step1. cone.fan[k] $B$r(B $B2C$($k(B. new... $B$X=i4|%G!<%?$r=q$-9~$`(B.
3169: cone.debug {(Step 1. Adding ) messagen k messagen (-th cone.) message} { } ifelse
3170: cones [k to_univNum] join /cones set
3171: cone.fan k get , (facets) getNode 2 get /vv set
3172: /newfacets [ ] vv join def
3173:
3174: cone.fan k get , (nextcid) getNode 2 get /vv set
3175: /newnextcid [ ] vv join def
3176:
3177: cone.fan k get , (nextfid) getNode 2 get /vv set
3178: /newnextfid [ ] vv join def
3179:
3180: % newmerged $B$O$^$:(B 0 $B$G$&$a$k(B. 0 : $B$^$@D4$Y$F$J$$(B.
3181: % 1 : merged $B$G>C$($?(B. 2 : boundary. 3 : $B$H$J$j$O0[$J$k(B.
3182: % [ ] join $B$r$d$C$F(B $B%Y%/%H%k$N(B clone $B$r:n$k(B.
3183: cone.fan k get , (flipped) getNode 2 get /vv set
3184: /newmerged [ ] vv join def
3185: 0 1 , newmerged length 1 sub {
3186: /i set
3187: newmerged i get , (2).. eq { }
3188: { newmerged i (0).. put } ifelse
3189: } for
3190: % newconeid $B$O(B k $B$G$&$a$k(B.
3191: /newconeid newfacets length newVector { pop k to_univNum } map def
3192:
3193: % merged $B$H(B newmerged $B$r(B cone $B$NNY@\4X78$N$_$G99?7$9$k(B.
3194: % $BF1$8(B init $B$r;}$D$3$H$O$o$+$C$F$$$k$N$G(B facet vector $B$N$_$N(B check $B$G==J,(B.
3195: % merged $B$N(B i $BHVL\(B $B$H(B newmerged $B$N(B j $BHVL\$GHf3S(B.
3196: 0 1 , merged length 1 sub {
3197: /i set
3198: 0 1 , newmerged length 1 sub {
3199: /j set
3200: merged i get , (0).. eq ,
3201: newmerged j get , (0).. eq , and
3202: nextcid i get , k to_univNum eq , and
3203: {
3204: facets i get , newfacets j get , add isZero {
3205: % merged[i], newmerged[j] $B$K(B 1 $B$rF~$l$F>C$9(B.
3206: % $B>e$NH=Dj$O(B nextfid, newnextfid $B$rMQ$$$F$b$h$$$N$G$O(B?
3207: merged i (1).. put
3208: newmerged j (1).. put
3209: } { } ifelse
3210: } { } ifelse
3211: } for
3212: } for
3213:
3214: % Step2. $B7k9g$7$F$+$i(B, $B$^$@D4$Y$F$J$$(B facet $B$rC5$9(B.
3215: cone.debug { (Step 2. Joining *** and new***) message } { } ifelse
3216: /facets facets newfacets join def
3217: /merged merged newmerged join def
3218: /nextcid nextcid newnextcid join def
3219: /nextfid nextfid newnextfid join
3220: /coneid coneid newconeid join def
3221:
3222: cone.debug{ ( Checking facets.) message } { } ifelse
3223: /k null def
3224: 0 1 , merged length 1 sub {
3225: /i set
3226: % i message
3227: merged i get (0).. eq {
3228: % i $BHVL\$r$^$@D4$Y$F$$$J$$(B.
3229: coneid i get , /p set
3230: nextcid i get , /q set
3231: cone.debug { [p q] message } { } ifelse
3232: q (0).. ge {
3233: % cone.fan [p] $B$H(B cone.fan [q] $B$N(B initial $B$rHf3S$9$k(B.
3234: % $BF1$8$J$i(B k $B$r@_Dj(B. exit for. $B0c$($P(B merged[i] = 3 ($B0c$&(B) $B$rBeF~(B.
3235: % differentC $B$O$9$G$K(B $B8=:_$N(B dhcone $B$H0c$&$H(B check $B$5$l$?(B cone $BHV9f(B.
3236: % dhcone.checked $B$O(B dhcone $B$,$9$G$K@8@.$5$l$F$$$k(B cone $BHV9f$N%j%9%H(B.
3237: % $B$3$l$K$O$$$C$F$$$F$b0c$&(B.
3238: q differentC memberQ , q dhcone.checked memberQ , or
3239: { /rr [0 ] def }
3240: { p q isSameCone_h /rr set } ifelse
3241:
3242: rr 0 get 1 eq {
3243: cone.debug { (Found next cone. ) message } { } ifelse
3244: /k q to_univNum def exit
3245: } {
3246: cone.debug { ( It is a different cone. ) message } { } ifelse
3247: differentC [ q ] join /differentC set
3248: merged i (3).. put
3249: } ifelse
3250: } { } ifelse
3251: } { } ifelse
3252: } for
3253:
3254: k tag 0 eq { exit } { } ifelse
3255: } loop
3256:
3257: [(-1)..] cones join shell rest /cones set
3258: % dhcone.checked, dhcone.unchecked $B$r99?7(B.
3259: dhcone.checked cones join /dhcone.checked set
3260: dhcone.unchecked cones setMinus /dhcone.unchecked set
3261:
3262: [(dhcone) [ ]
3263: [
3264: [(cones) [ ] cones] arrayToTree
3265: [(facets) [ ] facets] arrayToTree
3266: [(merged) [ ] merged] arrayToTree
1.5 takayama 3267: [(nextcid) [ ] nextcid] arrayToTree
3268: [(nextfid) [ ] nextfid] arrayToTree
3269: [(coneid) [ ] coneid] arrayToTree
1.4 takayama 3270: ]
3271: ] arrayToTree /arg1 set
3272: ] pop
3273: popVariables
3274: arg1
3275: } def
3276:
3277:
3278: %<
3279: % Usages: dhCones_h
3280: % cone.fan $B$O(B doubly homogenized (local) $B$G@8@.$5$l$?(B Grobner fan.
3281: % cone.fan $B$r(B dehomogenize (H->1) $B$7$F(B init $B$rHf$Y$F(B dhcone.fan $B$r@8@.$9$k(B.
3282: %
3283: % $B%F%9%H(B1. (data/test14.sm1) run (data/test14-data.sm1) run
3284: % dhCones_h
3285: % test22
3286: %>
3287: /dhCones_h {
3288: (cone.grGblist) boundp { } {setGrGblist} ifelse
3289: genDhcone.init
3290: /dhcone.fan [ ] def
3291: {
3292: (-----------------------------------------) message
3293: (#dhcone.unchecked = ) messagen dhcone.unchecked length message
3294: dhcone.unchecked length 0 eq { exit } { } ifelse
3295: dhcone.fan
3296: [ dhcone.unchecked 0 get , genDhcone ] join /dhcone.fan set
3297: (#dhcone.fan = ) messagen dhcone.fan length message
3298: } loop
3299: dhcone.fan
3300: } def
3301:
1.5 takayama 3302: %<
3303: % Usages: dhcone.rtable
3304: % 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)
3305: % $B$r(B dhcone.fan $B$+$i:n$k(B. dhcone2.gblist $B$b:n$kJd=u4X?t(B.
3306: % dhCones_h $B$7$F$+$i(B dhcone.rable $B$9$k(B.
3307: %>
3308: /dhcone.rtable {
3309: [/i /j /vv /cones /facets /facets2 /merged /nextcid /nextcid2 /ii /ww] pushVariables
3310: [
3311: % $BCV49I=(B dhcone.h2dh $B$r:n$k(B.
3312: /dhcone.h2dh cone.fan length newVector.with-1 def
3313: 0 1 , dhcone.fan length 1 sub {
3314: /i set
3315: dhcone.fan i get , (cones) getNode 2 get /vv set
3316: 0 1 vv length 1 sub {
3317: /j set
3318: dhcone.h2dh , vv j get , i to_univNum , put
3319: } for
3320: } for
3321: % merge $B$7$?(B dhcone $B$r@0M}$7$?$b$N(B, dhcone2.fan $B$r:n$k(B.
3322: /dhcone2.fan dhcone.fan length newVector def
3323: 0 1 , dhcone.fan length 1 sub {
3324: /i set
3325: dhcone.fan i get (facets) getNode 2 get /facets set
3326: dhcone.fan i get (merged) getNode 2 get /merged set
3327: dhcone.fan i get (nextcid) getNode 2 get /nextcid set
3328: dhcone.fan i get (cones) getNode 2 get /cones set
3329: /facets2 [ ] def
3330: /nextcid2 [ ] def
3331: 0 1 , facets length 1 sub {
3332: /j set
3333: merged j get , (3).. eq {
3334: facets2 [ facets j get ] join /facets2 set
3335: % $B$H$J$j$N(B cone $B$,$"$k$H$-(B $BJQ49I=$K$7$?$,$$(B, cone $BHV9f$rJQ49(B
3336: nextcid2 [ dhcone.h2dh , nextcid j get , get ] join /nextcid2 set
3337: } { } ifelse
3338: merged j get , (2).. eq {
3339: facets2 [ facets j get ] join /facets2 set
3340: % $B6-3&$N$H$-(B -2 $B$rF~$l$k(B.
3341: nextcid2 [ (-2).. ] join /nextcid2 set
3342: } { } ifelse
3343: } for
3344:
3345: dhcone2.fan i ,
3346: [(dhcone) [ ]
3347: [
3348: [(facets) [ ] facets2] arrayToTree
3349: [(nextcid) [ ] nextcid2] arrayToTree
3350: [(cones) [ ] cones] arrayToTree
3351: ]
3352: ] arrayToTree , put
3353:
3354: } for
3355:
3356: % $B:G8e$K(B dhcone2.gblist $B$r:n$k(B.
3357: /dhcone2.gblist , dhcone2.fan length newVector , def
3358: 0 1 , dhcone2.fan length 1 sub {
3359: /i set
3360: dhcone2.fan i get (cones) getNode 2 get /cones set
3361: cone.grGblist , cones 0 get , get , /ii set % GB of initial (H->1).
3362: cone.gblist i get , (weight) getNode , [ 2 0 2 ] get /ww set
3363:
3364: dhcone2.gblist i,
3365: [(gbasis) [ ]
3366: [
3367: [(initial) [ ] ii] arrayToTree
3368: [(weight) [ ] ww] arrayToTree
3369: ]
3370: ] arrayToTree , put
3371:
3372: } for
3373: (dhcone2.fan, dhcone2.gblist, dhcone.h2dh are set.) message
3374:
3375: ] pop
3376: popVariables
3377: } def
3378:
3379: %<
3380: % $BI=$N8+J}$N2r@b$r0u:~$9$k4X?t(B.
3381: % Usages: dhcone.explain
3382: %>
3383: /dhcone.explain {
3384: [
3385: ( ) nl
3386: (Data format in << dhcone2.fan >>, which is a dehomogenized Grobner fan.) nl nl
3387: (<< cone.vlist >> is the list of the variables.) nl
3388: @@@.Hsymbol ( is the homogenization variable to be dehomogenized.) nl nl
3389: (<< cone.input >> is generators of a given ideal.) nl nl
3390: (<< cone.d >> is the dimension of parametrization space of the weights P_w) nl
3391: ( P_w is a cone in R^m where the number m is stored in << cone.m >>) nl
3392: ( P_w --- W ---> R^n [weight space]. ) nl
3393: ( W is stored in << cone.W >> ) nl
3394: ( << u cone.W mul >> gives the weight vector standing for u) nl nl
3395: (All cones in the data lie in the weight parametrization space P_w.) nl
3396: ( "facets" are the inner normal vector of the cone. ) nl
3397: ( "nextcid" is a list of the cone id's of the adjacent cones.) nl
3398: ( -2 in "nextcid" means that this facet lies on the border of the weight space.) nl
3399: ( "cones" is a list of the cone id's of the NON-dehomonized Grobner fan) nl
3400: ( stored in << cone.fan >>) nl
3401: ] cat
3402: } def
3403:
3404: %<
3405: % dhcone.printGrobnerFan
3406: % dhcone $B$N0u:~4X?t(B
3407: %>
3408: /dhcone.printGrobnerFan {
3409: [/i] pushVariables
3410: [
3411: (========== Grobner Fan (for dehomogenized cones) ============) message
3412: [
3413: (cone.comment)
3414: (cone.vlist) (cone.vv)
3415: (cone.input)
3416: (cone.type) (cone.local) (cone.h0)
3417: (cone.n) (cone.m) (cone.d)
3418: (cone.W) (cone.Wpos) (cone.Wt)
3419: (cone.L) (cone.Lp) (cone.Lpt)
3420: (cone.weightBorder)
3421: (cone.incidence)
3422: ] { printGrobnerFan.1 } map
3423: ( ) message
3424: (The number of cones = ) messagen dhcone.fan length message
3425: ( ) message
3426: 0 1 dhcone2.fan length 1 sub {
3427: /ii set
3428: ii messagen ( : ) messagen
3429: dhcone2.fan ii get printTree
3430: } for
3431: 1 {
3432: 0 1 dhcone2.gblist length 1 sub {
3433: /ii set
3434: ii messagen ( : ) messagen
3435: dhcone2.gblist ii get printTree
3436: } for
3437: } { } ifelse
3438:
3439:
3440: (=========================================) message
3441: %(cone.withGblist = ) messagen cone.withGblist message
3442: dhcone.explain message
3443: ( ) message
3444: ] pop
3445: popVariables
3446: } def
3447:
3448: %
3449: % $B;n$7J}(B test14, 22, 25
3450: %
3451: % (data/test14.sm1) run (data/test14-data.sm1) run
3452: % printGrobnerFan ; % H $BIU$-$G0u:~(B.
3453: % dhCones_h ; % dehomogenize Cones.
3454: % dhcone.rtable ; % dhcone2.fan $BEy$r@8@.(B.
3455: % dhcone.printGrobnerFan ; % $B0u:~(B.
3456: % $B0u:~$7$?$b$N$O(B test*-print.txt $B$X3JG<$7$F$"$k(B.
3457: %
3458:
3459: % Todo: save functions.
1.9 takayama 3460:
3461: %<
3462: % Collart, Kalkbrener, Mall $B$N%"%k%4%j%:%`$K$h$k(B gb $B$N(B flip.
3463: % See also Sturmfels' book, p.22, 23.
3464: % Usages: [reducedGb, vlist, oldWeight, facetWeight, newWeight] ckmFlip rGb
3465: % If it fails, then it returns null, else it returns the reducedGb for the
3466: % newWeight.
3467: % gb $B$N(B check $B$r$d$k$N$G(B, $B$=$l$K<:GT$7$?$i(B null $B$rLa$9(B.
3468: % weight $B$O$9$Y$F(B vw $B7A<0$G(B. vw $B7A<0(B = variable weight $B$N7+$jJV$7$N7A<0(B
3469: % reducedGb $B$OJ8;zNs$N%j%9%H$G$O$J$/B?9`<0$N7A<0$N$3$H(B.
1.11 takayama 3470: % $BM}M3$O(B reducedGb $B$h$j(B ring $B$N9=B$$rFI$`$?$a(B.
1.9 takayama 3471: %>
3472: /ckmFlip {
3473: /arg1 set
3474: [/arg_ckmFlip /gOld /vlist /oldWeight /facetWeight /newWeight
3475: /gNew
3476: /ww /ww1 /ww2 % $BK\$NCf$N(B w1, w, w2 ($B8E$$(B, facet, $B?7$7$$(B)
3477: /ch1 /ch2 % $BK\$NCf$N(B {\cal H}_1, {\cal H}_2
3478: /grData /rTable
3479: /rTable2 % rTable $B$NH?BP$NJQ49(B.
3480: /facetWeight_gr /vlist_gr % graded ring $BMQ(B.
3481: /oldWeight_gr
3482: /ccf % reduction $B$7$?78?t(B.
3483: /rwork /ccf2 /gNew
3484: ] pushVariables
3485: [
3486: arg1 /arg_ckmFlip set
3487: arg_ckmFlip 0 get /gOld set
3488: arg_ckmFlip 1 get /vlist set
3489: arg_ckmFlip 2 get /oldWeight set
3490: arg_ckmFlip 3 get /facetWeight set
3491: arg_ckmFlip 4 get /newWeight set
3492:
3493: % facet weight vector ww $B$K$D$$$F$N(B initial $B$r<h$j=P$9(B. ch1 $B$X$$$l$k(B.
3494: gOld getRing ring_def
3495: facetWeight weightv /ww set
3496: gOld { ww init } map /ch1 set % facetWeight $B$K$h$k(B initial $B$N<h$j=P$7(B.
3497:
3498:
3499: % $BNc(B: [(x,y) [(x) -1 (Dx) 1 (y) -1 (Dy) 2]] getGrRing
3500: % [$x,y,y',$ , [ $x$ , $y$ ] , [ [ $Dy$ , $y'$ ] ] ]
3501: % $BJQ?t%j%9%H(B $BCV49I=(B
3502: % ch1 $B$r(B gr_ww $B$N85$KJQ49(B.
3503: [vlist facetWeight] getGrRing /grData set
3504: [grData 0 get ring_of_differential_operators 0] define_ring /rwork set
3505: grData 2 get { { . } map } map /rTable set
3506: rTable { reverse } map /rTable2 set
3507: grData 0 get /vlist_gr set
3508: ch1 { toString . rTable replace toString } map /ch1 set
3509:
3510: oldWeight { dup isString { . rTable replace toString }
3511: { } ifelse } map /oldWeight_gr set
3512:
3513: % facetWeight $B$b(B $B?7$7$$4D(B gr_ww $B$N(B weight $B$KJQ49(B.
3514: % $BNc(B. [(x) -1 (Dx) 1 (y) -1 (Dy) 2] ==> [(x) -1 (Dx) 1 (y) -1 (y') 2]
3515: facetWeight { dup isString { . rTable replace toString }
3516: { } ifelse } map /facetWeight_gr set
1.11 takayama 3517:
3518: % newWeight $B$b(B $B?7$7$$4D(B gr_ww $B$N(B weight $B$KJQ49(B.
3519: % $BNc(B. [(x) -1 (Dx) 1 (y) -1 (Dy) 2] ==> [(x) -1 (Dx) 1 (y) -1 (y') 2]
3520: newWeight { dup isString { . rTable replace toString }
3521: { } ifelse } map /newWeight_gr set
3522:
1.9 takayama 3523: % Dx x = x Dx + h H or Dx x = x Dx + h^2 $B$G7W;;(B.
3524: % $B$I$A$i$r$H$k$+$O(B cone.gb_gr $B$G6hJL$9$k$7$+$J$7(B
3525: %% [ch1 vlist_gr oldWeight_gr] /ttt set
3526: %% ttt cone.gb_gr /ch1 set %$B:FEY$N7W;;$OITMW(B.
3527: [[(1)] vlist_gr oldWeight_gr] cone.gb_gr getRing ring_def % Set Ring.
3528: ch1 {toString .} map /ch1 set
3529: %% $B$3$3$^$G$G$H$j$"$($:%F%9%H$r$7$h$&(B.
3530: %% ch1 /arg1 set
3531: [ch1 { toString } map vlist_gr newWeight_gr] cone.gb_gr /ch2 set
3532:
3533: % Dx x = x Dx + h H or Dx x = x Dx + h^2 $B$G7W;;(B.
3534: % $B$I$A$i$r$H$k$+$O(B cone.reduction_gr $B$G6hJL$9$k$7$+$J$7(B
3535: ch1 getRing ring_def ;
3536: ch2 {toString .} map {ch1 cone.reduction} map /ccf set
3537: %ccf pmat
3538: % $B$H$j$"$($:%F%9%H(B.
3539: % [ch1 ch2] /arg1 set
3540: %% ccf[i][0] $B$O(B 0 $B$G$J$$$HL7=b(B. check $B$^$@$7$F$J$$(B.
3541:
3542: %% ccf[i][2] (syzygy) $B$r(B gr $B$+$i(B $B$b$H$N(B ring $B$XLa$7(B,
3543: %% $B?7$7$$(B reduced gbasis $B$r(B ccf[i][2] * gOld $B$G:n$k(B.
3544: rwork ring_def
3545: ccf { 2 get {toString . rTable2 replace toString} map } map /ccf2 set
3546: %% ccf2 $B$O(B gr $B$G$J$$(B ring $B$N85(B.
3547: gOld getRing ring_def
1.10 takayama 3548: cone.DhH { cone.begin_DhH } { } ifelse % Hh $B$+(B h^2 $B$+(B.
1.9 takayama 3549: ccf2 { {.} map gOld mul } map /gNew set
3550: gNew { toString } map /gNew set
1.10 takayama 3551: cone.DhH { cone.end_DhH } { } ifelse % Hh $B$+(B h^2 $B$+(B.
1.9 takayama 3552: % gNew /arg1 set
3553: %gNew $B$,(B newWeight $B$G$N(B GB $B$+(B check. Yes $B$J$i(B reduced basis $B$X(B.
3554: %No $B$J$i(B null $B$rLa$9(B.
1.10 takayama 3555: %%Ref: note @s/2005/06/30-note-gfan.pdf
1.12 ! takayama 3556: cone.do_gbCheck not {
! 3557: (Warning! gbCheck is skipped.) message
! 3558: } {
! 3559: (Doing gbCheck.) message
! 3560: } ifelse
! 3561: cone.do_gbCheck {
! 3562: gNew [(gbCheck) 1] setAttributeList newWeight
! 3563: cone.gb (gb) getAttribute
! 3564: } { 1 } ifelse
1.9 takayama 3565: 1 eq {
3566: gNew [(reduceOnly) 1] setAttributeList newWeight cone.gb /arg1 set
3567: }{ /arg1 null def } ifelse
3568: ] pop
3569: popVariables
3570: arg1
3571: } def
3572:
3573: %<
3574: % Usages: f gbasis cone.reduction_DhH
1.10 takayama 3575: % dx x = x dx + h H $B$G$N(B reduction.
1.9 takayama 3576: %>
3577: /cone.reduction_DhH {
3578: /arg2 set /arg1 set
3579: [/ff /ggbasis /eenv /ans] pushVariables
3580: [
3581: /ff arg1 def /ggbasis arg2 def
1.10 takayama 3582: cone.begin_DhH
3583: ff ggbasis reduction /ans set
3584: cone.end_DhH
3585: /arg1 ans def
3586: ] pop
3587: popVariables
3588: arg1
3589: } def
3590:
3591: %<
3592: % Usages: f gbasis cone.reduction_Dh
3593: % dx x = x dx + h^2 $B$G$N(B reduction.
3594: %>
3595: /cone.reduction_Dh {
3596: /arg2 set /arg1 set
3597: [/ff /ggbasis /eenv /ans] pushVariables
3598: [
3599: /ff arg1 def /ggbasis arg2 def
1.9 takayama 3600: ff ggbasis reduction /ans set
3601: /arg1 ans def
3602: ] pop
3603: popVariables
3604: arg1
3605: } def
3606:
1.10 takayama 3607: %<
3608: % Usages: cone.begin_DhH dx x = x dx + h H $B$r3+;O(B.
3609: %>
1.9 takayama 3610: /cone.begin_DhH {
3611: [(Homogenize) (AutoReduce) (KanGBmessage)] pushEnv /cone.eenv set
3612: [(Homogenize) 3] system_variable
3613: } def
3614:
1.10 takayama 3615: %<
3616: % Usages: cone.begin_DhH dx x = x dx + h H $B$r=*N;(B.
3617: %>
1.9 takayama 3618: /cone.end_DhH {
3619: cone.eenv popEnv
3620: } def
3621:
1.10 takayama 3622: %<
3623: % Usages: ff vv ww cone.gb_gr_DhH dx x = x dx + h H $B$G7W;;(B.
3624: % dh.gb $B$O(B dhecart.sm1 $B$GDj5A$5$l$F$*$j(B, dx x = x dx + h H $B$G$N7W;;(B.
3625: % gr $B$r$H$C$F$b(B, -w,w $B$N>l9g$O(B $BHyJ,:nMQAG4D$N$^$^$G$"$j(B, $B$3$l$,I,MW(B.
3626: % bug? cone.gb $B$G==J,(B?
3627: %>
3628: /cone.gb_gr_DhH {
3629: /arg1 set
3630: [/ff /ww /vv] pushVariables
3631: [
3632: /ff arg1 0 get def
3633: /vv arg1 1 get def
3634: /ww arg1 2 get def
3635: /dh.gb.verbose 1 def
3636: /dh.autoHomogenize 0 def
3637: [(AutoReduce) 1] system_variable
3638: [ff { toString } map vv
3639: [ww vv generateD1_1]] dh.gb 0 get /arg1 set
3640: ] pop
3641: popVariables
3642: arg1
3643: } def
3644: %<
3645: % Usages: ff vv ww cone.gb_gr_Dh dx x = x dx + h^2 $B$G7W;;(B.
3646: % gb $B$O(B dhecart.sm1 $B$GDj5A$5$l$F$*$j(B, dx x = x dx + h^2 $B$G$N7W;;(B.
3647: % gr $B$r$H$C$F$b(B, -w,w $B$N>l9g$O(B $BHyJ,:nMQAG4D$N$^$^$G$"$j(B, $B$3$l$,I,MW(B.
3648: % bug? cone.gb $B$G==J,(B?
3649: %>
3650: /cone.gb_gr_Dh {
3651: /arg1 set
1.11 takayama 3652: [/ff /ww /vv /gg /envtmp] pushVariables
1.10 takayama 3653: [
3654: /ff arg1 0 get def
3655: /vv arg1 1 get def
3656: /ww arg1 2 get def
1.11 takayama 3657:
3658: [(AutoReduce) (KanGBmessage)] pushEnv /envtmp set
1.10 takayama 3659: [(AutoReduce) 1] system_variable
1.11 takayama 3660: [(KanGBmessage) 1] system_variable
3661: [vv ring_of_differential_operators
3662: [ww] weight_vector 0] define_ring
3663: [ff {toString .} map] ff getAttributeList setAttributeList
3664: groebner 0 get /gg set
3665: envtmp popEnv
3666:
3667: /arg1 gg def
1.10 takayama 3668: ] pop
3669: popVariables
3670: arg1
3671: } def
3672:
3673:
3674: % $B$3$l$i$O(B cone.ckmFlip 1 $B$N;~$7$+;H$o$:(B.
3675: /cone.reduction {
3676: cone.DhH {
3677: cone.reduction_DhH
3678: }{
3679: cone.reduction_Dh
3680: } ifelse
3681: } def
3682: /cone.gb_gr {
3683: cone.DhH {
3684: cone.gb_gr_DhH
3685: }{
3686: cone.gb_gr_Dh
3687: } ifelse
3688: } def
3689:
3690:
1.9 takayama 3691: /test1.ckmFlip {
3692: % cf. cone.sample2
3693: cone.load.cohom
3694: /cone.comment [
3695: (BS for y and y-(x-1)^2, t1, t2 space, in doubly homogenized Weyl algebra.) nl
3696: (The Grobner cones are dehomogenized to get local Grobner fan.) nl
3697: ] cat def
3698: /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h) (H)] def
3699: /cone.vv (t1,t2,x,y) def
3700: /cone.type 1 def
3701: /cone.parametrizeWeightSpace {
3702: 4 2 parametrizeSmallFan
3703: } def
1.10 takayama 3704:
3705: /cone.DhH 1 def
3706: /cone.ckmFlip 1 def
3707:
1.9 takayama 3708: /cone.local 1 def
3709: /cone.w_start null def
3710: /cone.h0 1 def
3711: /cone.input
3712: [
3713: (t1-y) (t2 - (y-(x-1)^2))
3714: ((-2 x + 2)*Dt2+Dx)
3715: (Dt1+Dt2+Dy)
3716: ]
3717: def
3718: % homogenize
3719: [cone.vv ring_of_differential_operators
3720: [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
3721: 0] define_ring
3722: dh.begin
3723: cone.input { . homogenize toString } map /cone.input set
3724: dh.end
3725:
3726:
3727: % $B%F%9%H$r3+;O$9$k(B.
3728: % getStartingCone /cone.ncone set
3729: % cone.ncone updateFan
3730: % cone.gblist 0 get message
3731: % cone.ncone /cone.ccone set
3732: % getNextFlip /cone.nextflip set
3733: % cone.nextflip message
3734:
3735: /wOld [(t1) , -29 , (t2) , -38 , (Dt1) , 29 , (Dt2) , 38 ] def
3736: /wFacet [(t1) , -1 , (t2) , -1 , (Dt1) , 1 , (Dt2) , 1 ] def
3737: /wNew [(t1) , -39 , (t2) , -38 , (Dt1) , 39 , (Dt2) , 38 ] def
3738: cone.input wOld cone.gb /ff set
3739: [ff (t1,t2,x,y) wOld wFacet wNew] ckmFlip /ff2 set
3740: (See ff and ff2) message
3741:
1.11 takayama 3742: } def
3743:
3744: %<
3745: % Usages: cone i getaVectorOnFacet
3746: % cone $B$N(B i $BHVL\$N(B facet $B$N>e$N(B vector $B$r5a$a$k(B.
3747: % cf. liftWeight
3748: %>
3749: /getaVectorOnFacet {
3750: /arg2 set /arg1 set
3751: [/cone /facet_i /ep /vp /v /v /ii] pushVariables
3752: [
3753: /cone arg1 def /facet_i arg2 def
3754: facet_i to_int32 /facet_i set
3755:
3756: cone (facetsv) getNode 2 get facet_i get /v set
3757: /vp v 0 get def
3758: 1 1 v length 1 sub {
3759: /ii set
3760: vp v ii get add /vp set
3761: } for
3762: vp nnormalize_vec /vp set
3763: /arg1 vp def
3764: ] pop
3765: popVariables
3766: arg1
3767: } def
3768:
3769: /getNextCone {
3770: getNextCone_ckm
3771: } def
3772:
3773: %<
3774: % Usages: result_getNextFlip getNextCone_ckm ncone
3775: % flip $B$7$F?7$7$$(B ncone $B$rF@$k(B. Collar-Kalkbrener-Moll $B$N%"%k%4%j%:%`$r;H$&(B
3776: % if (cone.ckmFlip == 0) $BIaDL$N7W;;(B else CKM.
3777: %>
3778: /getNextCone_ckm {
3779: /arg1 set
3780: [/ncone /ccone /kk /w /next_weight_w_wv /cid /ttt] pushVariables
3781: [
3782: /ccone arg1 def
3783: /ncone null def
3784: /kk ccone 1 get def % kk $B$O(B cid $BHVL\$N(B cone $B$N(B kk $BHVL\$N(B facet $B$rI=$9(B.
3785: /cid ccone 2 get def % cid $B$O(B cone $B$N(B $BHV9f(B.
3786: ccone 0 get /ccone set
3787: {
3788: ccone tag 0 eq { exit } { } ifelse
3789:
3790: % ccone $B$N(B kk $BHVL\$N(B facet $B$K$D$$$F(B flip $B$9$k(B.
3791: ccone kk cone.epsilon flipWeight /w set
3792: (Trying new weight is ) messagen w message
3793: w liftWeight /next_weight_w_wv set
3794: (Trying new weight [w,wv] is ) messagen next_weight_w_wv message
3795:
3796: cone.ckmFlip {
3797: [
3798: cone.gblist cid get (grobnerBasis) getNode 2 get % reduce gb
3799: cone.vv
3800: cone.gblist cid get (weight) getNode [2 0 2] get % weight
3801: ccone kk getaVectorOnFacet liftWeight 1 get % weight on facet
3802: next_weight_w_wv 1 get % new weight
3803: ] /ttt set
3804: ttt message
3805: ttt ckmFlip /cone.cgb set
3806: }{
3807: cone.input next_weight_w_wv 1 get cone.gb /cone.cgb set
3808: } ifelse
3809:
3810: cone.cgb tag 0 eq not {
3811: [w] next_weight_w_wv join /cone.cgb_weight set
3812: next_weight_w_wv 1 get cone.cgb coneEq /cone.g_ineq set
3813: cone.g_ineq cone.w_ineq join cone.Wt mul cone.Lpt mul
3814: pruneZeroVector /cone.gw_ineq_projectedWtLpt set
3815:
3816: (cone.gw_ineq_projectedWtLpt is obtained.) message
3817:
3818: cone.gw_ineq_projectedWtLpt getConeInfo /cone.nextConeInfo set
3819: % $B<!85$rD4$Y$k(B. $B$@$a$J$i(B retry
3820: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
3821: cone.nextConeInfo 1 get newCone /ncone set
3822: ccone ncone getCommonFacet 0 get {
3823: (Flip succeeded.) message
3824: exit
3825: } { } ifelse
3826: } { } ifelse
3827: % common face $B$,$J$1$l$P(B $B$d$O$j(B epsilon $B$r>.$5$/(B.
3828: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
3829: (ccone and ncone do not have a common facet.) message
3830: } {
3831: (ncone is not maximal dimensional. ) message
3832: } ifelse
3833: }{ } ifelse
3834:
3835: (Decreasing epsilon to ) messagen
3836: cone.epsilon (1).. (2).. div mul /cone.epsilon set
3837: cone.epsilon cone.epsilon.limit sub numerator (0).. lt {
3838: (Too small cone.epsilon ) error
3839: } { } ifelse
3840: cone.epsilon message
3841: } loop
3842: /arg1 ncone def
3843: ] pop
3844: popVariables
3845: arg1
1.9 takayama 3846: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>