Annotation of OpenXM/src/kan96xx/Doc/oxasir.sm1, Revision 1.2
1.2 ! takayama 1: % $OpenXM$
1.1 maekawa 2: %% kxx/oxasir.sm1 1998, 2/12 (this version is at Old/oxasir.sm1.19980212
3: %% 3/1, 1995, 11/5, 11/21
4: %% This file is error clean.
5: %%%%%%% How to install.
6: %%% Set ASIR_LIBDIR if necessary. Ex. /u/nobuki/lib/asir
7: %%% write ~/.asirrc : load("gr")$ load("primdec")$ end$
8: %%% oxasir.asir must be in
9: %%% LOAD_SM1_PATH or oxasirpath.asirlib
10: %%% Edit below
11: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12: %%% /usr/local/lib/sm1, SM1_LOAD_PATH, /usr/local/lib/asir, ASIR_LOAD_PATH
13: /oxasirpath.oxasir (ox_asir) def %% loadmethod is 1
14: /oxasirpath.asirlib (oxasir.asir) def
15:
16: /ox_asirConnectMethod { asirconnectr /oxasir.ccc set } def
17: %/ox_asirConnectMethod { asirconnect2 } def
18:
19: %% Old path
20: %/oxasirpath.oxasir (/home/nobuki/kxx/ox_asir) def %% loadmethod is 1
21: %/oxasirpath.asirlib (/home/nobuki/kxx/oxasir.asir) def
22: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23: /oxasir.loadmethod 1 def %% "..." oxsendcmo (load) ox...
24: %/oxasir.loadmethod 0 def %% load("..."); %% at MSRI
25: %%%%%%%%%%%%%%%% end of configuration.
26: /initializePathNamesForOxAsir {
27: [oxasirpath.oxasir] getPathNameAsir /oxasirpath.oxasir set
28: [oxasirpath.asirlib] getPathNameSm1 /oxasirpath.asirlib set
29: } def
30:
31:
32: /oxasir.verbose 0 def
33: /oxasir.version (2.981105) def
34: oxasir.version [(Version)] system_variable gt
35: { [(This package requires the latest version of kan/sm1) nl
36: (Please get it from http://www.math.kobe-u.ac.jp/KAN) ] cat
37: error
38: } { } ifelse
39: (oxasir.sm1, --- open asir protocol module 3/1 1998, 6/5 1999) message-quiet
40: ( asirconnect, asir, fctr, primadec, (C) M.Noro, N.Takayama ) message-quiet
41:
42: /oxasir.ccc load isArray
43: { }
44: { /oxasir.ccc [ ] def } ifelse
45:
46: [(parse) (ox.sm1) pushfile] extension pop
47: oxasir.verbose {
48: (type in asirconnect to connect, asir is used to execute asir command. )
49: message
50: (type in asirconnect2 to open a new window for ox_asir, connect, asir is used to execute asir command [you need to edit asirconnect2 to tell the path to load ox_asir] )
51: message
52: } { } ifelse
53:
54: /loadAsirFile {
55: /arg1 set
56: [/in-loadAsirFile /peer /fname] pushVariables
57: [
58: /peer arg1 0 get def
59: /fname arg1 1 get def
60: oxasir.loadmethod {
61: peer fname oxsendcmo peer 1 oxsendcmo
62: peer (load) oxexec
63: }{
64: peer [$load("$ fname $");$] cat oxsubmit
65: }ifelse
66: ] pop
67: popVariables
68: } def
69: [(loadAsirFile)
70: [$[client fname] loadAsirFile (ox_asir function)$
71: $Load a file into the client$
72: ]] putUsages
73:
74: /asirinit {
75: %% gr and primdec are loaded by .asirrc
76: /asirinit.peer set
77: [asirinit.peer oxasirpath.asirlib] loadAsirFile
78: } def
79: /asirconnect {
80: [(localhost) 1300 1200] oxconnect /oxasir.ccc set
81: /ccc oxasir.ccc def %% for compatibility.
82: oxasir.ccc asirinit
83: } def
84: /asirconnect2 {
85: [oxpath.oxlog.xterm oxpath.ox ( -ox ) oxasirpath.oxasir
86: oxpath.null
1.2 ! takayama 87: ( & )] cat system-csh
! 88: % (xterm -e /home/nobuki/kxx/ox -ox /home/nobuki/kxx/ox_asir &) system-csh
! 89: % (kterm -iconic -e /home/nobuki/kxx/ox -ox /home/nobuki/kxx/ox_asir &) system-csh
1.1 maekawa 90: % For MSRI
91: % Eterm is also nice (including kanji). rxvt is also nice.
1.2 ! takayama 92: %(xterm -icon -e /u/nobuki/tmp/kxx/ox -ox /u/nobuki/tmp/Ox/ox_asir2 &) system-csh
! 93: %(kterm2 -e /u/nobuki/tmp/kxx/ox -ox /u/nobuki/tmp/Ox/ox_asir2 &) system-csh
1.1 maekawa 94: % (If you start the server automatically, you may have a trouble to) message
95: % (oxreset. In order to avoid this trouble, start the server by hand.) message
1.2 ! takayama 96: (sleep 5) system-csh
1.1 maekawa 97: [(localhost) 1300 1200] oxconnect /oxasir.ccc set
98: /ccc oxasir.ccc def %% for compatibility.
99: oxasir.ccc asirinit
100: } def
101:
102: [(asirconnect2)
103: [(asirconnect2 starts ox_asir server. (ox_asir function))
104: (Open xxx protocol is used for the communication between sm1 and ox_asir.)
105: (cf. oxhelp, asir.)
106: (You need to install ox_asir server to use this function. cf. oxasir)
107: ]] putUsages
108:
109: /asirconnect3 {
110: [oxpath.oxlog.xterm oxpath.ox ( -ox ) oxasirpath.oxasir
111: ( -data 2300 -control 2200) oxpath.null
1.2 ! takayama 112: ( & )] cat system-csh
1.1 maekawa 113: % (If you start the server automatically, you may have a trouble to) message
114: % (oxreset. In order to avoid this trouble, start the server by hand.) message
1.2 ! takayama 115: (sleep 5) system-csh
1.1 maekawa 116: [(localhost) 2300 2200] oxconnect /oxasir.ccc2 set
117: /ccc2 oxasir.ccc2 def %% for compatibility.
118: oxasir.ccc2 asirinit
119: (The client is stored in oxasir.ccc2.) message
120: } def
121:
122: [(asir)
123: [(pid [asir-command, asir-arg1, asir-arg2, ...] asir result (ox_asir function))
124: (Call open asir server. You need to install ox_asir on your system)
125: (to use this function. cf. primadec, fctr, asirconnect2, asirconnectr.)
126: (If you interrupted the computation by typing ctrl-C, type in )
127: ( oxasir.ccc oxreset ; )
128: (to interrupt the ox_asir server.)
129: (Example: oxasir.ccc [(fctr) (x^10-1).] asir )
130: ( )
131: (This function requires plugins cmo, socket and ox_asir server. cf. oxasir)
132: (See, ftp://endeavor.fujitsu.co.jp/pub/isis/asir on asir)
133: ]
134: ] putUsages
135:
136: /asir {
137: /arg2 set
138: /arg1 set
139: [/pid /asir-comm /comm /n /i /rr] pushVariables
140: [(CurrentRingp)] pushEnv
141: [
142: /pid arg1 def
143: /asir-comm arg2 def
144: pid tag 6 eq { } { (Invalid pid. See asir.) error } ifelse
145: pid 0 get (client) eq { } { (Invalid pid. See asir.) error } ifelse
146: asir-comm tag 6 eq { } { (Invalid argument asir-comm. See asir) error } ifelse
147:
148: [ %% Change the current ring if necessary to send a correct OxVlist.
149: asir-comm oxasir.changeRing
150: ] pop
151: %%% Setting OxVlist to tell asir a way to change dist-poly <==> poly.
152: (OxVlist=) getVlist2 toString (;) 3 cat_n /comm set
153: %% comm message
154: pid comm oxsubmit
155: pid (print(OxVlist);) oxsubmit
156:
157:
158: /n asir-comm length def
159: n 1 sub -1 1 {
160: /i set
161: pid asir-comm i get oxsendcmo
162: pid 1 oxsendcmo pid (ox_dtop) oxexec
163: } for
164: pid n 1 sub oxsendcmo
165: pid asir-comm 0 get oxexec
166:
167: pid 1 oxsendcmo pid (ox_ptod) oxexec
168: pid oxpopcmo /arg1 set
169:
170:
171: ] pop
172: popEnv
173: popVariables
174: arg1
175: } def
176:
177: /oxasir.changeRing {
178: /arg1 set
179: [/in-oxasir.changeRing /f /rr] pushVariables
180: [
181: /f arg1 def
182: f isArray {
183: f {oxasir.changeRing} map
184: }{
185: f isPolynomial {
186: f (0). eq { }
187: { f (ring) dc /rr set [(CurrentRingp) rr] system_variable } ifelse
188: } { } ifelse
189: } ifelse
190: ] pop
191: popVariables
192: } def
193:
194: /fctr {
195: /arg1 set
196: [/f /comm /vv] pushVariables
197: [(CurrentRingp)] pushEnv
198: [
199: /f arg1 def
200: oxasir.ccc [ ] eq {
201: (Starting ox_asir server.) message
202: ox_asirConnectMethod
203: } { } ifelse
204:
205: f isPolynomial not {
206: /vv f 1 get def
207: vv isArray { /vv vv from_records def } { } ifelse
208: /f f 0 get def
209: [vv ring_of_polynomials 0] define_ring
210: f . /f set
211: }{ } ifelse
212: oxasir.ccc [(fctr) f] asir /arg1 set
213: ] pop
214: popEnv
215: popVariables
216: arg1
217: } def
218:
219: [(fctr)
220: [(You need to install ox_asir server to use this function. (ox_asir function))
221: (f fctr g)
222: (poly f; array g;)
223: ([f v] fctr g ; string f, string or array of string v)
224: (This function factors the polynomial f over Q.)
225: ( )
226: (Example 1: [(x^10-y^10) (x,y)] fctr ::)
227: (Example 2: (x^10-1). fctr ::)
228: ( )
229: (If you interrupted the computation by typing ctrl-C, type in )
230: ( oxasir.ccc oxreset ; )
231: (to interrupt the ox_asir server.)
232: ( )
233: (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
234: ]] putUsages
235:
236:
237: [(primadec)
238: [(You need to install ox_asir server to use this function. (ox_asir function))
239: ([ ii ] primadec [[q1 p1] [q2 p2] ... ] )
240: ( array of poly ii; array of poly q1, p1, q2, p2 ...;)
241: ( q1, q2, ... are primary components of the primary ideal decomposition)
242: ( of the ideal generated by << ii >>.)
243: ( )
244: ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
245: ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
246: (<< v >> is an array of independent variables.)
247: ( )
248: ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
249: ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
250: ( v is a string of variables separated by , )
251: ( )
252: (Example: [(x,y) ring_of_polynomials 0] define_ring)
253: ( [ [(x^2-1). (x y).] ] primadec pmat ;)
254: ( )
255: (Example: [ [(x^2-1) (x y)] [(x) (y)]] primadec pmat ;)
256: ( )
257: (If you interrupted the computation by typing ctrl-C, type in )
258: ( oxasir.ccc oxreset ; )
259: (to interrupt the ox_asir server.)
260: ( )
261: (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
262: ]] putUsages
263:
264: /primadec {
265: /arg1 set
266: [/in-primadec /aa /f /comm /vvv /r /setarg] pushVariables
267: [(CurrentRingp)] pushEnv
268: [
269: /aa arg1 def
270: aa isArray { } { (<<array>> primadec) error } ifelse
271: /setarg 0 def
272: oxasir.ccc [ ] eq {
273: (Starting ox_asir server.) message
274: ox_asirConnectMethod
275: } { } ifelse
276: aa { tag } map /typev set
277: typev [ ArrayP ] eq
278: { /f aa 0 get def
279: f 0 get (ring) dc /r set
280: [(CurrentRingp) r] system_variable
281: /vvv getVariableNames def
282: /setarg 1 def
283: } { } ifelse
284: typev [ArrayP StringP] eq
285: { /f aa 0 get def
286: /vvv [ aa 1 get to_records pop ] def
287: /setarg 1 def
288: } { } ifelse
289: typev [ArrayP ArrayP] eq
290: { /f aa 0 get def
291: /vvv aa 1 get {toString} map def
292: /setarg 1 def
293: } { } ifelse
294: setarg { } { (primadec : Argument mismatch) error } ifelse
295:
296: f 0 get isPolynomial {
297: /r f 0 get (ring) dc def
298: /vvv vvv { r ,, } map def
299: }
300: {
301: [vvv from_records ring_of_polynomials 0] define_ring
302: f { toString . } map /f set
303: vvv { . } map /vvv set
304: } ifelse
305: oxasir.ccc [(primadec) f vvv] asir /arg1 set
306: ] pop
307: popEnv
308: popVariables
309: arg1
310: } def
311:
312:
313: /getVlist2 {
314: [/n /i ] pushVariables
315: [
316: /n [(N)] system_variable def
317: [
318: 0 1 n 1 sub { /i set (x) i (dollar) dc 2 cat_n } for
319: 0 1 n 1 sub { /i set (d) i (dollar) dc 2 cat_n } for
320: ] /arg1 set
321: ] pop
322: popVariables
323: arg1
324: } def
325:
326: %%%%%%%%%%%%%%%%%%%
327: /getVlist {
328: [/n /i ] pushVariables
329: [
330: /n [(N)] system_variable def
331: [
332: 0 1 n 1 sub { /i set [(x) (var) i] system_variable } for
333: 0 1 n 1 sub { /i set [(D) (var) i] system_variable } for
334: ] /arg1 set
335: ] pop
336: popVariables
337: arg1
338: } def
339:
340: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
341: [(chattr) 0 /findIntegralRoots] extension pop
342: oxasir.verbose {
343: (Overloaded on findIntegralRoots.) message
344: } { } ifelse
345: /findIntegralRoots {
346: /arg1 set
347: [/in-findIntegralRoots /pp ] pushVariables
348: [
349: /pp arg1 def
350: oxasir.ccc [ ] eq {
351: (Starting ox_asir server.) message
352: ox_asirConnectMethod
353: } { } ifelse
354: oxasir.ccc oxIsServerReady
355: { pp findIntegralRoots.oxasir /arg1 set}
356: { pp findIntegralRoots.slow /arg1 set} ifelse
357: ] pop
358: popVariables
359: arg1
360: } def
361:
362: /findIntegralRoots.oxasir {
363: /arg1 set
364: [/in-findIntegralRoots /f /r /g /aa /rlist] pushVariables
365: [(CurrentRingp) (KanGBmessage)] pushEnv
366: [
367: /f arg1 def
368: [(s) ring_of_polynomials 0] define_ring
369: f toString . /f set
370: f fctr rest /g set
371: g {
372: 0 get /aa set
373: aa (s). degree 1 eq {
374: aa (s). coeff 1 get /aa set
375: aa length 1 eq { 0 }
376: { aa 0 get (1). eq {
377: 0 << aa 1 get (integer) dc >> sub
378: } { } ifelse
379: } ifelse
380: }{ } ifelse
381: } map
382: /rlist set
383: %% rlist ::
384: [-1000000] rlist join shell rest /arg1 set
385: ] pop
386: popEnv
387: popVariables
388: arg1
389: } def
390:
391:
392: %%%%%%%%%%%%%%%%%%%%%%%%%%
393:
394: /asirconnectr {
395: [/in-asirconnectr /pass /peer /data /control /oxasir] pushVariables
396: [
397: /pass [(oxGenPass)] extension def
398: /peer [(oxGetPort) (localhost)] extension def
399: /data peer 1 get toString def
400: /control peer 3 get toString def
401: peer message
402: [oxpath.oxlog.xterm oxpath.ox ( -reverse -ox ) oxasirpath.oxasir
403: ( -data ) data ( -control ) control ( -pass ) pass
404: oxpath.null
1.2 ! takayama 405: ( &)] cat system-csh
1.1 maekawa 406: [(oxCreateClient2) peer 0 pass] extension /oxasir set
407: %% 0 means connect from only localhost.
408: oxasir asirinit
409: /arg1 oxasir def
410: ] pop
411: popVariables
412: arg1
413: } def
414: [(asirconnectr)
415: [(asirconnectr server (ox_asir function))
416: (array server;)
417: (Example: asirconnectr /oxasir.ccc set)
418: ]] putUsages
419:
420:
421: %%%%%%%%%%%%% From gbhg3/Int/intw.sm1
422: %% This function needs solv1.asir and ox_asir.
423: %% See solv1.asir for the usage of this function.
424: /rationalRoots2 {
425: /arg1 set
426: [/in-rationalRoots2 /aa /f /comm /vvv /r /setarg
427: /w /ans
428: ] pushVariables
429: [(CurrentRingp) (KanGBmessage)] pushEnv
430: [
431: /aa arg1 def
432: aa isArray { } { (<<array>> rationalRoots2) error } ifelse
433: /setarg 0 def
434: oxasir.ccc [ ] eq {
435: (Starting ox_asir server.) message
436: ox_asirConnectMethod
437: } { } ifelse
438: aa { tag } map /typev set
439: typev [ArrayP StringP ArrayP] eq
440: { /f aa 0 get def
441: /vvv [ aa 1 get to_records pop ] def
442: /w aa 2 get def
443: /setarg 1 def
444: } { } ifelse
445: typev [ArrayP ArrayP ArrayP] eq
446: { /f aa 0 get def
447: /vvv aa 1 get {toString} map def
448: /setarg 1 def
449: /w aa 2 get def
450: } { } ifelse
451: setarg { } { (rationalRoots2 : Argument mismatch) error } ifelse
452:
453:
454: [vvv from_records ring_of_polynomials 0] define_ring
455: f { toString . } map /f set
456: vvv { . } map /vvv set
457: w { toString . } map /w set
458:
459: (rationalRoots2 -- f = ) messagen f messagen
460: ( , vvv= ) messagen vvv messagen ( , w = ) messagen w message
461:
462: vvv length 1 eq w 0 get (1). eq and
463: {
464: [(KanGBmessage) 0] system_variable
465: [f] groebner_sugar 0 get /f set
466: vvv 0 get toString (s) eq {
467: }{ [[vvv 0 get toString (s)] from_records ring_of_polynomials 0] define_ring}
468: ifelse
469: f 0 get toString . [[vvv 0 get toString . (s).]] replace
470: findIntegralRoots /ans set
471: }
472: {
473: oxasir.ccc [(sm1_rationalRoots2) f vvv w] asir
474: {(integer) dc} map
475: /ans set
476: } ifelse
477:
478: /arg1 ans def
479: ] pop
480: popEnv
481: popVariables
482: arg1
483: } def
484: [(rationalRoots2)
485: [(rationalRoots2 (ox_asir function) called from intw.sm1 to analyze integral)
486: (roots.)
487: ]] putUsages
488:
489: /ptozp_subst {
490: /arg1 set
491: [/in-ptozp_subst /aaa /fff /xxx /vvv /vlist] pushVariables
492: [(CurrentRingp)] pushEnv
493: [
494: /aaa arg1 def
495: /fff aaa 0 get def
496: /xxx aaa 1 get toString def
497: /vvv aaa 2 get {toString ..} map def
498: aaa length 4 eq {
499: /vlist aaa 3 get def
500: } {
501: /vlist 0 def
502: } ifelse
503: oxasir.ccc [ ] eq {
504: (Starting ox_asir server.) message
505: ox_asirConnectMethod
506: } { } ifelse
507: fff isPolynomial {
508: fff (ring) dc ring_def
509: fff toString /fff set
510: }
511: { vlist isInteger { (ptozp_subst: need variable names.) error } { } ifelse
512: [vlist ring_of_differential_operators 0] define_ring
513: } ifelse
514: oxasir.ccc [(sm1_ptozp_subst) fff . xxx . vvv] asir
515: /arg1 set
516: ] pop
517: popEnv
518: popVariables
519: arg1
520: } def
521:
522: [(ptozp_subst)
523: [$[f s [p q] v] ptozp_subst g (ox_asir function)$
524: $It returns ptozp(subst(f,s,p/q))$
525: $Example 1: [ (x Dx - s) (s) [2 3] (x,s)] ptozp_subst $
526: $ ===> 3 x Dx - 2 $
527: ]] putUsages
528:
529: /reduceByAsir {
530: /arg1 set
531: [/in-reduceByAsir /aaa /fff /fff0 /fff1 /vlist] pushVariables
532: [(CurrentRingp)] pushEnv
533: [
534: /aaa arg1 def
535: /fff aaa 0 get def
536: aaa length 2 eq {
537: /vlist aaa 1 get def
538: } {
539: /vlist 0 def
540: } ifelse
541: oxasir.ccc [ ] eq {
542: (Starting ox_asir server.) message
543: ox_asirConnectMethod
544: } { } ifelse
545: fff isArray {
546: fff length 2 eq {
547: /fff0 fff 0 get def
548: /fff1 fff 1 get def
549: } {
550: ([ << [f g] >> vlist ] reduceByAsir ) error
551: } ifelse
552: } {
553: ([ << [f g] >> vlist ] reduceByAsir ) error
554: } ifelse
555: fff0 isPolynomial fff1 isPolynomial and {
556: fff0 (ring) dc ring_def
557: fff0 toString . /fff0 set
558: fff1 (ring) dc ring_def
559: fff1 toString . /fff1 set
560: }
561: { vlist isInteger { (reduceByAsir: need variable names.) error } { } ifelse
562: [vlist ring_of_differential_operators 0] define_ring
563: fff0 toString . /fff0 set
564: fff1 toString . /fff1 set
565: } ifelse
566: oxasir.ccc [(sm1_rat2plist2) [fff0 fff1]] asir
567: /arg1 set
568: ] pop
569: popEnv
570: popVariables
571: arg1
572: } def
573:
574: [(reduceByAsir)
575: [$ [[f g] v] reduceByAsir [ff gg] (ox_asir function)$
576: $ [[f g]] reduceByAsir [ff gg] $
577: $Example 1: [[(2 x -2) (4 x - 8)] (x)] reduceByAsir $
578: (Note that there may be a gcd that is more than 1 among the coefficients.)
579: ]] putUsages
580:
581: /oxasir.sm1.loaded 1 def
582: initializePathNamesForOxAsir %% This should be the last.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>