Annotation of OpenXM/src/kan96xx/Doc/gfan.sm1, Revision 1.14
1.14 ! takayama 1: % $OpenXM: OpenXM/src/kan96xx/Doc/gfan.sm1,v 1.13 2009/08/26 04:54:17 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
1.13 takayama 1027:
1028: ceq length 0 eq {
1029: (Monomial ideal is not accepted as an input.) cone_ir_input
1030: } { } ifelse
1031:
1.1 takayama 1032: ceq genPo2 /ceq2 set
1033: % ceq2 $B$O(B polymake.data(polymake.INEQUALITIES(...)) $B7A<0(B
1034: % polymake $B$G(B ceq2 $B$N<!85$N7W;;(B.
1035: /getConeInfo.ceq ceq def /getConeInfo.ceq2 ceq2 def
1036:
1037: cone.debug { (Calling polymake DIM.) message } { } ifelse
1038: [(DIM) ceq2] doPolymake 1 get /rr set
1039: cone.debug {(Done.) message } { } ifelse
1040: % test5 $B$K$O<!$N%3%a%s%H$H$j$5$k(B. $B>e$N9T$r%3%a%s%H%"%&%H(B.
1041: % test5.data tfbToTree /rr set
1042: /cone.getConeInfo.rr0 rr def
1043:
1044: rr (DIM) getNode /cdim set
1045: cdim 2 get 0 get 0 get 0 get to_univNum /cdim set
1046: % polymake $B$N(B DIM $B$O0l$D>.$5$$$N$G(B 1 $BB-$9(B.
1047: cdim (1).. add /cdim set
1048:
1049: rr (FACETS) getNode tag 0 eq {
1050: % FACETS $B$r;}$C$F$$$J$$$J$i:FEY7W;;$9$k(B.
1051: % POINTED, NOT__POINTED $B$bF@$i$l$k(B
1052: cone.debug { (Calling polymake FACETS.) message } { } ifelse
1053: [(FACETS) ceq2] doPolymake 1 get /rr set
1054: cone.debug { (Done.) message } { } ifelse
1055: } { } ifelse
1056:
1057: rr (VERTICES) getNode tag 0 eq {
1058: (internal error: VERTICES is not found.) error
1059: } { } ifelse
1060:
1061: /cone.getConeInfo.rr1 rr def
1062:
1063: rr (NOT__POINTED) getNode tag 0 eq {
1064: % cone $B$,(B pointed $B$N;~$O(B mmc $B$OC10L9TNs(B. genUnitMatrix $B$r;H$&(B.
1065: % VERTICES $B$h$j0l$D>.$5$$%5%$%:(B.
1066: /mmc
1067: [ rr (VERTICES) getNode 2 get 0 get 0 get rest]
1068: genUnitMatrix
1069: def
1070: /mmL [ ] def
1071: /ppt (POINTED) def
1072: } {
1073: % pointed $B$G$J$$>l9g(B,
1074: % cone $B$N@~7AItJ,6u4V$r7W;;(B.
1075: rr getLinearitySubspace /mmL set
1076: [mmL genUnit] mmL join /mmc set % [1,0,0,...] $B$rB-$9(B.
1077: mmc asir_matrix_kernel /mmc set % $BJd6u4V(B
1078: mmc removeFirstFromPolymake /mmc set % $B$R$H$D>.$5$$%5%$%:$K(B.
1079:
1080: [mmL genUnit] mmL join asir_matrix_image
1081: removeFirstFromPolymake /mmL set
1082: mmL asir_matrix_image /mmL set % Linearity space $B$r5a$a$k(B. rm 0vector
1083: /ppt (NOT__POINTED) def
1084: } ifelse
1085: /arg1 [[cdim mmc mmL ppt] rr] def
1086: ] pop
1087: popVariables
1088: arg1
1089: } def
1090:
1091:
1092: /test.put {
1093: /dog [(dog) [[(legs) 4] ] [1 2 3 ]] [(class) (tree)] dc def
1094: /man [(man) [[(legs) 2] ] [1 2 3 ]] [(class) (tree)] dc def
1095: /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def
1096: /fan [ma 1 copy] def
1097: ma (dog) getNode /dd set
1098: dd 2 get /dd2 set
1099: dd2 1 0 put
1100: ma message
1101:
1102: fan message
1103: } def
1104:
1105: /test6.data
1106: $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])]))$
1107: def
1108: % tfbToTree
1109:
1110: /arrayToTree { [(class) (tree)] dc } def
1111:
1112: %<
1113: % polymake $B$h$jF@$i$l$?(B TreeObject $B$+$i(B TreeObject cone $B$r@8@.$9$k(B.
1114: % Usages: test6.data tfbToTree newCone $B$GF0:n%F%9%H(B
1115: %>
1116: /test6 {
1117: test6.data tfbToTree /rr set
1118: rr newCone /rr2 set
1119: } def
1120:
1121: %<
1122: % Usages: doPolymakeObj newCone
1123: %>
1124: /newCone {
1125: /arg1 set
1126: [/polydata /cone /facets /vertices /flipped /ineq
1127: /facetsv /rr] pushVariables
1128: [
1129: /polydata arg1 def
1130: polydata (FACETS) getNode tag 0 eq {
1131: (newCone : no FACETS data.) error
1132: } { } ifelse
1133: % facets $B$OM-M}?t$N>l9g@55,2=$9$k(B. data/test11 $B$G(B $BM-M}?t$G$k(B.
1134: polydata (FACETS) getNode 2 get 0 get to_univNum
1135: { nnormalize_vec} map /facets set
1136: [[ ] ] facets join shell rest removeFirstFromPolymake /facets set
1.2 takayama 1137: facets length 0 eq
1138: {(Internal error. Facet data is not obtained. See OpenXM_tmp.) error} { } ifelse
1.1 takayama 1139: % vertices $B$O(B cone $B$N>e$K$"$k$N$G@0?tG\(B OK. $B@55,$+$9$k(B.
1140: polydata (VERTICES) getNode 2 get 0 get to_univNum
1141: { nnormalize_vec} map /vertices set
1142: [[ ] ] vertices join shell rest removeFirstFromPolymake /vertices set
1143: % inequalities $B$OM-M}?t$N>l9g@55,2=$9$k(B.
1144: polydata (INEQUALITIES) getNode 2 get 0 get to_univNum
1145: { nnormalize_vec } map /ineq set
1146: [[ ] ] ineq join shell rest removeFirstFromPolymake /ineq set
1147:
1.4 takayama 1148: % nextcid, nextfid $B$r2C$($k(B. nextcid $B$O(B nextConeId $B$NN,(B. $B$H$J$j$N(B cone $BHV9f(B.
1149: % nextfid $B$O(B nextFacetId $B$NN,(B. $B$H$J$j$N(B cone $B$N(B facet
1150: % $BHV9f(B.
1.1 takayama 1151: [(cone) [ ]
1152: [
1153: [(facets) [ ] facets] arrayToTree
1154: [(flipped) [ ] facets length newVector null_to_zero] arrayToTree
1155: [(facetsv) [ ] facets vertices newCone_facetsv] arrayToTree
1.4 takayama 1156: [(nextcid) [ ] facets length newVector.with-1 ] arrayToTree
1157: [(nextfid) [ ] facets length newVector.with-1 ] arrayToTree
1.1 takayama 1158: [(vertices) [ ] vertices] arrayToTree
1159: [(inequalities) [ ] ineq] arrayToTree
1160: ]
1161: ] arrayToTree /cone set
1162: /arg1 cone def
1163: ] pop
1164: popVariables
1165: arg1
1166: } def
1167:
1168: %<
1169: % Usages: newCone_facetv
1170: % facet vertices newCone_facetv
1171: % facet $B$K$N$C$F$$$k(B vertices $B$r$9$Y$FNs5s(B.
1172: %>
1173: /newCone_facetv {
1174: /arg2 set
1175: /arg1 set
1176: [/facet /vertices] pushVariables
1177: [
1178: /facet arg1 def /vertices arg2 def
1179: [
1180: 0 1 vertices length 1 sub {
1181: /ii set
1182: facet vertices ii get mul isZero
1183: { vertices ii get } { } ifelse
1184: } for
1185: ]
1186: /arg1 set
1187: ] pop
1188: popVariables
1189: arg1
1190: } def
1191:
1192: %<
1193: % Usages: newCone_facetsv
1194: % facets vertices newCone_facetv
1195: % facets $B$K$N$C$F$$$k(B vertices $B$r$9$Y$FNs5s(B. $B%j%9%H$r:n$k(B.
1196: %>
1197: /newCone_facetsv {
1198: /arg2 set
1199: /arg1 set
1200: [/facets /vertices] pushVariables
1201: [
1202: /facets arg1 def /vertices arg2 def
1203: facets { vertices newCone_facetv } map
1204: /arg1 set
1205: ] pop
1206: popVariables
1207: arg1
1208: } def
1209:
1210: %<
1.2 takayama 1211: % Usages: [gb weight] newConeGB
1212: % gb $B$H(B weight $B$r(B tree $B7A<0$K$7$F3JG<$9$k(B.
1213: %>
1214: /newConeGB {
1215: /arg1 set
1216: [/gbdata /gg /ww /rr] pushVariables
1217: [
1218: /gbdata arg1 def
1219: % gb
1220: gbdata 0 get /gg set
1221: % weight
1222: gbdata 1 get /ww set
1223: %
1224: [(coneGB) [ ]
1225: [
1226: [(grobnerBasis) [ ] gg] arrayToTree
1227: [(weight) [ ] [ww]] arrayToTree
1228: [(initial) [ ] gg { ww 2 get weightv init } map ] arrayToTree
1229: ]
1230: ] arrayToTree /rr set
1231: /arg1 rr def
1232: ] pop
1233: popVariables
1234: arg1
1235: } def
1236:
1237: %<
1.1 takayama 1238: % Usages: cone_random
1239: %>
1240: /cone_random.start (2).. def
1241: /cone_random {
1242: [(tdiv_qr)
1243: cone_random.start (1103515245).. mul
1244: (12345).. add
1245:
1246: (2147483646)..
1247: ] mpzext 1 get /cone_random.start set
1248: cone_random.start
1249: } def
1250:
1251: /cone_random.limit 40 def
1252: /cone_random_vec {
1253: /arg1 set
1254: [/nn /rr] pushVariables
1255: [
1256: /nn arg1 def
1257: [
1258: 0 1 nn 1 sub {
1259: pop
1260: [(tdiv_qr) cone_random cone_random.limit] mpzext 1 get
1261: } for
1262: ] /arg1 set
1263: ] pop
1264: popVariables
1265: arg1
1266: } def
1267:
1268: %<
1269: % Usages: getNewRandomWeight
1270: %% 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.
1271: %% h, H $B$N=hM}$bI,MW(B.
1272: %% $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?
1273: %>
1274: /getNewRandomWeight {
1275: /arg1 set
1276: [/vv /vvd /rr] pushVariables
1277: [
1278: /vv arg1 def
1279: vv { (D) 2 1 roll 2 cat_n } map /vvd set
1280: ] pop
1281: popVariables
1282: arg1
1283: } def
1284:
1285: % test7 : univNum $B$N(B weight $B$,@5$7$/G'<1$5$l$k$+$N%F%9%H(B
1286: % aux-cone.sm1
1287:
1288: %<
1289: % Usages: n d coneEqForSmallFan.2 (cone.type 2 $B@lMQ(B: x,y,Dx,Dy,h)
1290: % 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.
1291: % $B$O$8$a$+$i(B d $B8D$NJQ?t(B.
1292: % 4, 2 , s,t,x,y $B$J$i(B weight $B$O(B s,t,Ds,Dt $B$N$_(B.
1293: % u_i + v_i >= 0 , u_i = v_i = 0.
1294: % homog $BJQ?t$N>r7o(B u_i+v_i >= t, i.e, -t >= 0 $B$bF~$l$k(B.
1295: % coneEq $B$N7k2L$H(B coneEqForSmallFan.2 $B$N7k2L$r(B join $B$7$F(B
1296: % getConeInfo or newCone
1297: % note-cone.sm1 2004.8.31 $B$r8+$h(B. w_ineq $B$"$?$j(B.
1298: % cone.local $B$,@_Dj$5$l$F$$$k$H(B u_i <= 0 $B$b>r7o$KF~$k(B.
1299: %>
1300: /coneEqForSmallFan.2 {
1301: /arg2 set
1302: /arg1 set
1303: [/n /d /nn /dd /ii /tt] pushVariables
1304: [
1305: /n arg1 def
1306: /d arg2 def
1307: n to_int32 /n set
1308: d to_int32 /d set
1309: /dd n d add def
1310: /nn n n add def
1311:
1312: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i = 0
1313: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1314: % -t >= 0
1315: [
1316: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1317: d 1 n 1 sub {
1318: /ii set
1319: % [ 0,0, ..., 0,1,0,... ; 0] $B$r@8@.(B
1320: nn 1 add newVector null_to_zero /tt set
1321: tt ii (1).. put
1322: tt
1323: % [ 0,0, ..., 0,-1,0,... ; 0] $B$r@8@.(B
1324: nn 1 add newVector null_to_zero /tt set
1325: tt ii (-1).. put
1326: tt
1327: } for
1328: dd 1 nn 1 sub {
1329: /ii set
1330: nn 1 add newVector null_to_zero /tt set
1331: tt ii (1).. put
1332: tt
1333: nn 1 add newVector null_to_zero /tt set
1334: tt ii (-1).. put
1335: tt
1336: } for
1337:
1338: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i = 0
1339: 0 1 d 1 sub {
1340: /ii set
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: nn 1 add newVector null_to_zero /tt set
1347: tt ii (-1).. put
1348: tt ii n add (-1).. put
1349: tt
1350:
1351: } for
1352:
1353: % -t >= 0
1354: cone.h0 {
1355: % t = 0
1356: nn 1 add newVector null_to_zero /tt set
1357: tt nn (1).. put
1358: tt
1359: nn 1 add newVector null_to_zero /tt set
1360: tt nn (-1).. put
1361: tt
1362: }
1363: {
1364: % -t >= 0
1365: nn 1 add newVector null_to_zero /tt set
1366: tt nn (-1).. put
1367: tt
1368: } ifelse
1369:
1370: % cone.local $B$,(B 1 $B$N;~(B
1371: % 0 ~ d-1 $B$G$O(B -u_i >= 0
1372: cone.local {
1373: 0 1 d 1 sub {
1374: /ii set
1375: nn 1 add newVector null_to_zero /tt set
1376: tt ii (-1).. put
1377: tt
1378: } for
1379: } { } ifelse
1380: ] /rr set
1381: /arg1 rr to_univNum def
1382: ] pop
1383: popVariables
1384: arg1
1385: } def
1386:
1387: %<
1388: % Usages: n d coneEqForSmallFan.1 (cone.type 1 $B@lMQ(B: x,y,Dx,Dy,h,H)
1389: % cone.type 2 $B$G$O(B x,y,Dx,Dy,h
1390: % coneEqForSmallFan.2 $B$N7k2L$rMQ$$$F@8@.(B.
1391: % H $B$N>r7o$r2C$($k(B.
1392: %>
1393: /coneEqForSmallFan.1 {
1394: /arg2 set
1395: /arg1 set
1396: [/n /d /i /j /rr /tt /tt2] pushVariables
1397: [
1398: /n arg1 def /d arg2 def
1399: n d coneEqForSmallFan.2 /rr set
1400: rr cone.appendZero /rr set
1401: % H $BMQ$N(B 0 $B$r2C$($k(B.
1402: % $B$H$j$"$($:(B t' = 0 $B$G$-$a$&$A(B.
1403: cone.h0 { } { (cone.h0 = 0 has not yet been implemented.) error } ifelse
1404: n 2 mul 2 add newVector null_to_zero /tt set
1405: tt n 2 mul 2 add 1 sub (-1).. put
1406: n 2 mul 2 add newVector null_to_zero /tt2 set
1407: tt2 n 2 mul 2 add 1 sub (1).. put
1408: rr [tt tt2] join /rr set
1409: /arg1 rr to_univNum def
1410: ] pop
1411: popVariables
1412: arg1
1413: } def
1414:
1415: %<
1416: % Usages: vv ineq toQuotientCone
1417: % weight space $B$N(B $B%Q%i%a!<%?$D$1$N$?$a$K;H$&(B.
1418: % cone.V $B$r5a$a$?$$(B. vv $B$O(B doPolymakeObj (VERTICES) getNode 2 get 0 get $B$GF@$k(B.
1419: % vertices $B$N(B non-negative combination $B$,(B cone.
1420: % vertice cone.w_ineq isInLinearSubspace $B$J$i<h$j=|$/(B.
1421: % $B$D$^$j(B vertice*cone.w_ineq = 0 $B$J$i<h$j=|$/(B.
1422: %
1423: % $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)
1424: % cone.w_cone 1 get (VERTICES) getNode :: $B$HHf3S$;$h(B.
1425: % $B$3$N4X?t$r8F$s$G(B cone.W $B$r:n$k$N$OITMW$+$b(B.
1426: %
1427: % Example: cf. parametrizeSmallFan
1428: % 4 2 coneEqForSmallFan.2 /cone.w_ineq set cone.w_ineq getConeInfo /rr set
1429: % rr 1 get (VERTICES) getNode 2 get 0 get removeFirstFromPolymake /vv set
1430: % vv cone.w_ineq toQuotientCone pmat
1431: %>
1432: /toQuotientCone {
1433: /arg2 set /arg1 set
1434: [/vv /ineq /rr] pushVariables
1435: [
1436: /vv arg1 def /ineq arg2 def
1437: vv {
1438: dup
1439: ineq isInLinearSpace 1 eq { pop }
1440: { } ifelse
1441: } map /arg1 set
1442: ] pop
1443: popVariables
1444: arg1
1445: } def
1446:
1447: %<
1448: % Usages: n d parametrizeSmallFan
1449: % n : x $BJQ?t$N?t(B.
1450: % d : 0 $B$K$7$J$$(B weight $B$N?t(B.
1451: % $B<!$NBg0hJQ?t$b@_Dj$5$l$k(B.
1452: % cone.W : weight $B$r%Q%i%a!<%?$E$1$9$k%Y%/%H%k$NAH(B.
1453: % 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,
1454: % i $B$,(B Wpos ~ $B$NHO0O$N$H$-(B V[i] $B$X$O(B Z $B$N85$r3]$1;;$7$F$h$$(B.
1455: % cone.w_ineq : weight space $B$NITEy<0@)Ls(B. $B0J8e$N7W;;$G>o$KIU2C$9$k(B.
1456: % cone.w_cone : w_ineq $B$r(B polymake $B$G(B getConeInfo $B$7$?7k2L(B.
1457: % Example: /cone.local 1 def ; 4 2 parametrizeSmallFan pmat
1458: % Example: /cone.local 0 def ; 4 2 parametrizeSmallFan pmat
1459: %>
1460: /parametrizeSmallFan {
1461: /arg2 set /arg1 set
1462: [/n /d /vv /coneray] pushVariables
1463: [
1464: /n arg1 def /d arg2 def
1465: {
1466: cone.type 1 eq {
1467: n d coneEqForSmallFan.1 /cone.w_ineq set
1468: exit
1469: } { } ifelse
1470: cone.type 2 eq {
1471: n d coneEqForSmallFan.2 /cone.w_ineq set
1472: exit
1473: } { } ifelse
1474: (This cone.type has not yet been implemented.) error
1475: } loop
1476: cone.w_ineq getConeInfo /cone.w_cone set
1477: cone.w_cone 1 get (VERTICES) getNode 2 get 0 get
1478: removeFirstFromPolymake /vv set
1479:
1480: vv cone.w_ineq toQuotientCone /coneray set
1481: coneray length /cone.Wpos set
1482:
1483: coneray cone.w_cone 0 get 2 get join /cone.W set
1484: /arg1 cone.W def
1485: ] pop
1486: popVariables
1487: arg1
1488: } def
1489:
1490: %<
1491: % Usages: n d coneEqForTotalFan.2 (cone.type 2 $B@lMQ(B: x,y,Dx,Dy,h)
1492: % n $BJQ?t$N?t(B,
1493: % d 0 $B$K$7$J$$JQ?t(B.
1494: % u_i + v_i >= 0 ,
1495: % homog $BJQ?t$N>r7o(B u_i+v_i >= 0, t = 0 $B$bF~$l$k(B.
1496: % coneEq $B$N7k2L$H(B coneEqForSmallFan.2 $B$N7k2L$r(B join $B$7$F(B
1497: % getConeInfo or newCone
1498: % cone.local $B$,@_Dj$5$l$F$$$k$H(B u_i <= 0 $B$b>r7o$KF~$k(B.
1499: %>
1500: /coneEqForTotalFan.2 {
1501: /arg2 set
1502: /arg1 set
1503: [/n /nn /dd /ii /tt] pushVariables
1504: [
1505: /n arg1 def
1506: /d arg2 def
1507: n to_int32 /n set
1508: d to_int32 /d set
1509: /nn n n add def
1510: /dd n d add def
1511:
1512: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i >= 0
1513: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1514: % t = 0
1515: [
1516: % d ~ n-1, dd ~ nn-1 $B$G$O(B u_i=v+i = 0.
1517: d 1 n 1 sub {
1518: /ii set
1519: % [ 0,0, ..., 0,1,0,... ; 0] $B$r@8@.(B
1520: nn 1 add newVector null_to_zero /tt set
1521: tt ii (1).. put
1522: tt
1523: % [ 0,0, ..., 0,-1,0,... ; 0] $B$r@8@.(B
1524: nn 1 add newVector null_to_zero /tt set
1525: tt ii (-1).. put
1526: tt
1527: } for
1528: dd 1 nn 1 sub {
1529: /ii set
1530: nn 1 add newVector null_to_zero /tt set
1531: tt ii (1).. put
1532: tt
1533: nn 1 add newVector null_to_zero /tt set
1534: tt ii (-1).. put
1535: tt
1536: } for
1537:
1538: % 0 ~ d-1, n ~ dd-1 $B$G$O(B u_i + v_i >= 0
1539: 0 1 d 1 sub {
1540: /ii set
1541: nn 1 add newVector null_to_zero /tt set
1542: tt ii (1).. put
1543: tt ii n add (1).. put
1544: tt
1545:
1546: } for
1547:
1548: % t = 0
1549: cone.h0 {
1550: % t = 0
1551: nn 1 add newVector null_to_zero /tt set
1552: tt nn (1).. put
1553: tt
1554: nn 1 add newVector null_to_zero /tt set
1555: tt nn (-1).. put
1556: tt
1557: }
1558: {
1559: (coneForTotalFan.2. Not implemented.) error
1560: } ifelse
1561:
1562: % cone.local $B$,(B 1 $B$N;~(B
1563: % 0 ~ d-1 $B$G$O(B -u_i >= 0
1564: cone.local {
1565: 0 1 d 1 sub {
1566: /ii set
1567: nn 1 add newVector null_to_zero /tt set
1568: tt ii (-1).. put
1569: tt
1570: } for
1571: } { } ifelse
1572: ] /rr set
1573: /arg1 rr to_univNum def
1574: ] pop
1575: popVariables
1576: arg1
1577: } def
1578:
1579: %<
1580: % Usages: n d parametrizeTotalFan
1581: % n : x $BJQ?t$N?t(B.
1582: % d : 0 $B$K$7$J$$?t(B.
1583: % $B<!$NBg0hJQ?t$b@_Dj$5$l$k(B.
1584: % cone.W : weight $B$r%Q%i%a!<%?$E$1$9$k%Y%/%H%k$NAH(B.
1585: % 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,
1586: % i $B$,(B Wpos ~ $B$NHO0O$N$H$-(B V[i] $B$X$O(B Z $B$N85$r3]$1;;$7$F$h$$(B.
1587: % cone.w_ineq : weight space $B$NITEy<0@)Ls(B. $B0J8e$N7W;;$G>o$KIU2C$9$k(B.
1588: % cone.w_ineq $B$r(B getConeInfo $B$7$?7k2L$O(B cone.w_cone
1589: % Example: /cone.local 1 def ; 3 parametrizeSmallFan pmat
1590: % Example: /cone.local 0 def ; 3 parametrizeSmallFan pmat
1591: % local $B$,(B 1 $B$@$H(B u_i <= 0 $B$K$J$k(B.
1592: %>
1593: /parametrizeTotalFan {
1594: /arg2 set
1595: /arg1 set
1596: [/n /d /vv /coneray] pushVariables
1597: [
1598: /n arg1 def /d arg2 def
1599: {
1600: cone.type 2 eq { n d coneEqForTotalFan.2 /cone.w_ineq set exit}
1601: { } ifelse
1602: (This cone.type has not yet been implemented.) error
1603: } loop
1604: cone.w_ineq getConeInfo /cone.w_cone set
1605: cone.w_cone 1 get (VERTICES) getNode 2 get 0 get
1606: removeFirstFromPolymake /vv set
1607:
1608: vv cone.w_ineq toQuotientCone /coneray set
1609: coneray length /cone.Wpos set
1610:
1611: coneray cone.w_cone 0 get 2 get join /cone.W set
1612: /arg1 cone.W def
1613: ] pop
1614: popVariables
1615: arg1
1616: } def
1617:
1618: %<
1619: % Usages: vlist wlist cone_wtowv
1620: % [x y Dx Dy h] [-1 0 1 0 0] ==> [(x) -1 (Dx) 1] $B$r:n$k(B.
1621: %>
1622: /cone_wtowv {
1623: /arg2 set /arg1 set
1624: [/vlist /wlist /ii] pushVariables
1625: [
1626: /vlist arg1 def
1627: /wlist arg2 def
1628: wlist length vlist length eq {
1.14 ! takayama 1629: } { (cone_wtowv: length of the argument must be the same. Please check the values of cone.vlist cone.vv cone.type parametrizeWeightSpace) error} ifelse
1.1 takayama 1630:
1631: wlist to_int32 /wlist set
1632: [
1633: 0 1 wlist length 1 sub {
1634: /ii set
1635: wlist ii get 0 eq { }
1636: { vlist ii get wlist ii get } ifelse
1637: } for
1638: ] /arg1 set
1639: ] pop
1640: popVariables
1641: arg1
1642: } def
1643:
1644: %<
1645: % Usages: pruneZeroVector
1646: % genPo, getConeInfo $BEy$NA0$K;H$&(B. 0 $B%Y%/%H%k$O0UL#$N$J$$@)Ls$J$N$G=|$/(B.
1.2 takayama 1647: % $BF1$8@)Ls>r7o$b$N$>$/(B. polymake FACET $B$,@5$7$/F0$+$J$$>l9g$,$"$k$N$G(B.
1648: % cf. pear/OpenXM_tmp/x3y2.poly, x^3+y^2, x^2+y^3 data/test15.sm1
1.1 takayama 1649: %>
1650: /pruneZeroVector {
1651: /arg1 set
1652: [/mm /ii /jj /tt] pushVariables
1653: [
1654: /mm arg1 def
1655: mm to_univNum /mm set
1.2 takayama 1656: [ [ ] ] mm join shell rest uniq /mm set
1.1 takayama 1657: [
1658: 0 1 mm length 1 sub {
1659: /ii set
1660: mm ii get /tt set
1661: {
1662: 0 1 tt length 1 sub {
1663: /jj set
1664: tt jj get (0).. eq { }
1665: { tt exit } ifelse
1666: } for
1667: exit
1668: } loop
1669: } for
1670: ] /arg1 set
1671: ] pop
1672: arg1
1673: } def
1674:
1675: %<
1676: % Usages: a projectIneq v , dim(a) = n, dim(v) = d
1677: % a*cone.Wt*cone.Lpt
1678: %>
1679: /projectIneq {
1680: cone.Wt mul cone.Lpt mul
1681: } def
1682:
1683: %<
1684: % Usages: v liftWeight [w vw], dim(v) = d, dim(w) = n, vw : vw $B7A<0$N(B weight
1685: % v*cone.Lp*cone.W cone.vlist w cone_wtowv
1686: %>
1687: /liftWeight {
1688: /arg1 set
1689: [/v /w /vw] pushVariables
1690: [
1691: /v arg1 def
1692: v cone.Lp mul cone.W mul /w set
1693: [w cone.vlist w cone_wtowv] /arg1 set
1694: ] pop
1695: popVariables
1696: arg1
1697: } def
1698:
1699: %<
1700: % Usage: m isZero
1701: % dr.sm1 $B$X0\$9(B.
1702: %>
1703: /isZero {
1704: /arg1 set
1705: [/mm /ans /ii] pushVariables
1706: [
1707: /mm arg1 def
1708: /ans 1 def
1709: mm isArray {
1710: 0 1 mm length 1 sub {
1711: /ii set
1712: mm ii get isZero /ans set
1713: ans 0 eq { exit } { } ifelse
1714: } for
1715: } {
1716: {
1717: mm tag 1 eq {/ans mm 0 eq def exit} { } ifelse
1718: mm isPolynomial { /ans mm (0). eq def exit } { } ifelse
1719: mm isUniversalNumber { /ans mm (0).. eq def exit } { } ifelse
1720: /ans 0 def exit
1721: } loop
1722: } ifelse
1723: /arg1 ans def
1724: ] pop
1725: popVariables
1726: arg1
1727: } def
1728: [(isZero)
1729: [(m isZero bool)]] putUsages
1730:
1731: %<
1732: % Usage: m isNonNegative
1733: % dr.sm1 $B$X0\$9(B.
1734: %>
1735: /isNonNegative {
1736: /arg1 set
1737: [/mm /ans /ii] pushVariables
1738: [
1739: /mm arg1 def
1740: /ans 1 def
1741: mm isArray {
1742: 0 1 mm length 1 sub {
1743: /ii set
1744: mm ii get isNonNegative /ans set
1745: ans 0 eq { exit } { } ifelse
1746: } for
1747: } {
1748: {
1749: mm tag 1 eq {/ans mm 0 gt mm 0 eq or def exit} { } ifelse
1750: mm isUniversalNumber { /ans mm (0).. gt mm (0).. eq or def exit }
1751: { } ifelse
1752: mm isRational { mm (numerator) dc mm (denominator) dc mul /mm set
1753: /ans mm (0).. gt mm (0).. eq or def exit } { } ifelse
1754: /ans 0 def exit
1755: } loop
1756: } ifelse
1757: /arg1 ans def
1758: ] pop
1759: popVariables
1760: arg1
1761: } def
1762: [(isNonNegative)
1763: [(m isNonNegative bool)
1764: (In case of matrix, m[i,j] >= 0 must hold for all i,j.)
1765: ]] putUsages
1766:
1767: % Global variable: cone.weightBorder
1768: % /cone.weightBorder null def $BITMW$G$"$m$&(B. getStartingCone $B$G@_Dj$5$l$k(B.
1769:
1770: %<
1771: % Usages: cone i isOnWeigthBorder
1772: % cone $B$N(B i $BHVL\$N(B facet $B$,(B weight $B6u4V$N6-3&$K$"$k$+(B?
1773: % $BBg0hJQ?t(B cone.weightBorder $B$,@_Dj$5$l$F$k$3$H(B.
1774: % $B$3$NJQ?t$O(B cone $B$N(B facet $B%Y%/%H%k$N%j%9%H(B.
1775: % $B$3$NJQ?t$O(B setWeightBorder $B$G@_Dj(B
1776: % cone.weightBorder[0] or cone.weightBorder[1] or ...
1777: % /ccone cone.startingCone def ccone 0 isOnWeightBorder
1778: % ccone 1 isOnWeightBorder
1779: %>
1780: /isOnWeightBorder {
1781: /arg2 set /arg1 set
1782: [/cone /facet_i /i /j /vv /co /ans] pushVariables
1783: [
1784: /cone arg1 def /facet_i arg2 def
1785: facet_i to_int32 /facet_i set
1786: /ans 0 def
1787: cone (facetsv) getNode 2 get facet_i get /vv set % Facet $B$r(B vertex $BI=8=(B.
1788: {
1789: 0 1 cone.weightBorder length 1 sub {
1790: /i set
1791: cone.weightBorder i get /co set % co $B$K@)Ls>r7o(B
1792: vv cone.Lp mul % vv $B$r(B weight space $B$X(B lift.
1793: co mul isZero
1794: { /ans 1 def exit } { } ifelse
1795: } for
1796: exit
1797: } loop
1798: /arg1 ans def
1799: ] pop
1800: popVariables
1801: arg1
1802: } def
1803:
1804: %<
1805: % Usages: cone i markFlipped
1806: % 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.
1807: % cone $B$O(B class-tree. Constructor $B$O(B newCone
1808: %>
1809: /markFlipped {
1810: /arg2 set /arg1 set
1811: [/cone /facet_i /vv] pushVariables
1812: [
1813: /cone arg1 def /facet_i arg2 def
1814: facet_i to_int32 /facet_i set
1815: cone (flipped) getNode 2 get /vv set
1816: vv facet_i (1).. put
1817: ] pop
1818: popVariables
1819: } def
1820:
1.4 takayama 1821: %<
1822: % Usages: cone i [cid fid] markNext
1823: % 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.
1824: % cone $B$N(B nextcid[i] = cid; nextfid[i] = fid $B$H$J$k(B.
1825: % cone $B<+BN$,JQ99$5$l$k(B.
1826: % cone $B$O(B class-tree.
1827: %>
1828: /markNext {
1829: /arg3 set /arg2 set /arg1 set
1830: [/cone /facet_i /vv /nextid] pushVariables
1831: [
1832: /cone arg1 def /facet_i arg2 def /nextid arg3 def
1833: facet_i to_int32 /facet_i set
1834: cone (nextcid) getNode 2 get /vv set
1835: vv facet_i , nextid 0 get to_univNum , put
1836:
1837: cone (nextfid) getNode 2 get /vv set
1838: vv facet_i , nextid 1 get to_univNum , put
1839: ] pop
1840: popVariables
1841: } def
1842:
1.1 takayama 1843:
1844:
1845: %<
1846: % Usages: cone getNextFacet i
1847: % flipped $B$N(B mark $B$N$J$$(B facet $B$N(B index facet_i $B$rLa$9(B.
1848: % $B$=$l$,$J$$$H$-$O(B null
1849: %>
1850: /getNextFacet {
1851: /arg1 set
1852: [/cone /facet_i /vv /ii] pushVariables
1853: [
1854: /cone arg1 def
1855: /facet_i null def
1856: cone (flipped) getNode 2 get /vv set
1857: 0 1 vv length 1 sub {
1858: /ii set
1859: vv ii get to_int32 0 eq { /facet_i ii def exit }
1860: { } ifelse
1861: } for
1862: /arg1 facet_i def
1863: ] pop
1864: popVariables
1865: arg1
1866: } def
1867:
1868: %<
1869: % Usages: cone i epsilon flipWeight
1870: % cone $B$N(B i $BHVL\$N(B facet $B$K$+$s$7$F(B flip $B$9$k(B.
1871: % $B?7$7$$(B weight $B$r5a$a$k(B. cf. liftWeight
1872: %>
1873: /flipWeight {
1874: /arg3 set /arg2 set /arg1 set
1875: [/cone /facet_i /ep /vp /v /v /ii] pushVariables
1876: [
1877: /cone arg1 def /facet_i arg2 def
1878: facet_i to_int32 /facet_i set
1879: /ep arg3 def
1880:
1881: ep to_univNum (1).. div /ep set
1882:
1883: % note: 2004.9.2
1884: cone (facetsv) getNode 2 get facet_i get /v set
1885: cone (facets) getNode 2 get facet_i get /f set
1.13 takayama 1886:
1887: v length 0 eq {
1888: (The codimension of the linarity space of the Grobner cone seems to be 1 or 0.) cone_ir_input
1889: } { } ifelse
1890:
1.1 takayama 1891: /vp v 0 get def
1892: 1 1 v length 1 sub {
1893: /ii set
1894: vp v ii get add /vp set
1895: } for
1896: vp ep f mul sub /vp set
1897: vp nnormalize_vec /vp set
1898: /arg1 vp def
1899: ] pop
1900: popVariables
1901: arg1
1902: } def
1903:
1904: %<
1905: % Usages: cone1 cone2 isSameCone bool
1906: % cone1 cone2 $B$,Ey$7$$$+(B? facet $B$GHf$Y$k(B.
1907: % cone1, cone2 $B$O(B pointed cone $B$G$J$$$H$$$1$J$$(B.
1908: %>
1909: /isSameCone {
1910: /arg2 set /arg1 set
1911: [/cone1 /cone2 /facets1 /facets2 /ans] pushVariables
1912: [
1913: /cone1 arg1 def
1914: /cone2 arg2 def
1915: /facets1 cone1 (facets) getNode 2 get def
1916: /facets2 cone2 (facets) getNode 2 get def
1917: facets1 length facets2 length eq {
1918: facets1 facets2 sub isZero /ans set
1919: } {
1920: /ans 0 def
1921: } ifelse
1922: /arg1 ans def
1923: ] pop
1924: popVariables
1925: arg1
1926: } def
1927:
1928: %<
1929: % Usages: cone1 cone2 getCommonFacet list
1930: % cone1 $B$NCf$G(B cone2 $B$K4^$^$l$k(B facet $B$N%j%9%H(B
1931: % cone2 $B$NCf$G(B cone1 $B$K4^$^$l$k(B facet $B$N%j%9%H$r$b$I$9(B.
1932: % [1 [i] [j]] $B$"$k$H$-(B. [0 [ ] [ ]] $B$J$$$H$-(B.
1933: % cone1 $B$N(B facetsv[i] $B$,(B cone2 $B$K4^$^$l$k$+D4$Y$k(B.
1934: % cone2 $B$N(B facetsv[i] $B$,(B cone1 $B$K4^$^$l$k$+D4$Y$k(B.
1935: % cone1, cone2 $B$O(B pointed cone $B$G$J$$$H$$$1$J$$(B.
1936: %>
1937: /getCommonFacet {
1938: /arg2 set /arg1 set
1939: [/cone1 /cone2 /facets /ineq /ans1 /ans2 /i /tt] pushVariables
1940: [
1941: /cone1 arg1 def
1942: /cone2 arg2 def
1943:
1944: /facets cone1 (facetsv) getNode 2 get def
1945: /ineq cone2 (inequalities) getNode 2 get def
1946: /ans1 [
1947: 0 1 facets length 1 sub {
1948: /i set
1949: facets i get /tt set % facetsv[i] $B$r(B tt $B$X(B.
1950: ineq tt transpose mul isNonNegative {
1951: i
1952: } { } ifelse
1953: } for
1954: ] def
1955:
1956: /facets cone2 (facetsv) getNode 2 get def
1957: /ineq cone1 (inequalities) getNode 2 get def
1958: /ans2 [
1959: 0 1 facets length 1 sub {
1960: /i set
1961: facets i get /tt set % facetsv[i] $B$r(B tt $B$X(B.
1962: ineq tt transpose mul isNonNegative {
1963: i
1964: } { } ifelse
1965: } for
1966: ] def
1967: ans1 length 1 gt ans2 length 1 gt or {
1968: (getCommonFacet found more than 1 common facets.) error
1969: } { } ifelse
1970: % $B6&DL(B facet $B$,$"$l$P(B 1, $B$J$1$l$P(B 0.
1971: ans1 length 1 eq ans2 length 1 eq and {
1972: /tt 1 def
1973: } {
1974: /tt 0 def
1975: } ifelse
1976: /arg1 [tt ans1 ans2] def
1977: ] pop
1978: popVariables
1979: arg1
1980: } def
1981:
1982: %
1983: % -------------------------------------------------
1984: % test8 $B$O(B aux-cone.sm1 $B$X0\F0(B.
1985: % $B0J2<$$$h$$$h0lHL$N%W%m%0%i%`$N:n@.3+;O(B.
1986: % -------------------------------------------------
1987: %
1988:
1989: %<
1990: % Usages: setWeightBorder
1991: % cone.weightBorder (weight cone $B$N(B facet $B%Y%/%H%k$N=89g(B) $B$r@_Dj$9$k(B.
1992: % $B$"$HI{;:J*$H$7$F(B cone.w_cone_projectedWt (doPolymakeObj)
1993: % cone.w_ineq_projectedWt
1994: % cone.m $B<!85$N%Y%/%H%k(B.
1995: % cone.W, cone.Wt, cone.w_ineq $B$,$9$G$K7W;;$:$_$G$J$$$H$$$1$J$$(B.
1996: %>
1997: /setWeightBorder {
1998: [
1999: (Entering setWeightBorder ) message
2000: cone.w_ineq cone.Wt mul pruneZeroVector /cone.w_ineq_projectedWt set
2001: {
2002: cone.w_ineq_projectedWt length 0 eq {
2003: % weight $B$N6u4V$K(B border $B$,$J$$>l9g(B.
2004: /cone.weightBorder [ ] def
2005: exit
2006: } { } ifelse
2007: % weight $B$N6u4V$K(B border $B$,$"$k>l9g(B.
2008: cone.w_ineq_projectedWt getConeInfo /cone.w_cone_projectedWt set
2009: cone.w_cone_projectedWt 0 get 0 get to_int32 cone.m to_int32 eq {
2010: } {
2011: (setWeightBorder : internal error.) message
2012: } ifelse
2013: cone.w_cone_projectedWt 1 get (FACETS) getNode 2 get 0 get
2014: removeFirstFromPolymake /cone.weightBorder set
2015: exit
2016: } loop
2017: (cone.weightBorder=) message
2018: cone.weightBorder pmat
2019: ] pop
2020: } def
2021:
2022: %
2023: % -------------------------------------------------
2024: % $B%W%m%0%i%`$NN.$l(B.
2025: % Global: cone.fan cone $B$rG[Ns$H$7$F3JG<$9$k(B.
2026: %
2027: % ncone (next cone) $B$,?75,$KF@$i$l$?(B cone $B$G$"$k$H$9$k(B.
2028: % $B$3$N$H$-<!$NA`:n$r$9$k(B.
2029: % 0. ncone $B$,(B cone.fan $B$K$9$G$K$J$$$+D4$Y$k(B. $B$"$l$P(B, internal error.
2030: % 1. ncone markBorder ; ncone $B$NCf$N(B border $B>e$N(B facet $B$r(B mark
2031: % 2. cone.fan $B$NCf$N(B cone $B$H6&DL(B facet $B$,$J$$$+D4$Y(B (getCommonFacet),
2032: % $B$"$l$P$=$l$i$r(B mark $B$9$k(B.
2033: % global: cone.incidence $B$K(B $B6&DL(Bfacet $B$r;}$DAH$_$N>pJs$r2C$($k(B.
2034: % 3. ncone $B$r(B cone.fan $B$N:G8e$K2C$($k(B.
2035: % $B0J>e$NA`:n$r$^$H$a$?$b$N$,(B ncone updateFan
2036: %
2037: % 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.
2038: % $B$J$1$l$P(B null $B$rLa$9(B. null $B$,La$l$P%W%m%0%i%`=*N;(B.
2039: %
2040: % getStargingCone $B$O7W;;$r=PH/$9$Y$-?75,$N(B cone $B$r7W;;$9$k(B. $BBg0hJQ?t(B cone.Lt, cone.W
2041: % $B$J$I$b$3$NCf$G@_Dj$9$k(B.
2042: % $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
2043: % $B$H$7$FF~NO$7$F$*$/(B.
2044: %
2045: % reduced gb $B$O(B $B4X?t(B input weight cone.gb reduced_G $B$G7W;;$9$k(B.
2046: %
2047: %
2048: % [ccone i] getNextCone ncone : flip $B$K$h$j<!$N(B cone $B$rF@$k(B.
2049: %
2050: % 1. clearGlobals ; $BF~NOBg0hJQ?t$N@_Dj(B.
2051: % 2. getStartingCone /ncone set
2052: % 3. { ncone updateFan
2053: % 4. getNextFlip /cone.nextflip set
2054: % 6. cone.nextflip isNull { exit } { } ifelse
2055: % 7. cone.nextflip getNextCone /ncone set
2056: % 8. } loop
2057: %
2058: %
2059: % -------------------------------------------------
2060: %
2061:
2062: %<
2063: % Usages: input weight cone.gb_Dh reduced_G
2064: % gb in h[1,1](D)
2065: %>
2066: /cone.gb_Dh {
2067: /arg2 set /arg1 set
1.12 takayama 2068: [/ff /ww /gg /gbopt] pushVariables
1.1 takayama 2069: [
2070: /ff arg1 def
2071: /ww arg2 def
2072: [(AutoReduce) 1] system_variable
2073: [cone.vv ring_of_differential_operators
2074: [ww] weight_vector 0] define_ring
1.12 takayama 2075: %(---) messagen ff getAttributeList message
2076: ff getAttributeList tag 0 eq {/gbopt [ ] def }
2077: {
2078: /gbopt ff getAttributeList def
2079: } ifelse
2080: [ff {toString .} map gbopt]
2081: groebner 0 get /gg set %% groenber $B$O(B attribute $B$r<u$1IU$1$J$$(B.
1.1 takayama 2082: /cone.gb_Dh.g gg def
2083: /arg1 gg def
2084: ] pop
2085: popVariables
2086: arg1
2087: } def
2088:
2089: %<
2090: % Usages: cone.boundp
2091: %
2092: /cone.boundp {
2093: dup boundp 2 1 roll tag 0 eq not and
2094: } def
2095:
2096: %<
2097: % Usages: clearGlobals
2098: % cf. cone.boundp
2099: % polymake $B$r:FEY8F$V$?$a$K(B global $BJQ?t$r%/%j%"$9$k(B.
2100: % $B$^$@ESCf(B.
2101: %>
2102: /clearGlobals {
2103: /cone.W null def
2104: /cone.Wt null def
2105:
2106: /cone.cinit null def
2107: /cone.weightBorder null def
2108:
2109: } def
2110:
2111: %<
2112: % Usages: getStartingCone ncone
2113: % getStargingCone $B$O7W;;$r=PH/$9$Y$-?75,$N(B cone $B$r7W;;$9$k(B.
2114: % $B@_Dj$9$Y$-Bg0hJQ?t$O0J2<$r8+$h(B.
2115: %>
2116:
2117: /getStartingCone.test {
2118: %------------------Globals----------------------------------------
2119: % --------------- $BF~NO%G!<%?MQBg0hJQ?t$N@_Dj(B --------------------------
2120: %
2121: % cone.input : $BF~NOB?9`<07O(B
2122: /cone.input
2123: [(t1-x-y) (h*t2-x^2-y^2) (2*x*Dt2+h*Dt1+h*Dx) (2*y*Dt2+h*Dt1+h*Dy)]
2124: def
2125:
2126: % cone.vlist : $BA4JQ?t$N%j%9%H(B
2127: /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h)] def
2128:
2129: % cone.vv : define_ring $B7A<0$NJQ?t%j%9%H(B.
2130: % t1,t2, x,y : t-space $B$N(B Grobner fan (local) $B$r5a$a$k(B.
2131: /cone.vv (t1,t2,x,y) def
2132:
2133: % cone.parametrizeWeightSpace : weight $B6u4V$r(B parametrize $B$9$k4X?t(B.
2134: % $BBg0hJQ?t(B cone.W , cone.Wpos $B$b$-$^$k(B.
2135: /cone.parametrizeWeightSpace {
2136: 4 2 parametrizeSmallFan
2137: } def
2138:
2139: % cone.w_start : weight$B6u4V$K$*$1$k(B weight $B$N=i4|CM(B.
2140: % $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.
2141: /cone.w_start
2142: [ 1 4 ]
2143: def
2144:
2145: % cone.gb : gb $B$r7W;;$9$k4X?t(B.
2146: /cone.gb {
2147: cone.gb_Dh
2148: } def
2149:
2150: %
2151: % ----------------- $B$*$o$j(B ---------------------------
2152: %
2153: } def % end of getStartingCone.test
2154:
2155: /getStartingCone {
2156: [/wv_start /w_start /reduced_G] pushVariables
2157: [
2158: % cone.n $B$O<+F0E*$K$-$a$i$l$k(B.
2159: % cone.n $B$O(B GB $B$r7W;;$9$k6u4V$N<!85(B.
2160: /cone.n cone.vlist length def
2161: %[1] cone.W, cone.Wpos $B$r5a$a$k(B. cone.m $B$O(B cone.W $B$h$j<+F0E*$K$-$^$k(B.
2162: % cone.m $B$O(B weight $B6u4V$N<+M3EY(B. cone.W $B$G<M1F$5$l$k@h$N<!85(B.
2163: /cone.W cone.boundp {
2164: (Skip cone.parametrizeWeightSpace. cf. clearGlobals) message
2165: } {
2166: cone.parametrizeWeightSpace
2167: } ifelse
2168: (parametrizing weight space: cone.W = ) messagen cone.W message
2169: /cone.Wt cone.W transpose def
2170: /cone.m cone.W length def
2171: % WeightBorder $B$N>r7oH=Dj(B facet $B$r@_Dj(B.
2172: /cone.weightBorder cone.boundp {
2173: (Skip setWeightBorder cf. clearGlobals) message
2174: } {
2175: setWeightBorder
2176: } ifelse
2177:
2178: %[2] weight vector wv_start $B$r@8@.$9$k(B.
2179: % wv_start $B$r@_Dj(B.
2180: cone.w_start tag 0 eq {
2181: % cone.w_start $B$,(B null $B$J$i(B random $B$K(B weight $B$r@_Dj(B.
2182: /cone.w_start cone.m cone_random_vec def
2183: } {
2184: cone.w_start length cone.m to_int32 eq {
2185: } {
2186: (Error: cone.w_start has wrong length.) error
2187: /cone.w_start cone.m cone_random_vec def
2188: } ifelse
2189: } ifelse
2190: /w_start cone.w_start cone.W mul def
2191:
2192: {
2193: cone.vlist w_start cone_wtowv /wv_start set
2194: (Trying a starting weight vector : ) messagen
2195: wv_start pmat
2196: %[3] reduced GB $B$N7W;;(B.
2197: cone.input wv_start cone.gb /reduced_G set
1.2 takayama 2198: (Reduced GB is obtained: ) message
2199: %reduced_G pmat
2200: /cone.cgb reduced_G def
2201: [cone.w_start w_start wv_start] /cone.cgb_weight set
1.1 takayama 2202:
2203: %[4] $B<M1F$7$F$+$i(B polytope $B$N%G!<%?$r7W;;(B.
2204: wv_start reduced_G coneEq /cone.g_ineq set
2205: cone.g_ineq cone.w_ineq join /cone.gw_ineq set
2206: cone.gw_ineq cone.Wt mul /cone.gw_ineq_projectedWt set % $B<M1F(B
2207: /cone.cinit cone.boundp {
2208: (Skipping cone.gw_ineq_projectedWt getConeInfo. cf. clearGlobals) message
2209: } {
2210: cone.gw_ineq_projectedWt getConeInfo /cone.cinit set
2211: } ifelse
2212:
2213: (cone.cinit is --- the first number is the dim of cone.) messagen
2214: cone.cinit 0 get pmat
2215: % Maximal dimensional cone $B$+$I$&$+$N8!::(B. $B8!::$K%Q%9$9$l$P(B loop $B$r(B exit
2216: % $B%Q%9$7$J$$>l9g(B w_start $B$r(B cone_random_vec $B$rMQ$$$FJQ99$9$k(B.
2217: cone.cinit 0 get 0 get to_int32 cone.m eq { exit }
2218: {
2219: (Failed to get the max dim cone. Updating the weight ...) messagen
1.2 takayama 2220: cone.m cone_random_vec /cone.w_start set
2221: /w_start cone.w_start cone.W mul def
1.1 takayama 2222: % cone.cinit $B$r:FEY7W;;$9$k$?$a$K(B clear $B$9$k(B.
2223: /cone.cinit null def
2224: } ifelse
2225: } loop
2226:
2227: (cone.m = ) messagen cone.m message
2228: (Suceeded to get the maximal dimensional startingCone.) message
2229:
2230: % Linearity subspace $B$N(B orth complement $B$X$N<M1F9TNs(B.
2231: % $BBg0hJQ?t(B cone.Lp, cone.Lpt $B$r@_Dj(B
2232: cone.cinit 0 get 1 get /cone.Lp set
2233: cone.Lp transpose /cone.Lpt set
2234: % Linearity subspace $B$N9TNs$r@_Dj(B.
2235: % $BBg0hJQ?t(B cone.L $B$r@_Dj(B
2236: cone.cinit 0 get 2 get /cone.L set
2237: % 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.
2238: % $BBg0hJQ?t(B cone.d $B$N@_Dj(B.
2239: /cone.d cone.Lp length def
2240:
2241: cone.m cone.d eq {
2242: (There is no linearity space) message
2243: } {
2244: (Dim of the linearity space is ) messagen cone.m cone.d sub message
2245: (cone.Lp = ) messagen cone.Lp pmat
2246: } ifelse
2247:
2248: %[5] cone.g_ineq * cone.Wt * cone.Lpt
2249: % cone.w_ineq * cone.Wt * cone.Lpt
2250: % $B$G@)Ls$r(B d $B<!85%Y%/%H%k$KJQ49(B.
2251: % W (R^m) $B6u4V$NITEy<0@)Ls$r(B L' (R^d) $B6u4V$X<M1F(B
2252: % cone.gw_ineq_projectedWtLpt
2253: % = cone.g_ineq*cone.Wt*cone.Lpt \/ cone.w_ineq*coneWt*cone.Lpt
2254:
2255: /cone.gw_ineq_projectedWtLpt
2256: cone.gw_ineq_projectedWt cone.Lpt mul
2257: def
2258:
2259: cone.m cone.d eq {
2260: /cone.cinit.d cone.cinit def
2261: } {
2262: % cone.m > cone.d $B$J$i$P(B, $B:FEY(B cone $B$N7W;;$,I,MW(B.
2263: % R^d $B$N(B cone $B$O(B cone.cinit.d $B$XF~$l$k(B.
2264: cone.gw_ineq_projectedWtLpt getConeInfo /cone.cinit.d set
2265: } ifelse
2266:
2267: cone.cinit.d 1 get newCone /cone.startingCone set
2268:
2269: (cone.startingCone is ) message
2270: cone.startingCone message
2271: ] pop
2272: popVariables
2273: cone.startingCone
2274: } def
2275:
2276: %
2277: % data/test9.sm1 $B$N(B test9 1-simplex X 2-simplex
2278: %
2279: % data/test10.sm1 1-simplex X 3-simplex
2280: % data/test11.sm1 SST, p.59
2281: %
2282: % $B$$$h$$$h(B, cone enumeration $B$N%W%m%0%i%`=q$-3+;O(B
2283: %
2284:
2285: %<
2286: % Usages: cone markBorder
2287: % cone->facets[i] $B$,(B weight space $B$N(B border $B$K$"$k$H$-(B
2288: % cone->flipped[i] = 2 $B$H$9$k(B.
2289: % $B$3$l$r(B cone $B$N$9$Y$F$N(B facet $B$KBP$7$F7W;;(B.
2290: %>
2291: /markBorder {
2292: /arg1 set
1.4 takayama 2293: [/cone /facets_t /flipped_t /kk /nextcid_t /nextfid_t] pushVariables
1.1 takayama 2294: [
2295: /cone arg1 def
2296: cone (facets) getNode 2 get /facets_t set
2297: cone (flipped) getNode 2 get /flipped_t set
1.4 takayama 2298: cone (nextcid) getNode 2 get /nextcid_t set
2299: cone (nextfid) getNode 2 get /nextfid_t set
1.1 takayama 2300: 0 1 flipped_t length 1 sub {
2301: /kk set
2302: flipped_t kk get (0).. eq {
2303: cone kk isOnWeightBorder {
2304: % Border $B$N>e$K$"$k$N$G(B flip $B:Q$N%^!<%/$r$D$1$k(B.
2305: flipped_t kk (2).. put
1.4 takayama 2306: % $B$H$J$j$N(B cone $B$N(B id (nextcid, nextfid) $B$O(B -2 $B$H$9$k(B.
2307: nextcid_t kk (-2).. put
2308: nextfid_t kk (-2).. put
1.1 takayama 2309: } { } ifelse
2310: } { } ifelse
2311: } for
2312: ] pop
2313: popVariables
2314: } def
2315:
2316: %<
2317: % Usages: ncone updateFan
2318: % $B%0%m!<%P%kJQ?t(B cone.fan $B$r99?7$9$k(B.
2319: %>
2320: %
2321: % updateFan $B$N(B debug $B$O(B data/test8 $B$G$H$j$"$($:$d$k(B.
2322: % test8 /ncone set $B$r<B9T$7$F$+$i(B ncone updateFan
2323:
2324: % global: cone.fan
2325: /cone.fan [ ] def
2326: % global: cone.incidence
2327: /cone.incidence [ ] def
1.2 takayama 2328: % global: cone.gblist gb's standing for each cones in cone.fan.
2329: /cone.gblist [ ] def
1.1 takayama 2330:
2331: /updateFan {
2332: /arg1 set
2333: [/ncone /kk /cfacet /ii /jj /tcone /flipped_t] pushVariables
2334: [
2335: /ncone arg1 def
2336: /cone.fan.n cone.fan length def
1.2 takayama 2337: % -1. cone.cgb ($BD>A0$K7W;;$5$l$?(B gb) $B$H(B cone.cgb_weight ($BD>A0$N7W;;$N(B weight)
2338: % $B$r(B cone.gblist $B$X3JG<$9$k(B.
2339: cone.gblist [ [cone.cgb cone.cgb_weight] newConeGB ] join /cone.gblist set
1.1 takayama 2340: % 0. ncone $B$,(B cone.fan $B$K$9$G$K$"$l$P%(%i!<(B
2341: 0 1 cone.fan.n 1 sub {
2342: /kk set
2343: ncone cone.fan kk get isSameCone {
2344: (Internal error updateFan: ncone is already in cone.fan) error
2345: } { } ifelse
2346: } for
2347:
2348: % 1. ncone $B$NCf$N(B border $B>e$N(B facet $B$r$9$Y$F(B mark.
2349: ncone markBorder
2350:
2351: % 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
2352: 0 1 cone.fan.n 1 sub {
2353: /kk set
2354: ncone cone.fan kk get getCommonFacet /cfacet set
2355: cfacet 0 get
2356: {
2357: % $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.
2358: /ii cfacet 1 get 0 get def
2359: /jj cfacet 2 get 0 get def
2360: cone.incidence [ [[cone.fan.n ii] [kk jj]] ] join /cone.incidence set
2361: % flipped $B$r(B mark $B$9$k(B.
2362: ncone ii markFlipped
2363: cone.fan kk get /tcone set
2364: tcone jj markFlipped
1.4 takayama 2365: % nextcid, nextfid $B$r@_Dj$9$k(B.
2366: ncone ii [kk jj] markNext
2367: tcone jj [cone.fan.n ii] markNext
1.1 takayama 2368: } { } ifelse
2369: } for
2370: % 3. ncone $B$r2C$($k(B.
2371: cone.fan [ncone] join /cone.fan set
2372: ] pop
2373: popVariables
2374: } def
2375:
2376: %<
1.9 takayama 2377: % usages: getNextFlip [cone, k, cid]
1.1 takayama 2378: % 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.
2379: % $B$b$&$J$$$H$-$K$O(B null $B$rLa$9(B.
1.9 takayama 2380: % 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
2381: % $BMQ$$$k(B.
1.1 takayama 2382: %>
2383: /getNextFlip {
1.9 takayama 2384: [/tcone /ans /ii /cid] pushVariables
1.1 takayama 2385: [
1.9 takayama 2386: /ans null def /cid -1 def
1.1 takayama 2387: 0 1 cone.fan length 1 sub {
2388: /ii set
2389: cone.fan ii get /tcone set
1.9 takayama 2390: /cid ii def
1.1 takayama 2391: tcone getNextFacet /ans set
2392: ans tag 0 eq { } { exit } ifelse
2393: } for
2394: ans tag 0 eq { /arg1 null def }
1.9 takayama 2395: { /arg1 [tcone ans cid] def } ifelse
1.1 takayama 2396: ] pop
2397: popVariables
2398: arg1
2399: } def
2400:
2401: % global variable : cone.epsilon , cone.epsilon.limit
2402: % flip $B$N;~$N(B epsilon
2403: /cone.epsilon (1).. (10).. div def
2404: /cone.epsilon.limit (1).. (100).. div def
1.9 takayama 2405: % cone.epsilon.limit $B$rIi$K$9$l$PDd;_$7$J$$(B.
1.1 takayama 2406:
2407: %<
2408: % Usages: result_getNextFlip getNextCone ncone
2409: % flip $B$7$F?7$7$$(B ncone $B$rF@$k(B.
2410: %>
1.11 takayama 2411: /getNextCone.orig {
1.1 takayama 2412: /arg1 set
2413: [/ncone /ccone /kk /w /next_weight_w_wv] pushVariables
2414: [
2415: /ccone arg1 def
2416: /ncone null def
2417: /kk ccone 1 get def
2418: ccone 0 get /ccone set
2419: {
2420: ccone tag 0 eq { exit } { } ifelse
2421:
2422: % ccone $B$N(B kk $BHVL\$N(B facet $B$K$D$$$F(B flip $B$9$k(B.
2423: ccone kk cone.epsilon flipWeight /w set
2424: (Trying new weight is ) messagen w message
2425: w liftWeight /next_weight_w_wv set
2426: (Trying new weight [w,wv] is ) messagen next_weight_w_wv message
2427:
2428: cone.input next_weight_w_wv 1 get cone.gb /cone.cgb set
1.2 takayama 2429: [w] next_weight_w_wv join /cone.cgb_weight set
1.1 takayama 2430: next_weight_w_wv 1 get cone.cgb coneEq /cone.g_ineq set
2431: cone.g_ineq cone.w_ineq join cone.Wt mul cone.Lpt mul
2432: pruneZeroVector /cone.gw_ineq_projectedWtLpt set
2433:
2434: (cone.gw_ineq_projectedWtLpt is obtained.) message
2435:
2436: cone.gw_ineq_projectedWtLpt getConeInfo /cone.nextConeInfo set
2437: % $B<!85$rD4$Y$k(B. $B$@$a$J$i(B retry
2438: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
2439: cone.nextConeInfo 1 get newCone /ncone set
2440: ccone ncone getCommonFacet 0 get {
2441: (Flip succeeded.) message
2442: exit
2443: } { } ifelse
2444: } { } ifelse
2445: % common face $B$,$J$1$l$P(B $B$d$O$j(B epsilon $B$r>.$5$/(B.
2446: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
2447: (ccone and ncone do not have a common facet.) message
2448: } {
2449: (ncone is not maximal dimensional. ) message
2450: } ifelse
2451: (Decreasing epsilon to ) messagen
2452: cone.epsilon (1).. (2).. div mul /cone.epsilon set
2453: cone.epsilon cone.epsilon.limit sub numerator (0).. lt {
2454: (Too small cone.epsilon ) error
2455: } { } ifelse
2456: cone.epsilon message
2457: } loop
2458: /arg1 ncone def
2459: ] pop
2460: popVariables
2461: arg1
2462: } def
2463:
2464: %<
2465: % Usages: set globals and getGrobnerFan
2466: % cf. clearGlobals
2467: % getStartingCone $B$9$k$H(B weightSpace $B$H$+$N7W;;$,$G$-$k(B. isOnWeightBorder $B$,(B
2468: % $B7h$a$i$l$k(B.
2469: %>
2470: % $B$H$j$"$($:(B (data/test8.sm1) run $B$7$F$+$i(B getGrobnerFan
2471: /getGrobnerFan {
2472: getStartingCone /cone.ncone set
2473: {
2474: cone.ncone updateFan
2475: ( ) message
2476: (----------------------------------------------------------) message
2477: (getGrobnerFan #cone.fan=) messagen cone.fan length message
2478: cone.ncone /cone.ccone set
2479: getNextFlip /cone.nextflip set
2480: cone.nextflip tag 0 eq { exit } { } ifelse
2481: cone.nextflip getNextCone /cone.ncone set
2482: } loop
1.2 takayama 2483: (Construction is completed. See cone.fan, cone.incidence and cone.gblist.)
2484: message
2485: } def
2486:
2487: %<
2488: % Usages: vlist generateD1_1
2489: % -1,1 weight $B$r@8@.$9$k(B.
2490: % vlist $B$O(B (t,x,y) $B$+(B [(t) (x) (y)]
2491: %
2492: %>
2493: /generateD1_1 {
2494: /arg1 set
2495: [/vlist /rr /rr /ii /vv] pushVariables
2496: [
2497: /vlist arg1 def
2498: vlist isString {
2499: [vlist to_records pop] /vlist set
2500: } { } ifelse
2501: [
2502: 0 1 vlist length 1 sub {
2503: /ii set
2504: vlist ii get /vv set
2505: vv -1
2506: [@@@.Dsymbol vv] cat 1
2507: } for
2508: ] /rr set
2509: /arg1 rr def
2510: ] pop
2511: popVariables
2512: arg1
2513: } def
2514:
2515: /listNodes {
2516: /arg1 set
2517: [/in-listNodes /ob /rr /rr /ii] pushVariables
2518: [
2519: /ob arg1 def
2520: /rr [ ] def
2521: {
2522: ob isClass {
2523: ob (array) dc /ob set
2524: } { exit } ifelse
2525: rr [ob 0 get] join /rr set
2526: ob 2 get /ob set
2527: 0 1 ob length 1 sub {
2528: /ii set
2529: rr ob ii get listNodes join /rr set
2530: } for
2531: exit
2532: } loop
2533: /arg1 rr def
2534: ] pop
2535: popVariables
2536: arg1
2537: } def
2538: [(listNodes)
2539: [(ob listNodes)
2540: (cf. getNode)
2541: (Example:)
2542: ( /dog [(dog) [[(legs) 4] ] [ ]] [(class) (tree)] dc def)
2543: ( /man [(man) [[(legs) 2] ] [ ]] [(class) (tree)] dc def)
2544: ( /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def)
2545: ( ma listNodes )
2546: ]] putUsages
2547:
2548: %<
2549: % Usages: obj printTree
2550: %>
2551: /printTree {
2552: /arg1 set
2553: [/ob /rr /rr /ii /keys /tt] pushVariables
2554: [
2555: /ob arg1 def
2556: /rr [ ] def
2557: /keys ob listNodes def
2558: keys 0 get /tt set
2559: keys rest /keys set
2560: keys { ob 2 1 roll getNode } map /rr set
2561: (begin ) messagen tt messagen
2562: ( ---------------------------------------) message
2563: 0 1 rr length 1 sub {
2564: /ii set
2565: keys ii get messagen (=) message
2566: rr ii get 2 get pmat
2567: } for
2568: (--------------------------------------- end ) messagen
2569: tt message
2570: /arg1 rr def
2571: ] pop
2572: popVariables
2573: arg1
2574: } def
2575:
2576: %<
2577: % Usages $B$O(B (inputForm) usages $B$r$_$h(B.
2578: %>
2579: /inputForm {
2580: /arg1 set
2581: [/ob /rr /i ] pushVariables
2582: [
2583: /ob arg1 def
2584: /rr [ ] def
2585: {
2586: ob isArray {
2587: rr [ ([) ] join /rr set
2588: 0 1 ob length 1 sub {
2589: /i set
2590: i ob length 1 sub lt {
2591: rr [ob i get inputForm $ , $] join /rr set
2592: } {
2593: rr [ob i get inputForm] join /rr set
2594: } ifelse
2595: } for
2596: rr [ (]) ] join cat /rr set
2597: exit
2598: } { } ifelse
2599: ob isClass {
2600: ob etag 263 eq { % tree
2601: /rr ob inputForm.tree def exit
2602: } { /rr [( $ this etag is not implemented $ )] cat def exit } ifelse
2603: } { } ifelse
2604: ob isUniversalNumber {
2605: [$($ ob toString $)..$] cat /rr set
2606: exit
2607: } { } ifelse
2608: ob isPolynomial {
2609: [$($ ob toString $).$] cat /rr set
2610: exit
2611: } { } ifelse
2612: ob isRational {
2613: [$ $ ob (numerator) dc inputForm $ $
2614: ob (denominator) dc inputForm $ div $ ] cat /rr set
2615: exit
2616: } { } ifelse
2617: ob isString {
2618: [$($ ob $)$ ] cat /rr set
2619: exit
2620: } { } ifelse
2621: ob toString /rr set
2622: exit
2623: } loop
2624: rr /arg1 set
2625: ] pop
2626: popVariables
2627: arg1
2628: } def
2629: [(inputForm)
2630: [(obj inputForm str)
2631: ]] putUsages
2632: % should be moved to dr.sm1
2633:
2634: /inputForm.tree {
2635: /arg1 set
2636: [/ob /key /rr /rr /ii] pushVariables
2637: [
2638: /ob arg1 def
2639: /rr [ ] def
2640: {
2641: ob (array) dc /ob set
2642: /rr [ $[$ ob 0 get inputForm $ , $
2643: ob 1 get inputForm $ , $
2644: ] def
2645: rr [ob 2 get inputForm ] join /rr set
2646: rr [$ ] $] join /rr set
2647: rr [ $ [(class) (tree)] dc $ ] join /rr set
2648: rr cat /rr set
2649: exit
2650: } loop
2651: /arg1 rr def
2652: ] pop
2653: popVariables
2654: arg1
2655: } def
2656:
2657: %<
2658: % Usages: str inputForm.value str
2659: %>
2660: /inputForm.value {
2661: /arg1 set
2662: [/key /val /valstr /rr] pushVariables
2663: [
2664: arg1 /key set
2665: key isString { } {(inputForm.value: argument must be a string) error } ifelse
2666: key boundp {
2667: [(parse) key] extension pop
2668: /val set
2669: val inputForm /valstr set
2670: [( ) valstr ( /) key ( set )] cat /rr set
2671: } {
2672: /valstr [] cat /rr set
2673: } ifelse
2674: rr /arg1 set
2675: ] pop
2676: popVariables
2677: arg1
2678: } def
2679:
2680: % global: cone.withGblist
2681: /cone.withGblist 0 def
2682: %<
2683: % Usages: saveGrobnerFan str
2684: % GrobnerFan $B$N%G!<%?$r(B inputForm $B$KJQ99$7$FJ8;zNs$KJQ$($k(B.
2685: % $B$3$N%G!<%?$r(B parse $B$9$k$H(B GrobnerFan $B$rF@$k$3$H$,2DG=(B.
2686: % BUG: $BB?9`<0$NB0$9$k4D$N%G!<%?$NJ]B8$O$^$@$7$F$J$$(B.
2687: %>
2688: /saveGrobnerFan {
2689: [/rr] pushVariables
2690: [
2691: (cone.withGblist=) messagen cone.withGblist message
2692: [
2693: % $B%f!<%6$N@_Dj$9$k%Q%i%a!<%?(B. cone.gb, cone.parametrizeWeightSpace $BEy$N4X?t$b$"$j(B.
2694: (cone.comment)
2695: (cone.type) (cone.local) (cone.h0)
2696: (cone.vlist) (cone.vv)
2697: (cone.input)
2698:
2699: % $B%W%m%0%i%`Cf$GMxMQ$9$k(B, $BBg;v$JBg0hJQ?t(B. weight vector $B$N<M1F9TNs$,=EMW(B.
2700: (cone.n) (cone.m) (cone.d)
2701: (cone.W) (cone.Wpos) (cone.Wt)
2702: (cone.L) (cone.Lp) (cone.Lpt)
2703: (cone.weightBorder)
2704: (cone.w_ineq)
2705: (cone.w_ineq_projectedWt)
2706: (cone.epsilon)
2707:
2708: % $B7k2L$NMWLs(B.
2709: (cone.fan)
2710: cone.withGblist { (cone.gblist) } { } ifelse
2711: (cone.incidence)
2712:
2713: ] { inputForm.value nl } map /rr set
1.3 takayama 2714: rr cat /rr set
2715: % ring $B$r(B save $B$7$F$J$$$N$GEv:B$NBP=h(B.
2716: [ ([) cone.vv inputForm ( ring_of_differential_operators 0 ] define_ring )
2717: nl nl rr] cat /arg1 set
1.2 takayama 2718: ] pop
2719: popVariables
2720: arg1
2721: } def
2722:
2723: /printGrobnerFan.1 {
2724: /arg1 set
2725: [/key /rr] pushVariables
2726: [
2727: /key arg1 def
2728: key boundp {
2729: [(parse) key] extension pop /rr set
2730: rr isArray {
2731: key messagen ( = ) message rr pmat
2732: } {
2733: key messagen ( = ) messagen rr message
2734: } ifelse
2735: }{
2736: key messagen ( = ) message
2737: } ifelse
2738: ] pop
2739: popVariables
2740: } def
2741:
2742: /printGrobnerFan {
2743: [/i] pushVariables
2744: [
2745: (========== Grobner Fan ====================) message
2746: [
2747: (cone.comment)
2748: (cone.vlist) (cone.vv)
2749: (cone.input)
2750: (cone.type) (cone.local) (cone.h0)
2751: (cone.n) (cone.m) (cone.d)
2752: (cone.W) (cone.Wpos) (cone.Wt)
2753: (cone.L) (cone.Lp) (cone.Lpt)
2754: (cone.weightBorder)
2755: (cone.incidence)
2756: ] { printGrobnerFan.1 } map
2757: ( ) message
2758: 0 1 cone.fan length 1 sub {
2759: /ii set
2760: ii messagen ( : ) messagen
2761: cone.fan ii get printTree
2762: } for
2763: cone.withGblist {
2764: 0 1 cone.gblist length 1 sub {
2765: /ii set
2766: ii messagen ( : ) messagen
2767: cone.gblist ii get printTree
2768: } for
2769: } { } ifelse
2770:
2771:
2772: (=========================================) message
2773: (cone.withGblist = ) messagen cone.withGblist message
2774: ( ) message
2775: ] pop
2776: popVariables
2777: } def
2778:
2779: %<
2780: % Usages: m uniq
2781: % Remove duplicated lines.
2782: %>
2783: /uniq {
2784: /arg1 set
2785: [/mm /prev /i /rr] pushVariables
2786: [
2787: /mm arg1 def
2788: {
2789: mm length 0 eq { [ ] /rr set exit } { } ifelse
2790: /prev mm 0 get def
2791: [
2792: prev
2793: 1 1 mm length 1 sub {
2794: /i set
2795: mm i get prev sub isZero { }
2796: { /prev mm i get def prev } ifelse
2797: } for
2798: ] /rr set
2799: exit
2800: } loop
2801: rr /arg1 set
2802: ] pop
2803: popVariables
2804: arg1
2805: } def
1.3 takayama 2806:
2807: %<
2808: % Usages: [vlist vw_vector] getGrRing [vlist vGlobal sublist]
2809: % example: [(x,y,z) [(x) -1 (Dx) 1 (y) 1 (Dy) 2]] getGrRing
2810: % [(x,y,z,y') [(x)] [[(Dy) (y')]]]
2811: % h[0,1](D_0) $B@lMQ$N(B getGrRing.
2812: % u_i + v_i > 0 $B$J$i(B Dx_i ==> x_i' ($B2D49$JJQ?t(B). sublist $B$X(B.
2813: % u_i < 0 $B$J$i(B x_i $B$O(B vGlobal $B$X(B.
2814: % ii [vlist vGlobal sublist] toGrRing /ii set
2815: % [ii jj vlist [(partialEcartGlobalVarX) vGlobal]] ecart.isSameIdeal $B$H;H$&(B.
2816: %>
2817: /getGrRing {
2818: /arg1 set
2819: [/vlist /vw_vector /ans /vGlobal /sublist /newvlist
2820: /dlist /tt /i /u /v /k
2821: ] pushVariables
2822: [
2823: /vlist arg1 0 get def
2824: /vw_vector arg1 1 get def
2825:
2826: vlist isString { [vlist to_records pop] /vlist set } { } ifelse
2827: vlist { toString } map /vlist set
2828: % dlist $B$O(B [(Dx) (Dy) (Dz)] $B$N%j%9%H(B.
2829: vlist { /tt set [@@@.Dsymbol tt] cat } map /dlist set
2830:
2831: /newvlist [ ] def /sublist [ ] def /vGlobal [ ] def
2832: % $B2D49$J?7$7$$JQ?t$r(B newvlist $B$X(B. $BCV49I=$r(B sublist $B$X(B.
2833: 0 1 vlist length 1 sub {
2834: /i set
2835: % (u,v) $B$O(B (x_i, Dx_i) $B$KBP$9$k(B weight vector
2836: /u vlist i get , vw_vector getGrRing.find def
2837: u -1 gt {
2838: vw_vector , u 1 add , get /u set
2839: } { /u 0 def } ifelse
2840:
2841: /v dlist i get , vw_vector getGrRing.find def
2842: v -1 gt {
2843: vw_vector , v 1 add , get /v set
2844: } { /v 0 def } ifelse
2845: u to_int32 /u set , v to_int32 /v set
2846:
2847: u v add , 0 gt {
2848: newvlist [vlist i get] join /newvlist set
2849: } { } ifelse
2850: u 0 lt {
2851: vGlobal [vlist i get] join /vGlobal set
2852: } { } ifelse
2853: } for
2854:
2855: newvlist { /tt set [ [@@@.Dsymbol tt] cat [tt (')] cat ] } map
2856: /sublist set
2857:
2858: /ans [ vlist , newvlist { /tt set [tt (')] cat } map , join from_records
2859: vGlobal sublist] def
2860: /arg1 ans def
2861: ] pop
2862: popVariables
2863: arg1
2864: } def
2865:
2866: %<
2867: % Usages: a uset getGrRing.find index
2868: %>
2869: /getGrRing.find {
2870: /arg2 set /arg1 set
2871: [/a /uset /ans /i] pushVariables
2872: [
2873: /a arg1 def /uset arg2 def
2874: /ans -1 def
2875: { /ans -1 def
2876: 0 1 , uset length 1 sub {
2877: /i set
2878: a tag , uset i get tag eq {
2879: a , uset i get eq {
2880: /ans i def exit
2881: } { } ifelse
2882: } { } ifelse
2883: } for
2884: exit
2885: } loop
2886: /arg1 ans def
2887: ] pop
2888: popVariables
2889: arg1
2890: } def
2891:
2892: %<
2893: % Usages: g1 g2 isSameGrRing bool
2894: % g1, g2 $B$O(B getGrRing $B$NLa$jCM(B.
2895: %>
2896: /isSameGrRing {
2897: /arg2 set /arg1 set
2898: [/g1 /g2 /ans] pushVariables
2899: [
2900: /g1 arg1 def /g2 arg2 def
2901: {
2902: /ans 1 def
2903: g1 0 get , g2 0 get eq { } { /ans 0 def exit } ifelse
2904: exit
2905: g1 1 get , g2 1 get eq { } { /ans 0 def exit } ifelse
2906: } loop
2907: /arg1 ans def
2908: ] pop
2909: popVariables
2910: arg1
2911: } def
2912:
2913: %<
2914: % Usages: [[ii i_vw_vector] [jj j_vw_vector] vlist] isSameInGrRing_h
1.4 takayama 2915: % It computes gb.
1.3 takayama 2916: %>
2917: /isSameInGrRing_h {
2918: /arg1 set
2919: [/ii /i_vw_vector /jj /j_vw_vector /vlist
2920: /i_gr /j_gr /rrule /ans] pushVariables
2921: [
2922: /ii arg1 [0 0] get def
2923: /i_vw_vector arg1 [0 1] get def
2924: /jj arg1 [1 0] get def
2925: /j_vw_vector arg1 [1 1] get def
2926: /vlist arg1 2 get def
2927: {
2928: [vlist i_vw_vector] getGrRing /i_gr set
2929: [vlist j_vw_vector] getGrRing /j_gr set
2930: i_gr j_gr isSameGrRing { } { /ans [0 [i_gr j_gr]] def exit} ifelse
2931:
2932: % bug: in case of module
2933: [i_gr 0 get , ring_of_differential_operators 0] define_ring
2934:
2935: % H $B$r(B 1 $B$K(B.
2936: /rrule [ [@@@.Hsymbol . (1).] ] def
2937:
2938: i_gr 2 get length 0 eq {
2939: } {
2940: rrule i_gr 2 get { { . } map } map join /rrule set
2941: } ifelse
2942: ii { toString . rrule replace toString } map /ii set
2943: jj { toString . rrule replace toString } map /jj set
2944:
2945: [ii jj i_gr 0 get , i_gr 1 get] ecartd.isSameIdeal_h /ans set
2946: [ans [i_gr] rrule ecartd.isSameIdeal_h.failed] /ans set
2947:
2948: exit
2949: } loop
2950: /arg1 ans def
2951: ] pop
2952: popVariables
2953: arg1
2954: } def
2955:
2956: /test1.isSameInGrRing_h {
2957: [(parse) (data/test8-data.sm1) pushfile] extension
2958:
2959: cone.gblist 0 get (initial) getNode 2 get /ii set
2960: cone.gblist 0 get (weight) getNode [2 0 2] get /iiw set
2961:
2962: cone.gblist 1 get (initial) getNode 2 get /jj set
2963: cone.gblist 1 get (weight) getNode [2 0 2] get /jjw set
2964:
2965: (Doing [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ff set) message
2966: [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ff set
2967:
2968: ff pmat
2969:
2970: } def
2971:
2972:
2973: %<
1.4 takayama 2974: % Usages: i j isSameCone_h.0 [bool, ...]
2975: % $B%F%9%HJ}K!(B. (data/test8.sm1) run (data/test8-data.sm1) run 0 1 isSameCone_h.0
2976: % gb $B$r:FEY7W;;$9$k(B stand alone $BHG(B. gr(Local ring) $B$GHf3S(B.
1.3 takayama 2977: %>
1.4 takayama 2978: /isSameCone_h.0 {
1.3 takayama 2979: /arg2 set /arg1 set
2980: [/i /j /ans /ii /iiw /jj /jjw] pushVariables
2981: [
2982: /i arg1 def /j arg2 def
1.4 takayama 2983: i to_int32 /i set , j to_int32 /j set
1.3 takayama 2984: cone.debug { (Comparing ) messagen [i j] message } { } ifelse
2985:
2986: cone.gblist i get (initial) getNode 2 get /ii set
2987: cone.gblist i get (weight) getNode [2 0 2] get /iiw set
2988:
2989: cone.gblist j get (initial) getNode 2 get /jj set
2990: cone.gblist j get (weight) getNode [2 0 2] get /jjw set
2991:
2992: [ [ii iiw] [jj jjw] cone.vv ] isSameInGrRing_h /ans set
2993:
2994: ans /arg1 set
2995: ] pop
2996: popVariables
2997: arg1
2998: } def
2999:
1.4 takayama 3000: %<
3001: % Usages: [ii vv i_vw_vector] getGbInGrRing_h [ii_gr i_gr]
3002: % Get Grobner Basis of ii in the graded ring.
3003: % The graded ring is obtained automatically from vv and i_vw_vector.
3004: % ii_gr is the Grobner basis. i_gr is the output of getGrRing.
3005: % cf. isSameInGrRing_h, ecart.isSameIdeal_h with [(noRecomputation) 1]
3006: %>
3007: /getGbInGrRing_h {
3008: /arg1 set
3009: [/ii /i_vw_vector /vlist /rng /vv /vvGlobal /wv /iigg
3010: /i_gr /rrule /ans] pushVariables
3011: [
3012: /ii arg1 0 get def
3013: /vlist arg1 1 get def
3014: /i_vw_vector arg1 2 get def
3015: [vlist i_vw_vector] getGrRing /i_gr set
3016:
3017: % bug: in case of module
3018: [i_gr 0 get , ring_of_differential_operators 0] define_ring
3019:
3020: % H $B$r(B 1 $B$K(B.
3021: /rrule [ [@@@.Hsymbol . (1).] ] def
3022:
3023: i_gr 2 get length 0 eq {
3024: } {
3025: rrule i_gr 2 get { { . } map } map join /rrule set
3026: } ifelse
3027: /vvGlobal i_gr 1 get def
3028: /vv i_gr 0 get def
3029:
3030: ii { toString . rrule replace toString } map /ii set
3031:
3032: [vv vvGlobal] ecart.stdBlockOrder /wv set
3033: vvGlobal length 0 eq {
3034: /rng [vv wv ] def
3035: }{
3036: /rng [vv wv [(partialEcartGlobalVarX) vvGlobal]] def
3037: } ifelse
3038: /save-cone.autoHomogenize ecart.autoHomogenize def
3039: /ecart.autoHomogenize 0 def
3040: [ii] rng join ecartd.gb /iigg set
3041: save-cone.autoHomogenize /ecart.autoHomogenize set
3042: /ans [iigg 0 get i_gr] def
3043: /arg1 ans def
3044: ] pop
3045: popVariables
3046: arg1
3047: } def
3048:
3049: /test1.getGbInGrRing_h {
3050: [(parse) (data/test8-data.sm1) pushfile] extension
3051:
3052: cone.gblist 0 get (initial) getNode 2 get /ii set
3053: cone.gblist 0 get (weight) getNode [2 0 2] get /iiw set
3054: [ii cone.vv iiw] getGbInGrRing_h /ff1 set
3055:
3056: cone.gblist 1 get (initial) getNode 2 get /jj set
3057: cone.gblist 1 get (weight) getNode [2 0 2] get /jjw set
3058: [jj cone.vv jjw] getGbInGrRing_h /ff2 set
3059:
3060: (ff1 and ff2) message
3061:
3062: } def
3063:
3064:
3065: %<
3066: % setGrGblist
3067: % cone.grGblist $B$r@_Dj$9$k(B.
3068: %>
3069: /setGrGblist {
3070: [/ii /ww /gg] pushVariables
3071: [
3072: cone.gblist {
3073: /gg set
3074: gg (initial) getNode 2 get /ii set
3075: gg (weight) getNode [2 0 2] get /ww set
3076: [ii cone.vv ww] getGbInGrRing_h
3077: } map /cone.grGblist set
3078: ] pop
3079: popVariables
3080: } def
3081:
3082: %<
3083: % Usages: i j isSameCone_h.2 [bool, ...]
3084: % gb $B$r:FEY7W;;$7$J$$(B.
3085: %>
3086: /isSameCone_h.2 {
3087: /arg2 set /arg1 set
3088: [/i /j /ans /ii /iiw /jj /jjw] pushVariables
3089: [
3090: /i arg1 def /j arg2 def
3091: i to_int32 /i set , j to_int32 /j set
3092: (cone.grGblist) boundp { } { setGrGblist } ifelse
3093: cone.debug { (Comparing ) messagen [i j] message } { } ifelse
3094:
3095: cone.grGblist i get /ii set
3096: cone.grGblist j get /jj set
3097:
3098: ii 1 get , jj 1 get isSameGrRing { }
3099: { /ans [0 [ii 1 get jj 1 get]] def exit} ifelse
3100:
3101: [ii 0 get , jj 0 get cone.vv [[(noRecomputation) 1]] ]
3102: ecartd.isSameIdeal_h /ans set
3103: [ans [ii 1 get] ii 1 get , ecartd.isSameIdeal_h.failed] /ans set
3104:
3105: ans /arg1 set
3106: ] pop
3107: popVariables
3108: arg1
3109: } def
3110:
3111: %<
3112: % test1.isSameCone_h.2 $B$O(B cone.grGblist $B$K(B initial $B$N(B gb $B$r(B graded ring
3113: % $B$G$^$:7W;;$7(B, $B$=$l$+$i(B ideal $B$NHf3S$r$*$3$J$&(B. isSameCone_h.1 $B$KHf$Y$F(B
3114: % gb $B$N:FEY$N7W;;$,$J$$$N$G7P:QE*(B.
3115: %>
3116: /test1.isSameCone_h.2 {
3117: /cone.loaded boundp { }
3118: {
3119: [(parse) (cohom.sm1) pushfile] extension
3120: [(parse) (dhecart.sm1) pushfile] extension
3121: /cone.loaded 1 def
3122: } ifelse
3123: %[(parse) (cone.sm1) pushfile] extension
3124: [(parse) (data/test8-data.sm1) pushfile] extension
3125: setGrGblist
3126: (cone.grGblist is set.) message
3127: 0 1 isSameCone_h.2 pmat
3128: } def
3129:
3130: %<
3131: % 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
3132: % $B$dBg0hJQ?t$K;H$&(B.
3133: % cone.gblist, cone.fan $B$,@5$7$/@_Dj$5$l$F$$$k$3$H(B.
3134: % (setGrGblist $B$r<B9T:Q$G$"$k$3$H(B. $B<+F0<B9T$5$l$k$,(B... )
3135: %
3136: %>
3137:
3138: /isSameCone_h { isSameCone_h.2 } def
3139:
3140: %<
3141: % Usages: genDhcone.init
3142: % dhcone.checked (dehomogenized $B:Q$N(B cone$BHV9f(B), dhcone.unchecked $B$N=i4|2=(B.
3143: %>
3144: /genDhcone.init {
3145: /dhcone.checked [ ] def
3146: /dhcone.unchecked [
3147: 0 1 cone.fan length 1 sub {
3148: to_univNum
3149: } for
3150: ] def
3151: } def
3152:
3153: %<
3154: % Usages: k genDhcone dhcone
3155: % 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).
3156: %
3157: % $B%F%9%H(B1. (data/test14.sm1) run (data/test14-data.sm1) run
3158: % genDhcone.init
3159: % 0 genDhcone /ff set
3160: %>
3161:
3162: /genDhcone {
3163: /arg1 set
3164: [/k /facets /merged /nextcid /nextfid /coneid
3165: /newfacets /newmerged /newnextcid /newnextfid /newconeid /vv
3166: /i /j /p /q /rr /cones /differentC
3167: ] pushVariables
3168: [
3169: /k arg1 def
3170: /facets [ ] def /merged [ ] def /nextcid [ ] def
3171: /nextfid [ ] def /coneid [ ] def
3172: /cones [ ] def
3173: /differentC [ ] def
3174:
3175: k to_univNum /k set
3176:
3177: {
3178: % Step1. cone.fan[k] $B$r(B $B2C$($k(B. new... $B$X=i4|%G!<%?$r=q$-9~$`(B.
3179: cone.debug {(Step 1. Adding ) messagen k messagen (-th cone.) message} { } ifelse
3180: cones [k to_univNum] join /cones set
3181: cone.fan k get , (facets) getNode 2 get /vv set
3182: /newfacets [ ] vv join def
3183:
3184: cone.fan k get , (nextcid) getNode 2 get /vv set
3185: /newnextcid [ ] vv join def
3186:
3187: cone.fan k get , (nextfid) getNode 2 get /vv set
3188: /newnextfid [ ] vv join def
3189:
3190: % newmerged $B$O$^$:(B 0 $B$G$&$a$k(B. 0 : $B$^$@D4$Y$F$J$$(B.
3191: % 1 : merged $B$G>C$($?(B. 2 : boundary. 3 : $B$H$J$j$O0[$J$k(B.
3192: % [ ] join $B$r$d$C$F(B $B%Y%/%H%k$N(B clone $B$r:n$k(B.
3193: cone.fan k get , (flipped) getNode 2 get /vv set
3194: /newmerged [ ] vv join def
3195: 0 1 , newmerged length 1 sub {
3196: /i set
3197: newmerged i get , (2).. eq { }
3198: { newmerged i (0).. put } ifelse
3199: } for
3200: % newconeid $B$O(B k $B$G$&$a$k(B.
3201: /newconeid newfacets length newVector { pop k to_univNum } map def
3202:
3203: % merged $B$H(B newmerged $B$r(B cone $B$NNY@\4X78$N$_$G99?7$9$k(B.
3204: % $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.
3205: % merged $B$N(B i $BHVL\(B $B$H(B newmerged $B$N(B j $BHVL\$GHf3S(B.
3206: 0 1 , merged length 1 sub {
3207: /i set
3208: 0 1 , newmerged length 1 sub {
3209: /j set
3210: merged i get , (0).. eq ,
3211: newmerged j get , (0).. eq , and
3212: nextcid i get , k to_univNum eq , and
3213: {
3214: facets i get , newfacets j get , add isZero {
3215: % merged[i], newmerged[j] $B$K(B 1 $B$rF~$l$F>C$9(B.
3216: % $B>e$NH=Dj$O(B nextfid, newnextfid $B$rMQ$$$F$b$h$$$N$G$O(B?
3217: merged i (1).. put
3218: newmerged j (1).. put
3219: } { } ifelse
3220: } { } ifelse
3221: } for
3222: } for
3223:
3224: % Step2. $B7k9g$7$F$+$i(B, $B$^$@D4$Y$F$J$$(B facet $B$rC5$9(B.
3225: cone.debug { (Step 2. Joining *** and new***) message } { } ifelse
3226: /facets facets newfacets join def
3227: /merged merged newmerged join def
3228: /nextcid nextcid newnextcid join def
3229: /nextfid nextfid newnextfid join
3230: /coneid coneid newconeid join def
3231:
3232: cone.debug{ ( Checking facets.) message } { } ifelse
3233: /k null def
3234: 0 1 , merged length 1 sub {
3235: /i set
3236: % i message
3237: merged i get (0).. eq {
3238: % i $BHVL\$r$^$@D4$Y$F$$$J$$(B.
3239: coneid i get , /p set
3240: nextcid i get , /q set
3241: cone.debug { [p q] message } { } ifelse
3242: q (0).. ge {
3243: % cone.fan [p] $B$H(B cone.fan [q] $B$N(B initial $B$rHf3S$9$k(B.
3244: % $BF1$8$J$i(B k $B$r@_Dj(B. exit for. $B0c$($P(B merged[i] = 3 ($B0c$&(B) $B$rBeF~(B.
3245: % differentC $B$O$9$G$K(B $B8=:_$N(B dhcone $B$H0c$&$H(B check $B$5$l$?(B cone $BHV9f(B.
3246: % dhcone.checked $B$O(B dhcone $B$,$9$G$K@8@.$5$l$F$$$k(B cone $BHV9f$N%j%9%H(B.
3247: % $B$3$l$K$O$$$C$F$$$F$b0c$&(B.
3248: q differentC memberQ , q dhcone.checked memberQ , or
3249: { /rr [0 ] def }
3250: { p q isSameCone_h /rr set } ifelse
3251:
3252: rr 0 get 1 eq {
3253: cone.debug { (Found next cone. ) message } { } ifelse
3254: /k q to_univNum def exit
3255: } {
3256: cone.debug { ( It is a different cone. ) message } { } ifelse
3257: differentC [ q ] join /differentC set
3258: merged i (3).. put
3259: } ifelse
3260: } { } ifelse
3261: } { } ifelse
3262: } for
3263:
3264: k tag 0 eq { exit } { } ifelse
3265: } loop
3266:
3267: [(-1)..] cones join shell rest /cones set
3268: % dhcone.checked, dhcone.unchecked $B$r99?7(B.
3269: dhcone.checked cones join /dhcone.checked set
3270: dhcone.unchecked cones setMinus /dhcone.unchecked set
3271:
3272: [(dhcone) [ ]
3273: [
3274: [(cones) [ ] cones] arrayToTree
3275: [(facets) [ ] facets] arrayToTree
3276: [(merged) [ ] merged] arrayToTree
1.5 takayama 3277: [(nextcid) [ ] nextcid] arrayToTree
3278: [(nextfid) [ ] nextfid] arrayToTree
3279: [(coneid) [ ] coneid] arrayToTree
1.4 takayama 3280: ]
3281: ] arrayToTree /arg1 set
3282: ] pop
3283: popVariables
3284: arg1
3285: } def
3286:
3287:
3288: %<
3289: % Usages: dhCones_h
3290: % cone.fan $B$O(B doubly homogenized (local) $B$G@8@.$5$l$?(B Grobner fan.
3291: % 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.
3292: %
3293: % $B%F%9%H(B1. (data/test14.sm1) run (data/test14-data.sm1) run
3294: % dhCones_h
3295: % test22
3296: %>
3297: /dhCones_h {
3298: (cone.grGblist) boundp { } {setGrGblist} ifelse
3299: genDhcone.init
3300: /dhcone.fan [ ] def
3301: {
3302: (-----------------------------------------) message
3303: (#dhcone.unchecked = ) messagen dhcone.unchecked length message
3304: dhcone.unchecked length 0 eq { exit } { } ifelse
3305: dhcone.fan
3306: [ dhcone.unchecked 0 get , genDhcone ] join /dhcone.fan set
3307: (#dhcone.fan = ) messagen dhcone.fan length message
3308: } loop
3309: dhcone.fan
3310: } def
3311:
1.5 takayama 3312: %<
3313: % Usages: dhcone.rtable
3314: % 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)
3315: % $B$r(B dhcone.fan $B$+$i:n$k(B. dhcone2.gblist $B$b:n$kJd=u4X?t(B.
3316: % dhCones_h $B$7$F$+$i(B dhcone.rable $B$9$k(B.
3317: %>
3318: /dhcone.rtable {
3319: [/i /j /vv /cones /facets /facets2 /merged /nextcid /nextcid2 /ii /ww] pushVariables
3320: [
3321: % $BCV49I=(B dhcone.h2dh $B$r:n$k(B.
3322: /dhcone.h2dh cone.fan length newVector.with-1 def
3323: 0 1 , dhcone.fan length 1 sub {
3324: /i set
3325: dhcone.fan i get , (cones) getNode 2 get /vv set
3326: 0 1 vv length 1 sub {
3327: /j set
3328: dhcone.h2dh , vv j get , i to_univNum , put
3329: } for
3330: } for
3331: % merge $B$7$?(B dhcone $B$r@0M}$7$?$b$N(B, dhcone2.fan $B$r:n$k(B.
3332: /dhcone2.fan dhcone.fan length newVector def
3333: 0 1 , dhcone.fan length 1 sub {
3334: /i set
3335: dhcone.fan i get (facets) getNode 2 get /facets set
3336: dhcone.fan i get (merged) getNode 2 get /merged set
3337: dhcone.fan i get (nextcid) getNode 2 get /nextcid set
3338: dhcone.fan i get (cones) getNode 2 get /cones set
3339: /facets2 [ ] def
3340: /nextcid2 [ ] def
3341: 0 1 , facets length 1 sub {
3342: /j set
3343: merged j get , (3).. eq {
3344: facets2 [ facets j get ] join /facets2 set
3345: % $B$H$J$j$N(B cone $B$,$"$k$H$-(B $BJQ49I=$K$7$?$,$$(B, cone $BHV9f$rJQ49(B
3346: nextcid2 [ dhcone.h2dh , nextcid j get , get ] join /nextcid2 set
3347: } { } ifelse
3348: merged j get , (2).. eq {
3349: facets2 [ facets j get ] join /facets2 set
3350: % $B6-3&$N$H$-(B -2 $B$rF~$l$k(B.
3351: nextcid2 [ (-2).. ] join /nextcid2 set
3352: } { } ifelse
3353: } for
3354:
3355: dhcone2.fan i ,
3356: [(dhcone) [ ]
3357: [
3358: [(facets) [ ] facets2] arrayToTree
3359: [(nextcid) [ ] nextcid2] arrayToTree
3360: [(cones) [ ] cones] arrayToTree
3361: ]
3362: ] arrayToTree , put
3363:
3364: } for
3365:
3366: % $B:G8e$K(B dhcone2.gblist $B$r:n$k(B.
3367: /dhcone2.gblist , dhcone2.fan length newVector , def
3368: 0 1 , dhcone2.fan length 1 sub {
3369: /i set
3370: dhcone2.fan i get (cones) getNode 2 get /cones set
3371: cone.grGblist , cones 0 get , get , /ii set % GB of initial (H->1).
3372: cone.gblist i get , (weight) getNode , [ 2 0 2 ] get /ww set
3373:
3374: dhcone2.gblist i,
3375: [(gbasis) [ ]
3376: [
3377: [(initial) [ ] ii] arrayToTree
3378: [(weight) [ ] ww] arrayToTree
3379: ]
3380: ] arrayToTree , put
3381:
3382: } for
3383: (dhcone2.fan, dhcone2.gblist, dhcone.h2dh are set.) message
3384:
3385: ] pop
3386: popVariables
3387: } def
3388:
3389: %<
3390: % $BI=$N8+J}$N2r@b$r0u:~$9$k4X?t(B.
3391: % Usages: dhcone.explain
3392: %>
3393: /dhcone.explain {
3394: [
3395: ( ) nl
3396: (Data format in << dhcone2.fan >>, which is a dehomogenized Grobner fan.) nl nl
3397: (<< cone.vlist >> is the list of the variables.) nl
3398: @@@.Hsymbol ( is the homogenization variable to be dehomogenized.) nl nl
3399: (<< cone.input >> is generators of a given ideal.) nl nl
3400: (<< cone.d >> is the dimension of parametrization space of the weights P_w) nl
3401: ( P_w is a cone in R^m where the number m is stored in << cone.m >>) nl
3402: ( P_w --- W ---> R^n [weight space]. ) nl
3403: ( W is stored in << cone.W >> ) nl
3404: ( << u cone.W mul >> gives the weight vector standing for u) nl nl
3405: (All cones in the data lie in the weight parametrization space P_w.) nl
3406: ( "facets" are the inner normal vector of the cone. ) nl
3407: ( "nextcid" is a list of the cone id's of the adjacent cones.) nl
3408: ( -2 in "nextcid" means that this facet lies on the border of the weight space.) nl
3409: ( "cones" is a list of the cone id's of the NON-dehomonized Grobner fan) nl
3410: ( stored in << cone.fan >>) nl
3411: ] cat
3412: } def
3413:
3414: %<
3415: % dhcone.printGrobnerFan
3416: % dhcone $B$N0u:~4X?t(B
3417: %>
3418: /dhcone.printGrobnerFan {
3419: [/i] pushVariables
3420: [
3421: (========== Grobner Fan (for dehomogenized cones) ============) message
3422: [
3423: (cone.comment)
3424: (cone.vlist) (cone.vv)
3425: (cone.input)
3426: (cone.type) (cone.local) (cone.h0)
3427: (cone.n) (cone.m) (cone.d)
3428: (cone.W) (cone.Wpos) (cone.Wt)
3429: (cone.L) (cone.Lp) (cone.Lpt)
3430: (cone.weightBorder)
3431: (cone.incidence)
3432: ] { printGrobnerFan.1 } map
3433: ( ) message
3434: (The number of cones = ) messagen dhcone.fan length message
3435: ( ) message
3436: 0 1 dhcone2.fan length 1 sub {
3437: /ii set
3438: ii messagen ( : ) messagen
3439: dhcone2.fan ii get printTree
3440: } for
3441: 1 {
3442: 0 1 dhcone2.gblist length 1 sub {
3443: /ii set
3444: ii messagen ( : ) messagen
3445: dhcone2.gblist ii get printTree
3446: } for
3447: } { } ifelse
3448:
3449:
3450: (=========================================) message
3451: %(cone.withGblist = ) messagen cone.withGblist message
3452: dhcone.explain message
3453: ( ) message
3454: ] pop
3455: popVariables
3456: } def
3457:
3458: %
3459: % $B;n$7J}(B test14, 22, 25
3460: %
3461: % (data/test14.sm1) run (data/test14-data.sm1) run
3462: % printGrobnerFan ; % H $BIU$-$G0u:~(B.
3463: % dhCones_h ; % dehomogenize Cones.
3464: % dhcone.rtable ; % dhcone2.fan $BEy$r@8@.(B.
3465: % dhcone.printGrobnerFan ; % $B0u:~(B.
3466: % $B0u:~$7$?$b$N$O(B test*-print.txt $B$X3JG<$7$F$"$k(B.
3467: %
3468:
3469: % Todo: save functions.
1.9 takayama 3470:
3471: %<
3472: % Collart, Kalkbrener, Mall $B$N%"%k%4%j%:%`$K$h$k(B gb $B$N(B flip.
3473: % See also Sturmfels' book, p.22, 23.
3474: % Usages: [reducedGb, vlist, oldWeight, facetWeight, newWeight] ckmFlip rGb
3475: % If it fails, then it returns null, else it returns the reducedGb for the
3476: % newWeight.
3477: % gb $B$N(B check $B$r$d$k$N$G(B, $B$=$l$K<:GT$7$?$i(B null $B$rLa$9(B.
3478: % 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
3479: % reducedGb $B$OJ8;zNs$N%j%9%H$G$O$J$/B?9`<0$N7A<0$N$3$H(B.
1.11 takayama 3480: % $BM}M3$O(B reducedGb $B$h$j(B ring $B$N9=B$$rFI$`$?$a(B.
1.9 takayama 3481: %>
3482: /ckmFlip {
3483: /arg1 set
3484: [/arg_ckmFlip /gOld /vlist /oldWeight /facetWeight /newWeight
3485: /gNew
3486: /ww /ww1 /ww2 % $BK\$NCf$N(B w1, w, w2 ($B8E$$(B, facet, $B?7$7$$(B)
3487: /ch1 /ch2 % $BK\$NCf$N(B {\cal H}_1, {\cal H}_2
3488: /grData /rTable
3489: /rTable2 % rTable $B$NH?BP$NJQ49(B.
3490: /facetWeight_gr /vlist_gr % graded ring $BMQ(B.
3491: /oldWeight_gr
3492: /ccf % reduction $B$7$?78?t(B.
3493: /rwork /ccf2 /gNew
3494: ] pushVariables
3495: [
3496: arg1 /arg_ckmFlip set
3497: arg_ckmFlip 0 get /gOld set
3498: arg_ckmFlip 1 get /vlist set
3499: arg_ckmFlip 2 get /oldWeight set
3500: arg_ckmFlip 3 get /facetWeight set
3501: arg_ckmFlip 4 get /newWeight set
3502:
3503: % facet weight vector ww $B$K$D$$$F$N(B initial $B$r<h$j=P$9(B. ch1 $B$X$$$l$k(B.
3504: gOld getRing ring_def
3505: facetWeight weightv /ww set
3506: gOld { ww init } map /ch1 set % facetWeight $B$K$h$k(B initial $B$N<h$j=P$7(B.
3507:
3508:
3509: % $BNc(B: [(x,y) [(x) -1 (Dx) 1 (y) -1 (Dy) 2]] getGrRing
3510: % [$x,y,y',$ , [ $x$ , $y$ ] , [ [ $Dy$ , $y'$ ] ] ]
3511: % $BJQ?t%j%9%H(B $BCV49I=(B
3512: % ch1 $B$r(B gr_ww $B$N85$KJQ49(B.
3513: [vlist facetWeight] getGrRing /grData set
3514: [grData 0 get ring_of_differential_operators 0] define_ring /rwork set
3515: grData 2 get { { . } map } map /rTable set
3516: rTable { reverse } map /rTable2 set
3517: grData 0 get /vlist_gr set
3518: ch1 { toString . rTable replace toString } map /ch1 set
3519:
3520: oldWeight { dup isString { . rTable replace toString }
3521: { } ifelse } map /oldWeight_gr set
3522:
3523: % facetWeight $B$b(B $B?7$7$$4D(B gr_ww $B$N(B weight $B$KJQ49(B.
3524: % $BNc(B. [(x) -1 (Dx) 1 (y) -1 (Dy) 2] ==> [(x) -1 (Dx) 1 (y) -1 (y') 2]
3525: facetWeight { dup isString { . rTable replace toString }
3526: { } ifelse } map /facetWeight_gr set
1.11 takayama 3527:
3528: % newWeight $B$b(B $B?7$7$$4D(B gr_ww $B$N(B weight $B$KJQ49(B.
3529: % $BNc(B. [(x) -1 (Dx) 1 (y) -1 (Dy) 2] ==> [(x) -1 (Dx) 1 (y) -1 (y') 2]
3530: newWeight { dup isString { . rTable replace toString }
3531: { } ifelse } map /newWeight_gr set
3532:
1.9 takayama 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.gb_gr $B$G6hJL$9$k$7$+$J$7(B
3535: %% [ch1 vlist_gr oldWeight_gr] /ttt set
3536: %% ttt cone.gb_gr /ch1 set %$B:FEY$N7W;;$OITMW(B.
3537: [[(1)] vlist_gr oldWeight_gr] cone.gb_gr getRing ring_def % Set Ring.
3538: ch1 {toString .} map /ch1 set
3539: %% $B$3$3$^$G$G$H$j$"$($:%F%9%H$r$7$h$&(B.
3540: %% ch1 /arg1 set
3541: [ch1 { toString } map vlist_gr newWeight_gr] cone.gb_gr /ch2 set
3542:
3543: % Dx x = x Dx + h H or Dx x = x Dx + h^2 $B$G7W;;(B.
3544: % $B$I$A$i$r$H$k$+$O(B cone.reduction_gr $B$G6hJL$9$k$7$+$J$7(B
3545: ch1 getRing ring_def ;
3546: ch2 {toString .} map {ch1 cone.reduction} map /ccf set
3547: %ccf pmat
3548: % $B$H$j$"$($:%F%9%H(B.
3549: % [ch1 ch2] /arg1 set
3550: %% ccf[i][0] $B$O(B 0 $B$G$J$$$HL7=b(B. check $B$^$@$7$F$J$$(B.
3551:
3552: %% ccf[i][2] (syzygy) $B$r(B gr $B$+$i(B $B$b$H$N(B ring $B$XLa$7(B,
3553: %% $B?7$7$$(B reduced gbasis $B$r(B ccf[i][2] * gOld $B$G:n$k(B.
3554: rwork ring_def
3555: ccf { 2 get {toString . rTable2 replace toString} map } map /ccf2 set
3556: %% ccf2 $B$O(B gr $B$G$J$$(B ring $B$N85(B.
3557: gOld getRing ring_def
1.10 takayama 3558: cone.DhH { cone.begin_DhH } { } ifelse % Hh $B$+(B h^2 $B$+(B.
1.9 takayama 3559: ccf2 { {.} map gOld mul } map /gNew set
3560: gNew { toString } map /gNew set
1.10 takayama 3561: cone.DhH { cone.end_DhH } { } ifelse % Hh $B$+(B h^2 $B$+(B.
1.9 takayama 3562: % gNew /arg1 set
3563: %gNew $B$,(B newWeight $B$G$N(B GB $B$+(B check. Yes $B$J$i(B reduced basis $B$X(B.
3564: %No $B$J$i(B null $B$rLa$9(B.
1.10 takayama 3565: %%Ref: note @s/2005/06/30-note-gfan.pdf
1.12 takayama 3566: cone.do_gbCheck not {
3567: (Warning! gbCheck is skipped.) message
3568: } {
3569: (Doing gbCheck.) message
3570: } ifelse
3571: cone.do_gbCheck {
3572: gNew [(gbCheck) 1] setAttributeList newWeight
3573: cone.gb (gb) getAttribute
3574: } { 1 } ifelse
1.9 takayama 3575: 1 eq {
3576: gNew [(reduceOnly) 1] setAttributeList newWeight cone.gb /arg1 set
3577: }{ /arg1 null def } ifelse
3578: ] pop
3579: popVariables
3580: arg1
3581: } def
3582:
3583: %<
3584: % Usages: f gbasis cone.reduction_DhH
1.10 takayama 3585: % dx x = x dx + h H $B$G$N(B reduction.
1.9 takayama 3586: %>
3587: /cone.reduction_DhH {
3588: /arg2 set /arg1 set
3589: [/ff /ggbasis /eenv /ans] pushVariables
3590: [
3591: /ff arg1 def /ggbasis arg2 def
1.10 takayama 3592: cone.begin_DhH
3593: ff ggbasis reduction /ans set
3594: cone.end_DhH
3595: /arg1 ans def
3596: ] pop
3597: popVariables
3598: arg1
3599: } def
3600:
3601: %<
3602: % Usages: f gbasis cone.reduction_Dh
3603: % dx x = x dx + h^2 $B$G$N(B reduction.
3604: %>
3605: /cone.reduction_Dh {
3606: /arg2 set /arg1 set
3607: [/ff /ggbasis /eenv /ans] pushVariables
3608: [
3609: /ff arg1 def /ggbasis arg2 def
1.9 takayama 3610: ff ggbasis reduction /ans set
3611: /arg1 ans def
3612: ] pop
3613: popVariables
3614: arg1
3615: } def
3616:
1.10 takayama 3617: %<
3618: % Usages: cone.begin_DhH dx x = x dx + h H $B$r3+;O(B.
3619: %>
1.9 takayama 3620: /cone.begin_DhH {
3621: [(Homogenize) (AutoReduce) (KanGBmessage)] pushEnv /cone.eenv set
3622: [(Homogenize) 3] system_variable
3623: } def
3624:
1.10 takayama 3625: %<
3626: % Usages: cone.begin_DhH dx x = x dx + h H $B$r=*N;(B.
3627: %>
1.9 takayama 3628: /cone.end_DhH {
3629: cone.eenv popEnv
3630: } def
3631:
1.10 takayama 3632: %<
3633: % Usages: ff vv ww cone.gb_gr_DhH dx x = x dx + h H $B$G7W;;(B.
3634: % dh.gb $B$O(B dhecart.sm1 $B$GDj5A$5$l$F$*$j(B, dx x = x dx + h H $B$G$N7W;;(B.
3635: % 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.
3636: % bug? cone.gb $B$G==J,(B?
3637: %>
3638: /cone.gb_gr_DhH {
3639: /arg1 set
3640: [/ff /ww /vv] pushVariables
3641: [
3642: /ff arg1 0 get def
3643: /vv arg1 1 get def
3644: /ww arg1 2 get def
3645: /dh.gb.verbose 1 def
3646: /dh.autoHomogenize 0 def
3647: [(AutoReduce) 1] system_variable
3648: [ff { toString } map vv
3649: [ww vv generateD1_1]] dh.gb 0 get /arg1 set
3650: ] pop
3651: popVariables
3652: arg1
3653: } def
3654: %<
3655: % Usages: ff vv ww cone.gb_gr_Dh dx x = x dx + h^2 $B$G7W;;(B.
3656: % gb $B$O(B dhecart.sm1 $B$GDj5A$5$l$F$*$j(B, dx x = x dx + h^2 $B$G$N7W;;(B.
3657: % 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.
3658: % bug? cone.gb $B$G==J,(B?
3659: %>
3660: /cone.gb_gr_Dh {
3661: /arg1 set
1.11 takayama 3662: [/ff /ww /vv /gg /envtmp] pushVariables
1.10 takayama 3663: [
3664: /ff arg1 0 get def
3665: /vv arg1 1 get def
3666: /ww arg1 2 get def
1.11 takayama 3667:
3668: [(AutoReduce) (KanGBmessage)] pushEnv /envtmp set
1.10 takayama 3669: [(AutoReduce) 1] system_variable
1.11 takayama 3670: [(KanGBmessage) 1] system_variable
3671: [vv ring_of_differential_operators
3672: [ww] weight_vector 0] define_ring
3673: [ff {toString .} map] ff getAttributeList setAttributeList
3674: groebner 0 get /gg set
3675: envtmp popEnv
3676:
3677: /arg1 gg def
1.10 takayama 3678: ] pop
3679: popVariables
3680: arg1
3681: } def
3682:
3683:
3684: % $B$3$l$i$O(B cone.ckmFlip 1 $B$N;~$7$+;H$o$:(B.
3685: /cone.reduction {
3686: cone.DhH {
3687: cone.reduction_DhH
3688: }{
3689: cone.reduction_Dh
3690: } ifelse
3691: } def
3692: /cone.gb_gr {
3693: cone.DhH {
3694: cone.gb_gr_DhH
3695: }{
3696: cone.gb_gr_Dh
3697: } ifelse
3698: } def
3699:
3700:
1.9 takayama 3701: /test1.ckmFlip {
3702: % cf. cone.sample2
3703: cone.load.cohom
3704: /cone.comment [
3705: (BS for y and y-(x-1)^2, t1, t2 space, in doubly homogenized Weyl algebra.) nl
3706: (The Grobner cones are dehomogenized to get local Grobner fan.) nl
3707: ] cat def
3708: /cone.vlist [(t1) (t2) (x) (y) (Dt1) (Dt2) (Dx) (Dy) (h) (H)] def
3709: /cone.vv (t1,t2,x,y) def
3710: /cone.type 1 def
3711: /cone.parametrizeWeightSpace {
3712: 4 2 parametrizeSmallFan
3713: } def
1.10 takayama 3714:
3715: /cone.DhH 1 def
3716: /cone.ckmFlip 1 def
3717:
1.9 takayama 3718: /cone.local 1 def
3719: /cone.w_start null def
3720: /cone.h0 1 def
3721: /cone.input
3722: [
3723: (t1-y) (t2 - (y-(x-1)^2))
3724: ((-2 x + 2)*Dt2+Dx)
3725: (Dt1+Dt2+Dy)
3726: ]
3727: def
3728: % homogenize
3729: [cone.vv ring_of_differential_operators
3730: [[(t1) -1 (t2) -1 (Dt1) 1 (Dt2) 1]] ecart.weight_vector
3731: 0] define_ring
3732: dh.begin
3733: cone.input { . homogenize toString } map /cone.input set
3734: dh.end
3735:
3736:
3737: % $B%F%9%H$r3+;O$9$k(B.
3738: % getStartingCone /cone.ncone set
3739: % cone.ncone updateFan
3740: % cone.gblist 0 get message
3741: % cone.ncone /cone.ccone set
3742: % getNextFlip /cone.nextflip set
3743: % cone.nextflip message
3744:
3745: /wOld [(t1) , -29 , (t2) , -38 , (Dt1) , 29 , (Dt2) , 38 ] def
3746: /wFacet [(t1) , -1 , (t2) , -1 , (Dt1) , 1 , (Dt2) , 1 ] def
3747: /wNew [(t1) , -39 , (t2) , -38 , (Dt1) , 39 , (Dt2) , 38 ] def
3748: cone.input wOld cone.gb /ff set
3749: [ff (t1,t2,x,y) wOld wFacet wNew] ckmFlip /ff2 set
3750: (See ff and ff2) message
3751:
1.11 takayama 3752: } def
3753:
3754: %<
3755: % Usages: cone i getaVectorOnFacet
3756: % cone $B$N(B i $BHVL\$N(B facet $B$N>e$N(B vector $B$r5a$a$k(B.
3757: % cf. liftWeight
3758: %>
3759: /getaVectorOnFacet {
3760: /arg2 set /arg1 set
3761: [/cone /facet_i /ep /vp /v /v /ii] pushVariables
3762: [
3763: /cone arg1 def /facet_i arg2 def
3764: facet_i to_int32 /facet_i set
3765:
3766: cone (facetsv) getNode 2 get facet_i get /v set
3767: /vp v 0 get def
3768: 1 1 v length 1 sub {
3769: /ii set
3770: vp v ii get add /vp set
3771: } for
3772: vp nnormalize_vec /vp set
3773: /arg1 vp def
3774: ] pop
3775: popVariables
3776: arg1
3777: } def
3778:
3779: /getNextCone {
3780: getNextCone_ckm
3781: } def
3782:
3783: %<
3784: % Usages: result_getNextFlip getNextCone_ckm ncone
3785: % flip $B$7$F?7$7$$(B ncone $B$rF@$k(B. Collar-Kalkbrener-Moll $B$N%"%k%4%j%:%`$r;H$&(B
3786: % if (cone.ckmFlip == 0) $BIaDL$N7W;;(B else CKM.
3787: %>
3788: /getNextCone_ckm {
3789: /arg1 set
3790: [/ncone /ccone /kk /w /next_weight_w_wv /cid /ttt] pushVariables
3791: [
3792: /ccone arg1 def
3793: /ncone null def
3794: /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.
3795: /cid ccone 2 get def % cid $B$O(B cone $B$N(B $BHV9f(B.
3796: ccone 0 get /ccone set
3797: {
3798: ccone tag 0 eq { exit } { } ifelse
3799:
3800: % ccone $B$N(B kk $BHVL\$N(B facet $B$K$D$$$F(B flip $B$9$k(B.
3801: ccone kk cone.epsilon flipWeight /w set
3802: (Trying new weight is ) messagen w message
3803: w liftWeight /next_weight_w_wv set
3804: (Trying new weight [w,wv] is ) messagen next_weight_w_wv message
3805:
3806: cone.ckmFlip {
3807: [
3808: cone.gblist cid get (grobnerBasis) getNode 2 get % reduce gb
3809: cone.vv
3810: cone.gblist cid get (weight) getNode [2 0 2] get % weight
3811: ccone kk getaVectorOnFacet liftWeight 1 get % weight on facet
3812: next_weight_w_wv 1 get % new weight
3813: ] /ttt set
3814: ttt message
3815: ttt ckmFlip /cone.cgb set
3816: }{
3817: cone.input next_weight_w_wv 1 get cone.gb /cone.cgb set
3818: } ifelse
3819:
3820: cone.cgb tag 0 eq not {
3821: [w] next_weight_w_wv join /cone.cgb_weight set
3822: next_weight_w_wv 1 get cone.cgb coneEq /cone.g_ineq set
3823: cone.g_ineq cone.w_ineq join cone.Wt mul cone.Lpt mul
3824: pruneZeroVector /cone.gw_ineq_projectedWtLpt set
3825:
3826: (cone.gw_ineq_projectedWtLpt is obtained.) message
3827:
3828: cone.gw_ineq_projectedWtLpt getConeInfo /cone.nextConeInfo set
3829: % $B<!85$rD4$Y$k(B. $B$@$a$J$i(B retry
3830: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
3831: cone.nextConeInfo 1 get newCone /ncone set
3832: ccone ncone getCommonFacet 0 get {
3833: (Flip succeeded.) message
3834: exit
3835: } { } ifelse
3836: } { } ifelse
3837: % common face $B$,$J$1$l$P(B $B$d$O$j(B epsilon $B$r>.$5$/(B.
3838: cone.nextConeInfo 0 get 0 get to_int32 cone.d eq {
3839: (ccone and ncone do not have a common facet.) message
3840: } {
3841: (ncone is not maximal dimensional. ) message
3842: } ifelse
3843: }{ } ifelse
3844:
3845: (Decreasing epsilon to ) messagen
3846: cone.epsilon (1).. (2).. div mul /cone.epsilon set
3847: cone.epsilon cone.epsilon.limit sub numerator (0).. lt {
3848: (Too small cone.epsilon ) error
3849: } { } ifelse
3850: cone.epsilon message
3851: } loop
3852: /arg1 ncone def
3853: ] pop
3854: popVariables
3855: arg1
1.9 takayama 3856: } def
1.13 takayama 3857:
3858: %%change
3859: /cone_ir_input {
3860: /arg1 set
3861: [/msg ] pushVariables
3862: [
3863: /msg arg1 def
3864: (---------------) message
3865: msg message
3866: ( ) message
3867: (Please also refer to the value of the variables cone.getConeInfo.rr0) message
3868: ( cone.getConeInfo.rr1 cone.Lp cone.cinit) message
3869: $ cone.cinit (FACETS) getNode :: $ message
3870: (We are sorry that we cannot accept this input.) error
3871: ] pop
3872: popVariables
3873: } def
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>