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

Annotation of OpenXM/src/kan96xx/Doc/ox.sm1, Revision 1.26

1.26    ! takayama    1: %%%%%%%%%%%  $OpenXM: OpenXM/src/kan96xx/Doc/ox.sm1,v 1.25 2003/07/21 13:36:40 takayama Exp $
1.18      takayama    2:
1.23      takayama    3: /ox.sm1.myname (ox-new.sm1) def
1.1       maekawa     4:
1.23      takayama    5: [(ostype)] extension 0 get (unix) eq {
                      6:   /oxstart100
                      7:     [[(getenv) (OpenXM_HOME)] extension (/bin/ox100start )] cat
                      8:   def
                      9: } {
                     10:   /oxstart100
                     11:    [[(getenv) (OpenXM_HOME)] extension
                     12:     (/bin/ox100start.exe )] cat
                     13:   def
                     14: } ifelse
                     15: [(getenv) (OXSTART100)] extension tag 0 eq not {
                     16:   /oxstart100 [(getenv) (OXSTART100)] extension def
                     17: } {  } ifelse
                     18: oxstart100  message
1.1       maekawa    19:
1.23      takayama   20: /ox.sm1.loaded 1 def
                     21: /oxasir.sm1.loaded 1 def
                     22: /ox.k0.loaded 1 def
                     23: /Ox103_loaded 1 def
1.1       maekawa    24:
                     25: /ox.verbose 0   def
1.23      takayama   26: /ox.version (3.030000) def
1.1       maekawa    27: ox.version [(Version)] system_variable gt
                     28: { (This package requires the latest version of kan/sm1) message
                     29:   (Please get it from http://www.math.kobe-u.ac.jp/KAN) message
                     30:   error
                     31: } { } ifelse
1.23      takayama   32: (ox.sm1, ---OpenXM protocol module 07/20, 2003  (C) N.Takayama.) message-quiet
                     33: (           for ox_sm1, ox_asir, ox_k0 ) message-quiet
1.1       maekawa    34:
                     35: /ox.ccc load isArray
                     36: { }
                     37: { /ox.ccc [ ] def } ifelse
1.23      takayama   38: /oxsm1.ccc load isArray
                     39: { }
                     40: { /oxsm1.ccc [ ] def } ifelse
                     41: /ox.takelog 0 def
1.1       maekawa    42:
1.23      takayama   43: (@@@.Xm_noX) boundp {
                     44: }{
                     45:   /@@@.Xm_noX 0 def
                     46: } ifelse
                     47: (Xm_noX) boundp {
                     48:   /@@@.Xm_noX Xm_noX def
                     49: }{  } ifelse
                     50: /Xm_noX @@@.Xm_noX def
1.1       maekawa    51:
1.23      takayama   52: /oxNoX {
                     53:    /Xm_noX 1 def
                     54: } def
1.1       maekawa    55:
                     56:
1.23      takayama   57: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                     58: %%%   basic functions for OX-RFC 100
                     59: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.1       maekawa    60: /SM_executeStringByLocalParser 268 def
                     61: /SM_execute 268 def
                     62: /SM_popString  263  def
                     63: /SM_mathcap 264 def
                     64:
                     65: /SM_popCMO 262 def
                     66: /SM_executeFunction 269 def
1.11      takayama   67: /SM_DUMMY_sendcmo   2147418112 1 add def    %%% SM_PRIVATE+1
1.1       maekawa    68: /SM_sync_ball 281 def
                     69:
                     70: /SM_pops  265  def
                     71: /SM_setName 266  def
                     72: /SM_evalName 267  def
                     73:
                     74: /SM_setMathCap 273 def
                     75:
                     76: /SM_getsp     275  def
                     77: /SM_dupErrors 276  def
                     78:
                     79: /SM_control_kill 1024 def
                     80: /SM_control_reset_connection  1030 def
1.15      takayama   81: /SM_control_spawn_server  1027 def
1.1       maekawa    82:
                     83: /Etag_error 257 def
                     84:
                     85: [(ox)
                     86:  [
                     87:   (client aa oxpushcmo (oxsendcmo), client oxpopcmo dd, client popstring dd, client ss oxrpc)
1.23      takayama   88:  (Example: oxsm1.ccc [1 2 3] oxpushcmo oxsm1.ccc oxpopcmo /ff set  ff :: )
1.1       maekawa    89:  (  )
                     90:  (client ss oxexecutestring(oxsubmit) <<executeString>>, client ss oxexec <<executeFunction>>)
                     91:
1.23      takayama   92:  (Example: oxsm1.ccc (0 1 10 { pop $Hello$ message } for) oxexecutestring )
                     93:  (Example: oxsm1.ccc (2).. oxpushcmo oxsm1.ccc (10).. oxpushcmo )
                     94:  (         oxsm1.ccc (power) oxexec  oxsm1.ccc oxpopcmo :: )
1.1       maekawa    95:  (  )
                     96:  (client str oxevalname, client str oxsetname, client num oxpops, client oxget)
                     97:  (   )
                     98:  (client oxmathcap, client oxsetmathcap, oxgenportfile, oxremoveportfile)
                     99:  (   )
                    100:  (client oxgetsp --- get stack pointer,  client oxgeterrors --- get all errors)
                    101:  (cleint oxisData, client oxreset, client oxshutdown)
                    102:  (oxhelp for this message, [(oxWatch) client] extension to start a log.)
                    103:  ([(oxSerial)] extension serial-number-of-out-going-ox-packet.)
1.23      takayama  104:  (oxpopcmo1, oxpopcmo2, sm1connectr ox_launch, ox_launch_nox)
1.1       maekawa   105:  (oxNoX : set an environment to invoke oxlog without xterm and to call oxlog with >& /dev/null)
                    106:  $        ex 1.  (ox.sm1) run oxNoX sm1connectr $
1.23      takayama  107:  $        ex 2.  (ox.sm1) run oxNoX (x^2-1). fctr pmat ; $
1.1       maekawa   108:  ]
                    109: ] putUsages
                    110:
1.23      takayama  111: /oxconnect {
                    112:   /arg1 set
                    113:   [(oxCreateClient) arg1 aload pop] extension
1.1       maekawa   114: } def
                    115:
                    116: ox.verbose { oxhelp } {  } ifelse
                    117:
                    118: /oxpushcmo { oxsendcmo } def
                    119: /oxsendcmo {
                    120:   /arg1 set
                    121:   /arg2 set
                    122:   ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    123:   } {  } ifelse
                    124:   [(oxReq) arg2 SM_DUMMY_sendcmo arg1] extension pop
                    125: } def
                    126:
                    127: /oxpopcmo {
                    128:   /arg1 set
                    129:   [(oxReq) arg1 SM_popCMO ] extension pop
                    130:   [(oxGet) arg1] extension
                    131: } def
                    132:
                    133: /oxgetsp {
                    134:   /arg1 set
                    135:   [(oxReq) arg1 SM_getsp ] extension pop
                    136:   [(oxReq) arg1 SM_popCMO ] extension pop
                    137:   [(oxGet) arg1] extension
                    138: } def
                    139:
                    140: /oxgeterrors {
                    141:   /arg1 set
                    142:   [(oxReq) arg1 SM_dupErrors ] extension pop
                    143:   [(oxReq) arg1 SM_popCMO ] extension pop
                    144:   [(oxGet) arg1] extension
                    145: } def
                    146:
                    147: /oxmathcap0 {
                    148:   /arg1 set
                    149:   [(oxReq) arg1 SM_mathcap ] extension pop
                    150: } def
                    151: /oxmathcap {
                    152:   /arg1 set
                    153:   [/in-oxmathcap /mypeer /mmm] pushVariables
                    154:   [ /mypeer arg1 def
                    155:     mypeer oxmathcap0
                    156:     mypeer oxpopcmo /mmm set
                    157:     mypeer 10 mmm put  %% set math cap.
                    158:   ] pop
                    159:   popVariables
                    160: } def
                    161: /oxsetmathcap {
                    162:   /arg1 set
                    163:   [/in-oxsetmathcap /mypeer /mymathcap] pushVariables
                    164:   [
                    165:     /mypeer arg1 def
                    166:     /mymathcap     [(cmoMathCap)] extension (array) dc def
                    167:     [(oxReq)
                    168:       mypeer   SM_setMathCap
                    169:       mymathcap
                    170:     ] extension pop
                    171:   ] pop
                    172:   popVariables
                    173: } def
1.23      takayama  174:
1.1       maekawa   175: /oxpopcmo1 {  %% ask of the transmission.
                    176:   /arg1 set
                    177:   [(oxReq) arg1 SM_popCMO ] extension pop
                    178: } def
                    179: /oxpopcmo2 {  %% wait the data.
                    180:   /arg1 set
                    181:   [(oxGet) arg1] extension
                    182: } def
                    183:
                    184:
                    185: /oxpopstring {
                    186:   /arg1 set
                    187:   [(oxReq) arg1 SM_popString ] extension pop
                    188:   [(oxGet) arg1] extension
                    189: } def
                    190:
                    191: /oxrpc {
                    192:   /arg1 set
                    193:   /arg2 set
                    194:   [/ans /ff] pushVariables
                    195:   [
                    196:    /ff arg2 def
                    197:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    198:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
                    199:    } {  } ifelse
                    200:    [(oxReq) ff SM_execute arg1] extension pop
                    201:    [(oxReq) ff SM_popCMO] extension pop
                    202:    [(oxGet) ff] extension /ans set
                    203:    ans etag Etag_error  eq {
                    204:      (Got an error object.) message
                    205:      /arg1 ans def
                    206:    }
                    207:    {  /arg1 ans def
                    208:     } ifelse
                    209:   ] pop
                    210:   popVariables
                    211:   arg1
                    212: } def
                    213:
                    214: /oxexecutestring { oxsubmit } def
                    215: /oxsubmit {
                    216:   /arg1 set
                    217:   /arg2 set
                    218:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    219:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
                    220:    } {  } ifelse
                    221:   [(oxReq) arg2 SM_execute arg1] extension pop
                    222: } def
                    223:
                    224: /oxexec {
                    225:   /arg1 set
                    226:   /arg2 set
                    227:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    228:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeFunction) put
                    229:    } {  } ifelse
                    230:   [(oxReq) arg2 SM_executeFunction arg1] extension pop
                    231: } def
                    232: /oxsubmit2 {
                    233:   oxexec
                    234: } def
                    235:
                    236: /oxpops {
                    237:   /arg1 set
                    238:   /arg2 set
                    239:   [(oxReq) arg2 SM_pops arg1] extension pop
                    240: } def
                    241:
                    242: /oxsetname {
                    243:   /arg1 set
                    244:   /arg2 set
                    245:   [(oxReq) arg2 SM_setName arg1] extension pop
                    246: } def
                    247:
                    248: /oxevalname {
                    249:   /arg1 set
                    250:   /arg2 set
                    251:   [(oxReq) arg2 SM_evalName arg1] extension pop
                    252: } def
                    253:
                    254:
                    255: /oxreset {
                    256:   /arg1 set
                    257:   [(oxReq) arg1 SM_control_reset_connection] extension pop
1.13      takayama  258: %%  [(oxGetFromControl) arg1 ] extension pop
1.1       maekawa   259:   [(oxGet) arg1] extension message
                    260: } def
                    261:
                    262: /oxisData {
                    263:   /arg1 set
                    264:   [/pp /ff] pushVariables
                    265:   [
                    266:     /ff arg1 def
                    267:     [(oxMultiSelect) [ff] 10] extension /pp set
                    268:     pp message
                    269:     pp 0 get 1 eq {
                    270:       pp 1 get 0 get 1 eq {  %% data is in the data stream.
                    271:         /arg1 [(oxGet) ff] extension def
                    272:       } {/arg1 (no data) def  } ifelse
                    273:     }
                    274:     { /arg1 (no data) def }
                    275:     ifelse
                    276:   ] pop
                    277:   popVariables
                    278:   arg1
                    279: } def
                    280:
                    281: /oxget {
                    282:   oxisData
                    283: } def
                    284:
                    285:
                    286: /oxshutdown {
                    287:   /arg1 set
                    288:   [(fp2fclose) arg1 1 get] extension
                    289:   [(oxReq) arg1 SM_control_kill] extension
                    290:   arg1 0 (closed) put
                    291: } def
                    292:
                    293: /oxgenportfile {
                    294:   [(oxGenPortFile)] extension
                    295: }def
                    296: /oxremoveportfile {
                    297:   [(oxRemovePortFile)] extension
                    298: }def
                    299:
                    300: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.4       takayama  301: /ox_launch_nox {
                    302:   /@@@.ox_launch_nox  1 def
                    303:   ox_launch_aux
                    304: } def
                    305: /ox_launch {
                    306:   /@@@.ox_launch_nox  0 def
                    307:   ox_launch_aux
                    308: } def
                    309:
                    310: /ox_launch_aux {
                    311:  /arg1 set
                    312:  [/in-launch_nox /pass /peer /data /control /name /machine
                    313:   /your-peer /comm /remoteOpenXMbin /remoteServer /myhost
1.10      takayama  314:   /argNumber /aaa
1.4       takayama  315:  ] pushVariables
                    316:  [
1.10      takayama  317:    /aaa arg1 def
                    318:    /argNumber aaa length def
                    319:    /machine aaa 0 get def
                    320:    machine (localhost) eq argNumber 5 lt and {
                    321:      aaa 1 get ox_launch_localhost /your-peer set
                    322:      /LLL.end goto
                    323:    } {
                    324:      /remoteOpenXMbin aaa 1 get def
                    325:      /remoteServer aaa 2 get def
                    326:      /name aaa 3 get def
                    327:      /myhost aaa 4 get def
                    328:    } ifelse
1.4       takayama  329:
                    330:    /pass [(oxGenPass)] extension def
                    331:    /peer [(oxGetPort) myhost] extension def
                    332:    /data peer 1 get toString def
                    333:    /control peer 3 get toString def
                    334:    peer message
                    335:  [(ssh -f ) machine ( -l ) name ( ")
                    336:
                    337:    @@@.ox_launch_nox {
                    338:    } {
                    339:      remoteOpenXMbin(/oxlog )
                    340:      ( /usr/X11R6/bin/xterm -icon -e )
                    341:    } ifelse
                    342:
                    343:   ( ) remoteOpenXMbin (/ox )
                    344:   ( -reverse -ox ) remoteServer
                    345:   ( -host ) myhost
                    346:   ( -data ) data ( -control ) control  ( -pass ) pass
                    347:   oxpath.null
                    348:   ( ")
                    349:  ] cat /comm set
                    350:  (Executing the command : ) messagen comm message message
                    351:   comm system
1.5       takayama  352:  (sleep 5) system-csh
1.4       takayama  353:  [(oxCreateClient2) peer 1 pass] extension /your-peer set
1.10      takayama  354:  /LLL.end
1.4       takayama  355:  /arg1 your-peer def
                    356:  ] pop
                    357:  popVariables
                    358:  arg1
                    359: } def
                    360:
                    361: [(ox_launch)
                    362: [( [remote remote-OpenXM-bin remote-ox-server remote-login-name myhostname] )
                    363:  (  ox_launch  client )
1.10      takayama  364:  $or $
                    365:  $ [(localhost) ox-server-name] ox_launch client$
1.4       takayama  366:  (Example 1: )
                    367:  $ [(tau.math.kobe-u.ac.jp) (/home/taka/OpenXM/bin) $
                    368:  $  (/home/taka/OpenXM/src/ox_math/ox_math) (taka) (dc4.math.kobe-u.ac.jp) $
                    369:  $ ] ox_launch /@@@.oxmath set $
                    370: ]] putUsages
                    371:
                    372: [(ox_launch_nox)
                    373: [( [remote remote-OpenXM-bin remote-ox-server remote-login-name myhostname] )
                    374:  (  ox_launch_nox  client )
                    375:  (Example 1: )
                    376:  $ [(tau.math.kobe-u.ac.jp) (/home/taka/OpenXM/bin) $
                    377:  $  (/home/taka/OpenXM/src/ox_math/ox_math) (taka) (dc4.math.kobe-u.ac.jp) $
                    378:  $ ] ox_launch_nox /@@@.oxmath set $
                    379: ]] putUsages
                    380:
1.10      takayama  381: /ox_launch_localhost {
                    382:  /arg1 set
                    383:  [/in-ox_launch_localhost /pass /peer /data /control /oxserver
                    384:   /my-peer] pushVariables
                    385:  [
                    386:     /oxserver arg1 def
                    387:     /pass [(oxGenPass)] extension def
                    388:     /peer [(oxGetPort) (localhost)] extension def
                    389:     /data peer 1 get toString def
                    390:     /control peer 3 get toString def
                    391:     peer message
                    392:     [oxpath.oxlog.xterm  oxpath.ox ( -reverse -ox ) oxserver
                    393:      ( -data ) data ( -control ) control  ( -pass ) pass
                    394:       oxpath.null
                    395:      ( &)] cat system-csh
                    396:     [(oxCreateClient2) peer 0 pass] extension /my-peer set
                    397:                          %% 0 means connect from only localhost.
                    398:     /arg1 my-peer def
                    399:  ] pop
                    400:  popVariables
                    401:  arg1
1.5       takayama  402: } def
1.1       maekawa   403:
1.23      takayama  404: /oxrpc2 {
                    405:   /arg2 set
                    406:   /arg1 set
                    407:  [/in-oxrpc2 /pid /n /comm /i] pushVariables
1.12      takayama  408:  [
1.23      takayama  409:    /pid arg1 def
                    410:    /comm arg2 def
                    411:    /n comm length def
                    412:    n 1 sub -1 1 {
                    413:        /i set
                    414:        pid comm i get oxsendcmo
                    415:    } for
                    416:    pid n 1 sub oxsendcmo
                    417:    pid comm 0 get oxexec
                    418:  ] pop
                    419:  popVariables
                    420: } def
                    421:
                    422: [(oxrpc2)
                    423:   [(Remote procedure call by using oxexec)
                    424:    (client [function-name  arg1 arg2 ...] oxrpc2 )
                    425:    (cf. ox-cmo-rpc in Risa/Asir)
                    426:    (Example: )
                    427:    $ (oxasir.sm1) run (x^2-1). fctr $
                    428:    (oxasir.ccc [(igcd) (6).. (10)..] oxrpc2)
                    429:    (oxasir.ccc oxpopcmo :: )
                    430:   ]
                    431: ] putUsages
                    432:
                    433: /oxIsServerReady {
                    434:   /arg1 set
                    435:   [/in-isServerReady /sdata /ans] pushVariables
                    436:   [
                    437:     /sdata arg1 def
                    438:     /ans 0 def
                    439:     sdata isArray {
                    440:      sdata length 1 gt {
                    441:        sdata 0 get (client) eq { /ans 1 def } { } ifelse
                    442:      } { } ifelse
                    443:     } { } ifelse
                    444:     /arg1 ans def
                    445:   ] pop
                    446:   popVariables
                    447:   arg1
                    448: } def
                    449:
                    450: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    451: %%%  Functions to start server by OX-RFC-101
                    452: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    453: /sm1StartControl101 {
                    454:  [/in-sm1connectr /pass /peer /data /control ] pushVariables
                    455:  [
                    456:  /pass [(oxGenPass)] extension def
                    457:  /peer [(oxGetPort1) (localhost)] extension def
                    458:  /data peer 1 get toString def
                    459:  peer message
                    460:  [(/home/nobuki/OpenXM/src/oxc/oxc)
                    461:   ( -c ) pass ( -h ) (localhost) ( -p ) data ( -x )
                    462:   oxpath.null
                    463:   ( &)] cat system-csh
                    464:
                    465:  [(oxCreateControl_RFC_101) peer 0 pass] extension /oxsm1.ccc set
                    466:                      %% 0 means connect from only localhost.
                    467:  /ox.ccc oxsm1.ccc def
                    468:  (The server is binded to the variable oxsm1.ccc) message
                    469:   oxsm1.ccc
1.12      takayama  470:  ] pop
                    471:  popVariables
1.14      takayama  472: } def
                    473:
                    474: /sm1StartEngine101 {
1.15      takayama  475:  [/in-sm1StartEngine101 /peer /data /control /engineID] pushVariables
1.14      takayama  476:  [
                    477:     /peer [(oxGetPort1) (localhost)] extension def
                    478:     /data peer 1 get def
1.15      takayama  479:
1.23      takayama  480:     oxsm1.ccc data oxpushcmo
                    481:     oxsm1.ccc (/home/nobuki/OpenXM/bin/ox_sm1) oxpushcmo
                    482:     [(oxPushCMD) oxsm1.ccc SM_control_spawn_server] extension
                    483:     oxsm1.ccc oxpopcmo /engineID set
1.15      takayama  484:     [(oxCreateEngine_RFC_101) peer 0 (Empty) engineID] extension
                    485:     /ox.ddd set
                    486:     (The engine is binded to the variables ox.ddd) message
1.14      takayama  487:  ] pop
                    488:  popVariables
                    489:  arg1
1.12      takayama  490: } def
1.16      takayama  491:
1.23      takayama  492: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    493: %%% Functions for OX-RFC 103
                    494: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.24      takayama  495: [(chattr) 0 /ctrlC-hook] extension
1.23      takayama  496: /ctrlC-hook {
                    497:   ox103_reset
                    498: } def
                    499: /ox103_disable {
1.24      takayama  500:   [(chattr) 0 /ctrlC-hook] extension
1.23      takayama  501:   /ctrlC-hook {  } def
                    502: } def
                    503:
                    504: [(ox103_reset)
                    505:  [(ox103_reset broadcasts the OX reset to all processes)
                    506:   (cf. ctrlC-hook, register_hander)
                    507: ]] putUsages
                    508: /ox103_reset {
                    509:   [/in-ox103_reset /L /n /i] pushVariables
                    510:   [
                    511:      /L [(oxGetClientList)] extension def
                    512:     (In ox103_reset...) message
                    513:      /n L length def
                    514:      0 1 n 1 sub {
                    515:        /i set
                    516:        L i get oxreset
                    517:      } for
                    518:      (Done) message
                    519:   ] pop
                    520:   popVariables
                    521: } def
                    522:
                    523: %%%%%%%
                    524: /ox103_asir_init {
                    525:   /arg1 set
                    526:   [/ttt] pushVariables
                    527:   [
                    528:     /ttt arg1 def
                    529:     %% ttt oxsetmathcap     ttt oxmathcap  %% It is done in asir.init
                    530:     %% Do nothing special for now.
                    531:   ] pop
                    532:   popVariables
                    533: } def
                    534: /ox103_sm1_init {
                    535:   /arg1 set
                    536:   [/ttt] pushVariables
                    537:   [
                    538:     /ttt arg1 def
                    539:     ttt oxsetmathcap
                    540:     ttt oxmathcap
                    541:     ttt ([(parse) (oxrfc103.sm1) pushfile] extension ) oxsubmit
                    542:   ] pop
                    543:   popVariables
                    544: } def
                    545: %%%
                    546:
                    547: /Xm_rfc103_shared [ ] def
                    548:
                    549: [(ox103_set_shared_variable)
                    550:  [(value name 2 ox103_set_shared_variable)
                    551:   (It broadcasts the <<value>> of a shared variable <<name>>)
                    552:   (to all processes.)
                    553:   (cf. Xm_rfc103_shared, )
                    554:   $Example:  (2).. (hoge) 2 ox103_set_shared_variable$
                    555: ]] putUsages
                    556: /ox103_set_shared_variable {
                    557:   /arg0 set  %% Dummy to be called by rpc2. Number of args
                    558:   /arg1 set  %% Name
                    559:   /arg2 set  %% Value,  [Name Value] not [Value Name]
                    560:   [/in-ox103_set_shared_variable /Name /Value
                    561:    /Found /N /i  /L
                    562:   ] pushVariables
                    563:   [
                    564:     /Name arg1 def
                    565:     /Value arg2 def
                    566:     Value message
                    567:     /Found 0 def
                    568:     /N  Xm_rfc103_shared length def
                    569:     0 1 N 1 sub {
                    570:       /i set
                    571:       Xm_rfc103_shared i get 0 get
                    572:       Name eq {
                    573:         Xm_rfc103_shared i [Name Value] put
                    574:         /Found 1 def
                    575:         exit
                    576:       } {  } ifelse
                    577:     } for
                    578:     Found 1 eq { }
                    579:     {
                    580:       Xm_rfc103_shared [Name Value] append
                    581:       /Xm_rfc103_shared set
                    582:     } ifelse
                    583:     /L [(oxGetClientList)] extension def
                    584:     0 1 L length 1 sub {
                    585:       /i set
                    586:       L i get [(ox103_set_shared_variable) Name Value] oxrpc2
                    587:     } for
                    588:
                    589:     (ox103_set_shared_variable: Xm_rfc103_shared=) message
                    590:     Xm_rfc103_shared message
                    591:     %% [(parse) [(/) Name ( ) Value toString ( def )] cat] extension
                    592:     %% Add $ $ when Value is a string.
                    593:
                    594:     /arg1 [Name Value] def
                    595:   ] pop
                    596:   popVariables
                    597:   arg1
                    598: } def
                    599:
                    600: /ox103_test {
                    601:   (x^2-1). fctr
                    602:   oxasir.ccc ( sm1_start(); ) oxexecutestring
                    603:   sm1connectr
                    604: } def
                    605:
                    606: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    607: %%%%%%%%   Starting ox_sm1.
                    608: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    609: /sm1connectr {
                    610:  [/in-sm1connectr /pass /peer /data /control ] pushVariables
                    611:  [
1.25      takayama  612:    [(getServerEnv) (bin/ox_sm1)] extension tag 0 eq {
                    613:      (Server bin/ox_sm1 is not found.) error
                    614:    }{ } ifelse
1.23      takayama  615:  /pass [(oxGenPass)] extension def
                    616:  /peer [(oxGetPort) (localhost)] extension def
                    617:  /data peer 1 get toString def
                    618:  /control peer 3 get toString def
                    619:  peer message
                    620:  [
                    621:   oxstart100
                    622:   Xm_noX { ( -nox ) } {  } ifelse
                    623:   ( -oxserver bin/ox_sm1 -e ) ( -reverse )
                    624:   ( -data ) data ( -control ) control  ( -pass ) pass
                    625:   ( )] cat execve
                    626:  [(oxCreateClient2) peer 0 pass] extension /oxsm1.ccc set
                    627:                      %% 0 means connect from only localhost.
                    628:  (The server is binded to the variable oxsm1.ccc) message
                    629:   /ox.ccc oxsm1.ccc def
                    630:   oxsm1.ccc.init
                    631:   oxsm1.ccc
                    632:  ] pop
                    633:  popVariables
                    634: } def
                    635:
                    636: /oxsm1.ccc.init {
                    637:    oxsm1.ccc ( [(oxPrintMessage) 0] extension pop ) oxsubmit
                    638:    Xm_noX { oxsm1.ccc ( /@@@.Xm_noX 1 def ) oxsubmit }
                    639:           { oxsm1.ccc ( /@@@.Xm_noX 0 def ) oxsubmit } ifelse
                    640:    (Ox103_loaded) boundp
                    641:    { oxsm1.ccc ox103_sm1_init }
                    642:    { }  ifelse
                    643: } def
                    644:
                    645: /sm1connectr-ssh {
                    646: %% It has not yet implemented.
                    647:  /arg1 set
                    648:  [/in-sm1connectr /pass /peer /data /control /name /machine
                    649:   /your-peer /comm
                    650:  ] pushVariables
                    651:  [
                    652:  /machine arg1 0 get def
                    653:  /name arg1 1 get def
                    654:
                    655:  /pass [(oxGenPass)] extension def
                    656:  /peer [(oxGetPort) myhostname-ssh] extension def
                    657:  /data peer 1 get toString def
                    658:  /control peer 3 get toString def
                    659:  peer message
                    660:  [(ssh -f ) machine ( -l ) name ( ")
                    661:   oxpath.oxlog.xterm-ssh  oxpath.ox-ssh ( -reverse -ox ) oxpath.oxsm1-ssh
                    662:   ( -host ) myhostname-ssh
                    663:   ( -data ) data ( -control ) control  ( -pass ) pass
                    664:   oxpath.null
                    665:   ( ")
                    666:  ] cat /comm set
                    667:  (Executing the command : ) messagen comm message message
                    668:   comm system
                    669:  (sleep 5) system-csh
                    670:  [(oxCreateClient2) peer 1 pass] extension /your-peer set
                    671:  /arg1 your-peer def
                    672:  ] pop
                    673:  popVariables
                    674:  arg1
                    675: } def
                    676: [(sm1connectr-ssh)
                    677: [([hostname login-name] sm1connectr-ssh client)
                    678:  (Starting oxpath.oxsm1-ssh by the launcher oxpath.ox-ssh on the "hostname".)
                    679:  (cf. oxNoX )
                    680:  (Set the following varialbes to appropriate values:)
                    681:  (oxpath.oxlog.xterm-ssh  oxpath.oxsm1-ssh  oxpath.ox-ssh myhostname-ssh )
                    682:  $Example 1: $
                    683:  $  *** Path names on the remote machine dc1.math.kobe-u.ac.jp $
                    684:  $    /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog /usr/X11R6/bin/xterm -icon -e ) def $
                    685:  $    /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
                    686:  $    /oxpath.ox-ssh    (/home/taka/OpenXM/bin/ox) def $
                    687:  $  *** The machine name on which you are running sm1. $
                    688:  $    /myhostname-ssh   (yama.math.kobe-u.ac.jp) def $
                    689:  $         [(dc1.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set  $
                    690:  $Example 2: $
                    691:  $  *** Path names on the remote machine dc2.math.kobe-u.ac.jp $
                    692:  $  *** We will not use X11 debug windows. $
                    693:  $    oxNoX $
                    694:  $    /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog ) def $
                    695:  $    /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
                    696:  $    /oxpath.ox-ssh    (/home/taka/OpenXM/bin/ox) def $
                    697:  $  *** the machine name on which you are running sm1. $
                    698:  $    /myhostname-ssh   (dc1.math.kobe-u.ac.jp) def $
                    699:  $         [(dc2.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set  $
                    700: ]] putUsages
1.26    ! takayama  701:
        !           702: %%% ntl
        !           703: /ntlconnectr {
        !           704:  [/in-ntlconnectr /pass /peer /data /control ] pushVariables
        !           705:  [
        !           706:    [(getServerEnv) (bin/ox_ntl)] extension tag 0 eq {
        !           707:      (Server bin/ox_ntl is not found.) error
        !           708:    }{ } ifelse
        !           709:  /pass [(oxGenPass)] extension def
        !           710:  /peer [(oxGetPort) (localhost)] extension def
        !           711:  /data peer 1 get toString def
        !           712:  /control peer 3 get toString def
        !           713:  peer message
        !           714:  [
        !           715:   oxstart100
        !           716:   Xm_noX { ( -nox ) } {  } ifelse
        !           717:   ( -oxserver bin/ox_ntl -e ) ( -reverse )
        !           718:   ( -data ) data ( -control ) control  ( -pass ) pass
        !           719:   ( )] cat execve
        !           720:  [(oxCreateClient2) peer 0 pass] extension /oxntl.ccc set
        !           721:                      %% 0 means connect from only localhost.
        !           722:  (The server is binded to the variable oxntl.ccc) message
        !           723: %  oxntl.ccc.init
        !           724:    oxntl.ccc
        !           725:  ] pop
        !           726:  popVariables
        !           727: } def
1.23      takayama  728:
                    729: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    730: %%%   Aux functions for ox_asir
                    731: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    732: /ox_asirConnectMethod { asirconnectr /oxasir.ccc set } def
                    733: /oxasir.loadmethod 1 def   %% "..." oxsendcmo (load) ox...
                    734: /oxasir.verbose 0   def
                    735: /oxasir.ccc load isArray
                    736: { }
                    737: { /oxasir.ccc [ ] def } ifelse
                    738: /loadAsirFile {
                    739:   /arg1 set
                    740:   [/in-loadAsirFile /peer /fname] pushVariables
                    741:   [
                    742:     /peer arg1 0 get def
                    743:     /fname arg1 1 get def
                    744:     oxasir.loadmethod  {
                    745:       peer  fname oxsendcmo peer 1 oxsendcmo
                    746:       peer (load) oxexec
1.16      takayama  747:     }{
1.23      takayama  748:       peer  [$load("$ fname $");$] cat oxsubmit
1.16      takayama  749:     }ifelse
1.23      takayama  750:   ] pop
                    751:   popVariables
                    752: } def
                    753: [(loadAsirFile)
                    754: [$[client fname] loadAsirFile   (ox_asir function)$
                    755:  $Load a file into the client$
                    756: ]] putUsages
                    757:
                    758: /set_oxasir.rr_path {
                    759:  [(ostype)] extension  0 get (windows) eq {
                    760:   [(getenv) (OSTYPE)] extension tag 0 eq {
                    761:      /oxasir.rr.name  (oxasir-win.rr) def
                    762:   }{
                    763:    [(getenv) (OSTYPE)] extension (cygwin) eq {
                    764:      /oxasir.rr.name  (oxasir.asir) def
                    765:    }{
                    766:      /oxasir.rr.name  (oxasir-win.rr) def
                    767:    } ifelse
                    768:   } ifelse
                    769:  }{
                    770:      /oxasir.rr.name  (oxasir.asir) def
                    771:  } ifelse
                    772: } def
                    773: set_oxasir.rr_path
                    774: /oxasirpath.asirlib [[(getenv) (OpenXM_HOME)] extension
                    775:                       (/lib/sm1/) oxasir.rr.name] cat  def
                    776: oxasir.verbose {
                    777:  oxasirpath.asirlib message
                    778: } { } ifelse
                    779:
                    780: %% Note.  oxasir.asir is under OpenXM/src/kan96xx/lib/
                    781: %%        oxasir-win.asir is generated under OpenXM/misc/packages/Windows
                    782: %%       They are installed under $OpenXM_HOME/lib/sm1
                    783: %%       Todo:  ox_asir has to understand /cygdrive/c/... on windows-native.
                    784: %%              Since ox_asir is generated by cygwin, it will be OK.
                    785: /asir.init {
                    786:  %% gr and primdec are loaded by .asirrc
                    787:  /asir.init.peer set
                    788:  [(ostype)] extension  0 get (windows) eq {
                    789:   [(getenv) (OSTYPE)] extension tag 0 eq {
                    790:     [asir.init.peer (oxasir-win.rr)] oxasirParseFile
                    791:   }{
                    792:    [(getenv) (OSTYPE)] extension (cygwin) eq {
                    793:      [asir.init.peer  oxasirpath.asirlib] loadAsirFile
                    794:    }{
                    795:      [asir.init.peer  (oxasir-win.rr)] oxasirParseFile
                    796:    } ifelse
                    797:   } ifelse
                    798:  }{
                    799:    [asir.init.peer  oxasirpath.asirlib] loadAsirFile
                    800:  } ifelse
                    801:  asir.init.peer oxmathcap
                    802:  asir.init.peer oxsetmathcap
                    803:  Xm_noX {
                    804:    asir.init.peer (Xm_noX=1;) oxsubmit
                    805:  }{
                    806:    asir.init.peer (Xm_noX=0;) oxsubmit
                    807:  } ifelse
                    808:  (Ox103_loaded) boundp
                    809:  {
                    810:    asir.init.peer ox103_asir_init
                    811:  }{  } ifelse
                    812: } def
                    813:
                    814: [(asir)
                    815:  [(pid [asir-command, asir-arg1, asir-arg2, ...] asir result  (ox_asir function))
                    816:   (Call open asir server. You need to install ox_asir on your system)
                    817:   (to use this function. cf. primadec, fctr, asirconnect2, asirconnectr.)
                    818:   (If you interrupted the computation by typing ctrl-C, type in )
                    819:   (   oxasir.ccc oxreset  ; )
                    820:   (to interrupt the ox_asir server.)
                    821:   (Example: oxasir.ccc [(fctr) (x^10-1).] asir )
                    822:   (  )
                    823:   (This function requires plugins cmo, socket and ox_asir server. cf. oxasir)
                    824:   (See, ftp://endeavor.fujitsu.co.jp/pub/isis/asir on asir)
                    825:  ]
                    826: ] putUsages
                    827:
                    828: /asir {
                    829:   /arg2 set
                    830:   /arg1 set
                    831:   [/pid  /asir-comm /comm /n /i /rr] pushVariables
                    832:   [(CurrentRingp)] pushEnv
                    833:   [
                    834:      /pid arg1 def
                    835:      /asir-comm arg2 def
                    836:      pid tag 6 eq {  } { (Invalid pid. See asir.) error } ifelse
                    837:      pid 0 get (client) eq { } { (Invalid pid. See asir.) error } ifelse
                    838:      asir-comm tag 6 eq {  } { (Invalid argument asir-comm. See asir) error } ifelse
                    839:
                    840:     [ %% Change the current ring if necessary to send a correct OxVlist.
                    841:       asir-comm oxasir.changeRing
                    842:     ] pop
                    843:     %%% Setting OxVlist to tell asir a way to change dist-poly <==> poly.
                    844:     (OxVlist=) getVlist2 toString (;) 3 cat_n /comm set
                    845:      %% comm message
                    846:      pid comm oxsubmit
                    847:      pid (print(OxVlist);) oxsubmit
                    848:
                    849:
                    850:      /n asir-comm length def
                    851:      n 1 sub -1 1 {
                    852:        /i set
                    853:        pid asir-comm i get oxsendcmo
                    854:        pid 1 oxsendcmo pid (ox_dtop) oxexec
                    855:      } for
                    856:      pid n 1 sub oxsendcmo
                    857:      pid asir-comm 0 get oxexec
                    858:
                    859:      pid 1 oxsendcmo pid (ox_ptod) oxexec
                    860:      pid oxpopcmo /arg1 set
                    861:
1.16      takayama  862:
1.23      takayama  863:   ] pop
                    864:   popEnv
                    865:   popVariables
                    866:   arg1
                    867: } def
                    868:
                    869: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    870: %%% Mathematical functions for asir
                    871: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    872: /oxasir.changeRing {
                    873:   /arg1 set
                    874:   [/in-oxasir.changeRing /f /rr] pushVariables
                    875:   [
                    876:      /f arg1 def
                    877:      f isArray {
                    878:        f {oxasir.changeRing} map
                    879:      }{
                    880:        f isPolynomial {
                    881:          f (0). eq { }
                    882:          { f (ring) dc /rr set [(CurrentRingp) rr] system_variable } ifelse
                    883:        } {  } ifelse
                    884:      } ifelse
                    885:   ] pop
                    886:   popVariables
                    887: } def
                    888:
                    889: /fctr {
                    890:   /arg1 set
                    891:   [/f /comm /vv] pushVariables
                    892:   [(CurrentRingp)] pushEnv
                    893:   [
                    894:     /f arg1 def
                    895:     oxasir.ccc [ ] eq {
                    896:        (Starting ox_asir server.) message
                    897:         ox_asirConnectMethod
                    898:     } {  } ifelse
                    899:
                    900:     f isPolynomial not {
                    901:       /vv f 1 get def
                    902:       vv isArray { /vv vv from_records  def } {  } ifelse
                    903:       /f f 0 get def
                    904:       [vv ring_of_polynomials 0] define_ring
                    905:       f . /f set
1.16      takayama  906:     }{ } ifelse
1.23      takayama  907:     oxasir.ccc [(fctr) f] asir /arg1 set
1.16      takayama  908:   ] pop
1.23      takayama  909:   popEnv
1.16      takayama  910:   popVariables
                    911:   arg1
                    912: } def
                    913:
1.23      takayama  914: [(fctr)
                    915:  [(You need to install ox_asir server to use this function. (ox_asir function))
                    916:   (f fctr g)
                    917:   (poly f; array g;)
                    918:   ([f v] fctr g ;  string f, string or array of string v)
                    919:   (This function factors the polynomial f over Q.)
                    920:   ( )
                    921:   (Example 1:  [(x^10-y^10) (x,y)] fctr ::)
                    922:   (Example 2:  (x^10-1). fctr ::)
                    923:   ( )
                    924:   (If you interrupted the computation by typing ctrl-C, type in )
                    925:   (   oxasir.ccc oxreset  ; )
                    926:   (to interrupt the ox_asir server.)
                    927:   (  )
                    928:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                    929: ]] putUsages
                    930:
                    931:
                    932: [(primadec)
                    933:  [(You need to install ox_asir server to use this function. (ox_asir function))
                    934:   ([ ii ] primadec [[q1 p1] [q2 p2] ... ] )
                    935:   ( array of poly ii; array of poly q1, p1, q2, p2 ...;)
                    936:   ( q1, q2, ... are primary components of the primary ideal decomposition)
                    937:   ( of the ideal generated by << ii >>.)
                    938:   (  )
                    939:   ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
                    940:   ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
                    941:   (<< v >> is an array of independent variables.)
                    942:   (  )
                    943:   ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
                    944:   ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
                    945:   ( v  is a string of variables separated by , )
                    946:   (  )
                    947:   (Example:  [(x,y) ring_of_polynomials 0] define_ring)
                    948:   (          [ [(x^2-1). (x y).] ] primadec pmat ;)
                    949:   (  )
                    950:   (Example:  [ [(x^2-1) (x y)] [(x) (y)]] primadec pmat ;)
                    951:   (  )
                    952:   (If you interrupted the computation by typing ctrl-C, type in )
                    953:   (   oxasir.ccc oxreset  ; )
                    954:   (to interrupt the ox_asir server.)
                    955:   (  )
                    956:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                    957: ]] putUsages
                    958:
                    959: /primadec {
                    960:   /arg1 set
                    961:   [/in-primadec /aa /f  /comm /vvv /r /setarg] pushVariables
                    962:   [(CurrentRingp)] pushEnv
                    963:   [
                    964:     /aa arg1 def
                    965:     aa isArray { } { (<<array>> primadec) error } ifelse
                    966:     /setarg 0 def
                    967:     oxasir.ccc [ ] eq {
                    968:        (Starting ox_asir server.) message
                    969:         ox_asirConnectMethod
                    970:     } {  } ifelse
                    971:     aa { tag } map /typev set
                    972:     typev [ ArrayP ] eq
                    973:     {  /f aa 0 get def
                    974:        f 0 get (ring) dc /r set
                    975:        [(CurrentRingp) r] system_variable
                    976:        /vvv getVariableNames def
                    977:        /setarg 1 def
                    978:     } { } ifelse
                    979:     typev [ArrayP StringP] eq
                    980:     {  /f aa 0 get def
                    981:        /vvv [ aa 1 get to_records pop ] def
                    982:        /setarg 1 def
                    983:     } { } ifelse
                    984:     typev [ArrayP ArrayP] eq
                    985:     {  /f aa 0 get def
                    986:        /vvv aa 1 get {toString} map def
                    987:        /setarg 1 def
                    988:     } { } ifelse
                    989:     setarg { } { (primadec : Argument mismatch) error } ifelse
                    990:
                    991:     f 0 get isPolynomial {
                    992:       /r f 0 get (ring) dc def
                    993:       /vvv vvv { r ,, } map def
                    994:     }
                    995:     {
                    996:       [vvv from_records ring_of_polynomials 0] define_ring
                    997:       f { toString . } map /f set
                    998:       vvv { . } map /vvv set
                    999:     } ifelse
                   1000:     oxasir.ccc [(primadec) f vvv] asir /arg1 set
1.16      takayama 1001:   ] pop
1.23      takayama 1002:   popEnv
1.16      takayama 1003:   popVariables
                   1004:   arg1
                   1005: } def
1.20      takayama 1006:
1.23      takayama 1007:
                   1008: /getVlist2 {
                   1009:   [/n  /i ] pushVariables
1.20      takayama 1010:   [
1.23      takayama 1011:     /n [(N)] system_variable def
                   1012:     [
                   1013:       0 1 n 1 sub { /i set (x) i (dollar) dc 2 cat_n } for
                   1014:       0 1 n 1 sub { /i set (d) i (dollar) dc 2 cat_n } for
                   1015:     ] /arg1 set
1.20      takayama 1016:   ] pop
                   1017:   popVariables
                   1018:   arg1
                   1019: } def
                   1020:
1.23      takayama 1021: %%%%%%%%%%%%%%%%%%%
                   1022: /getVlist {
                   1023:   [/n  /i ] pushVariables
                   1024:   [
                   1025:     /n [(N)] system_variable def
                   1026:     [
                   1027:       0 1 n 1 sub { /i set [(x) (var) i] system_variable } for
                   1028:       0 1 n 1 sub { /i set [(D) (var) i] system_variable } for
                   1029:     ] /arg1 set
                   1030:   ] pop
                   1031:   popVariables
                   1032:   arg1
                   1033: } def
1.20      takayama 1034:
1.23      takayama 1035: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1036: [(chattr) 0 /findIntegralRoots] extension pop
                   1037: /findIntegralRoots {
                   1038:   /arg1 set
                   1039:   [/in-findIntegralRoots /pp ] pushVariables
1.20      takayama 1040:   [
1.23      takayama 1041:     /pp arg1 def
                   1042:     oxasir.ccc [ ] eq {
                   1043:       (Starting ox_asir server.) message
                   1044:        ox_asirConnectMethod
                   1045:     } {  } ifelse
                   1046:     oxasir.ccc oxIsServerReady
                   1047:     { pp findIntegralRoots.oxasir /arg1 set}
                   1048:     { pp findIntegralRoots.slow /arg1 set} ifelse
1.20      takayama 1049:   ] pop
                   1050:   popVariables
                   1051:   arg1
                   1052: } def
1.23      takayama 1053:
                   1054: /findIntegralRoots.oxasir {
1.20      takayama 1055:   /arg1 set
1.23      takayama 1056:   [/in-findIntegralRoots /f /r /g /aa /rlist] pushVariables
                   1057:   [(CurrentRingp) (KanGBmessage)] pushEnv
1.20      takayama 1058:   [
1.23      takayama 1059:     /f arg1 def
                   1060:     [(s) ring_of_polynomials 0] define_ring
                   1061:     f toString . /f set
                   1062:     f fctr rest /g set
                   1063:     g {
                   1064:          0 get /aa set
                   1065:          aa (s). degree 1 eq {
                   1066:            aa (s). coeff 1 get /aa set
                   1067:            aa length 1 eq { 0 }
                   1068:            {  aa 0 get (1). eq {
                   1069:                  0 << aa 1 get (integer) dc >> sub
                   1070:               } { } ifelse
                   1071:            } ifelse
                   1072:          }{ } ifelse
                   1073:      } map
                   1074:     /rlist set
                   1075:     %% rlist ::
                   1076:     [-1000000] rlist join shell rest /arg1 set
1.20      takayama 1077:   ] pop
1.23      takayama 1078:   popEnv
1.20      takayama 1079:   popVariables
                   1080:   arg1
1.21      takayama 1081: } def
                   1082:
1.23      takayama 1083: %%%%%%%%%%%%%   From gbhg3/Int/intw.sm1
                   1084: %% This function needs solv1.asir and ox_asir.
                   1085: %% See solv1.asir for the usage of this function.
                   1086: /rationalRoots2 {
                   1087:   /arg1 set
                   1088:   [/in-rationalRoots2 /aa /f  /comm /vvv /r /setarg
                   1089:    /w /ans
                   1090:   ] pushVariables
                   1091:   [(CurrentRingp) (KanGBmessage)] pushEnv
1.21      takayama 1092:   [
1.23      takayama 1093:     /aa arg1 def
                   1094:     aa isArray { } { (<<array>> rationalRoots2) error } ifelse
                   1095:     /setarg 0 def
                   1096:     oxasir.ccc [ ] eq {
                   1097:        (Starting ox_asir server.) message
                   1098:         ox_asirConnectMethod
                   1099:     } {  } ifelse
                   1100:     aa { tag } map /typev set
                   1101:     typev [ArrayP StringP ArrayP] eq
                   1102:     {  /f aa 0 get def
                   1103:        /vvv [ aa 1 get to_records pop ] def
                   1104:        /w aa 2 get def
                   1105:        /setarg 1 def
                   1106:     } { } ifelse
                   1107:     typev [ArrayP ArrayP ArrayP] eq
                   1108:     {  /f aa 0 get def
                   1109:        /vvv aa 1 get {toString} map def
                   1110:        /setarg 1 def
                   1111:        /w aa 2 get def
                   1112:     } { } ifelse
                   1113:     setarg { } { (rationalRoots2 : Argument mismatch) error } ifelse
                   1114:
                   1115:
                   1116:     [vvv from_records ring_of_polynomials 0] define_ring
                   1117:     f { toString . } map /f set
                   1118:     vvv { . } map /vvv set
                   1119:     w { toString . } map /w set
                   1120:
                   1121:     (rationalRoots2 -- f = ) messagen f messagen
                   1122:     ( , vvv= ) messagen vvv messagen ( , w = ) messagen w message
                   1123:
                   1124:     vvv length 1 eq w 0 get (1). eq and
                   1125:     {
                   1126:        [(KanGBmessage) 0] system_variable
                   1127:        [f] groebner_sugar 0 get /f set
                   1128:        vvv 0 get toString (s) eq {
                   1129:        }{ [[vvv 0 get toString (s)] from_records ring_of_polynomials 0] define_ring}
                   1130:        ifelse
                   1131:        f 0 get toString . [[vvv 0 get toString . (s).]] replace
                   1132:        findIntegralRoots /ans set
                   1133:     }
                   1134:     {
                   1135:       oxasir.ccc [(sm1_rationalRoots2) f vvv w] asir
                   1136:       {(integer) dc} map
                   1137:       /ans set
1.21      takayama 1138:     } ifelse
1.23      takayama 1139:
1.21      takayama 1140:     /arg1 ans def
                   1141:   ] pop
1.23      takayama 1142:   popEnv
                   1143:   popVariables
                   1144:   arg1
                   1145: } def
                   1146: [(rationalRoots2)
                   1147: [(rationalRoots2  (ox_asir function) called from intw.sm1 to analyze integral)
                   1148:  (roots.)
                   1149: ]] putUsages
                   1150:
                   1151: /ptozp_subst  {
                   1152:   /arg1 set
                   1153:   [/in-ptozp_subst /aaa /fff /xxx /vvv /vlist] pushVariables
                   1154:   [(CurrentRingp)] pushEnv
                   1155:   [
                   1156:      /aaa arg1 def
                   1157:      /fff aaa 0 get def
                   1158:      /xxx aaa 1 get toString def
                   1159:      /vvv aaa 2 get {toString ..} map def
                   1160:      aaa length 4 eq {
                   1161:        /vlist aaa 3 get def
                   1162:      } {
                   1163:        /vlist 0 def
                   1164:      } ifelse
                   1165:      oxasir.ccc [ ] eq {
                   1166:         (Starting ox_asir server.) message
                   1167:         ox_asirConnectMethod
                   1168:      } {  } ifelse
                   1169:      fff isPolynomial {
                   1170:        fff (ring) dc ring_def
                   1171:        fff toString /fff set
                   1172:      }
                   1173:      { vlist isInteger { (ptozp_subst: need variable names.) error } {  } ifelse
                   1174:        [vlist ring_of_differential_operators 0] define_ring
                   1175:      } ifelse
                   1176:      oxasir.ccc [(sm1_ptozp_subst) fff . xxx .  vvv] asir
                   1177:      /arg1 set
                   1178:   ] pop
                   1179:   popEnv
                   1180:   popVariables
                   1181:   arg1
                   1182: } def
                   1183:
                   1184: [(ptozp_subst)
                   1185:  [$[f  s  [p q] v] ptozp_subst g   (ox_asir function)$
                   1186:   $It returns ptozp(subst(f,s,p/q))$
                   1187:   $Example 1:  [ (x Dx - s) (s) [2 3] (x,s)] ptozp_subst $
                   1188:   $   ===>     3 x Dx - 2 $
                   1189: ]] putUsages
                   1190:
                   1191: /reduceByAsir  {
                   1192:   /arg1 set
                   1193:   [/in-reduceByAsir /aaa /fff /fff0 /fff1 /vlist] pushVariables
                   1194:   [(CurrentRingp)] pushEnv
                   1195:   [
                   1196:      /aaa arg1 def
                   1197:      /fff aaa 0 get def
                   1198:      aaa length 2 eq {
                   1199:        /vlist aaa 1 get def
                   1200:      } {
                   1201:        /vlist 0 def
                   1202:      } ifelse
                   1203:      oxasir.ccc [ ] eq {
                   1204:         (Starting ox_asir server.) message
                   1205:         ox_asirConnectMethod
                   1206:      } {  } ifelse
                   1207:      fff isArray {
                   1208:        fff length 2 eq {
                   1209:          /fff0 fff 0 get def
                   1210:          /fff1 fff 1 get def
                   1211:        } {
                   1212:          ([ << [f g] >> vlist ] reduceByAsir ) error
                   1213:        } ifelse
                   1214:      } {
                   1215:        ([ << [f g] >> vlist ] reduceByAsir ) error
                   1216:      } ifelse
                   1217:      fff0 isPolynomial fff1 isPolynomial and {
                   1218:        fff0 (ring) dc ring_def
                   1219:        fff0 toString . /fff0 set
                   1220:        fff1 (ring) dc ring_def
                   1221:        fff1 toString . /fff1 set
                   1222:      }
                   1223:      { vlist isInteger { (reduceByAsir: need variable names.) error } {  } ifelse
                   1224:        [vlist ring_of_differential_operators 0] define_ring
                   1225:        fff0 toString . /fff0 set
                   1226:        fff1 toString . /fff1 set
                   1227:      } ifelse
                   1228:      oxasir.ccc [(sm1_rat2plist2) [fff0 fff1]] asir
                   1229:      /arg1 set
                   1230:   ] pop
                   1231:   popEnv
                   1232:   popVariables
                   1233:   arg1
                   1234: } def
                   1235:
                   1236: [(reduceByAsir)
                   1237: [$ [[f g] v] reduceByAsir [ff gg]   (ox_asir function)$
                   1238:  $ [[f g]] reduceByAsir [ff gg]  $
                   1239:  $Example 1: [[(2 x -2) (4 x - 8)] (x)] reduceByAsir $
                   1240:  (Note that there may be a gcd that is more than 1 among the coefficients.)
                   1241: ]] putUsages
                   1242:
                   1243: %% File should be preprocessed by OpenXM/misc/packages/Windows/oxpp
                   1244: %% and ./oxapp --removeSharp
                   1245: [(oxasirParseFile)
                   1246: [$[peer filename] oxasirParseFile $
                   1247:  $File should be preprocessed by OpenXM/misc/packages/Windows/oxpp$
                   1248:  $and ./oxapp --removeSharp $
                   1249: ]] putUsages
                   1250:
                   1251: /oxasirParseFile {
                   1252:   /arg1 set
                   1253:   [/in-oxasirParseFile /fname /sss] pushVariables
                   1254:   [
                   1255:     /fname arg1 1 get def
                   1256:     /peer  arg1 0 get def
                   1257:     fname pushfile /sss set
                   1258:     peer
                   1259:     [$if (1) { ; $ sss (}$)] cat
                   1260:     oxsubmit
                   1261:   ] pop
                   1262:   popVariables
                   1263: } def
                   1264:
                   1265: [(bfct)
                   1266:  [
                   1267:   ( f bfct b )
                   1268:   ( poly f; poly b)
                   1269:   ([f v] bfct b)
                   1270:   ( string f )
                   1271:   ( b is the global b-function of the polynomial f.)
                   1272:   (Example: [(x^3-y^2) (x,y)] bfct fctr :: )
                   1273:   (Algorithm: M.Noro, Mathematical Software, icms 2002, pp.147--157.)
                   1274:   (  )
                   1275:   (If you interrupted the computation by typing ctrl-C, type in )
                   1276:   (   oxasir.ccc oxreset  ; )
                   1277:   (to interrupt the ox_asir server.)
                   1278:   (  )
                   1279:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1280:   (You need to install ox_asir server to use this function. (ox_asir function))
                   1281: ]] putUsages
                   1282:
                   1283: /bfct {
                   1284:   /arg1 set
                   1285:   [/in-bfct /f /comm /vv] pushVariables
                   1286:   [(CurrentRingp)] pushEnv
                   1287:   [
                   1288:     /f arg1 def
                   1289:     oxasir.ccc [ ] eq {
                   1290:        (Starting ox_asir server.) message
                   1291:         ox_asirConnectMethod
                   1292:     } {  } ifelse
                   1293:
                   1294:     f isPolynomial not {
                   1295:       /vv f 1 get def
                   1296:       vv isArray { /vv vv from_records  def } {  } ifelse
                   1297:       /f f 0 get def
                   1298:       [vv ring_of_polynomials 0] define_ring
                   1299:       f . /f set
                   1300:     }{ } ifelse
                   1301:     oxasir.ccc [(oxasir_bfct) f] asir /f set
                   1302:     [(s) ring_of_polynomials 0] define_ring
                   1303:     f . /f set
                   1304:     [f f fctr] /arg1 set
                   1305:   ] pop
                   1306:   popEnv
1.21      takayama 1307:   popVariables
                   1308:   arg1
                   1309: } def
                   1310:
1.23      takayama 1311: [(generic_bfct)
                   1312:  [
                   1313:   ( [ii weight] generic_bfct b )
                   1314:   ( list of poly ii; list weight)
                   1315:   ([ii weight variables] generic_bfct b)
                   1316:   ( list of string ii; list weight; list variables)
                   1317:   ( b is the general b-function of the ideal ii w.r.t the weight.)
                   1318:   (Example: [[(Dx^2) (Dy^2)] [(x) -1 (Dx) 1] [(x) (y)]] generic_bfct :: )
                   1319:   (Notion: Saito, Sturmfels, Takayama, Grobner deformations of hypergeometric differential equaitons)
                   1320:   (Algorithm:  M.Noro, Mathematical Software, icms 2002, pp.147--157.)
                   1321:   (  )
                   1322:   (If you interrupted the computation by typing ctrl-C, type in )
                   1323:   (   oxasir.ccc oxreset  ; )
                   1324:   (to interrupt the ox_asir server.)
                   1325:   (  )
                   1326:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1327:   (You need to install ox_asir server to use this function. (ox_asir function))
                   1328: ]] putUsages
                   1329:
                   1330: /generic_bfct {
                   1331:   /arg1 set
                   1332:   [/in-generic_bfct /aa /f  /comm /vvv0 /n /vvv /ddd /r /setarg
                   1333:    /bf /wt ] pushVariables
                   1334:   [(CurrentRingp)] pushEnv
                   1335:   [
                   1336:     /aa arg1 def
                   1337:     aa isArray { } { (<<array>> generic_bfct) error } ifelse
                   1338:     /setarg 0 def
                   1339:     aa { tag } map /typev set
                   1340:     typev [ ArrayP ArrayP] eq
                   1341:     {  /f aa 0 get def
                   1342:        f 0 tag PolyP { } {  (The first argument must be a list of differential operators. Give the third variable: a list of variables) error } ifelse
                   1343:        f 0 get (ring) dc /r set
                   1344:        [(CurrentRingp) r] system_variable
                   1345:        /wt aa 1 get def
                   1346:
                   1347:        /vvv0 getVariableNames def
                   1348:        /n [(N)] system_variable def
                   1349:        /vvv vvv0 n carN rest reverse rest reverse def
                   1350:        /ddd vvv0 reverse n carN reverse
                   1351:                    rest reverse rest reverse def
                   1352:
                   1353:        /wt wt generic_bfct.aux1 def
                   1354:
                   1355:        /setarg 1 def
                   1356:     } { } ifelse
                   1357:     typev [ArrayP ArrayP StringP] eq
                   1358:     {  /f aa 0 get def
                   1359:        /vvv [ aa 2 get to_records pop ] def
                   1360:        /wt aa 1 get def
                   1361:
                   1362:        /n vvv length def
                   1363:        /ddd vvv { (D) 2 1 roll 2 cat_n } map def
                   1364:
                   1365:        /setarg 1 def
                   1366:     } { } ifelse
                   1367:     typev [ArrayP ArrayP ArrayP] eq
                   1368:     {  /f aa 0 get def
                   1369:        /vvv aa 2 get {toString} map def
                   1370:        /wt aa 1 get def
                   1371:
                   1372:        /n vvv length def
                   1373:        /ddd vvv { (D) 2 1 roll 2 cat_n } map def
                   1374:
                   1375:        /setarg 1 def
                   1376:     } { } ifelse
                   1377:     setarg { } { (generic_bfct : Argument mismatch) error } ifelse
                   1378:
                   1379:     f 0 get isPolynomial {
                   1380:
                   1381:     }
                   1382:     {
                   1383:       [vvv from_records ring_of_differential_operators 0] define_ring
                   1384:       f { toString . } map /f set
                   1385:       vvv { . } map /vvv set
                   1386:       ddd { . } map /ddd set
                   1387:       /wt wt generic_bfct.aux1 def
                   1388:     } ifelse
                   1389:     [f vvv ddd wt] message
                   1390:
                   1391:     oxasir.ccc [ ] eq {
                   1392:        (Starting ox_asir server.) message
                   1393:         ox_asirConnectMethod
                   1394:     } {  } ifelse
                   1395:
                   1396:     oxasir.ccc [(oxasir_generic_bfct) f vvv ddd wt] asir /bf set
                   1397:     [(s) ring_of_polynomials 0] define_ring
                   1398:     bf . /bf set
                   1399:     [bf bf fctr] /arg1 set
                   1400:   ] pop
                   1401:   popEnv
                   1402:   popVariables
                   1403:   arg1
1.20      takayama 1404: } def
1.22      takayama 1405:
1.23      takayama 1406: /generic_bfct.aux1 {
1.22      takayama 1407:   /arg1 set
1.23      takayama 1408:   [/in-generic_bfct.aux1 /wt /wtx /wtd /n]  pushVariables
                   1409:   [
                   1410:     arg1 /wt set
                   1411:     /n [(N)] system_variable def
                   1412:     wt { dup tag PolyP eq { toString } {    } ifelse } map /wt set
                   1413:     wt weightv /wt set
                   1414:     /wtx wt n carN rest reverse rest reverse def
                   1415:     /wtd wt reverse n carN reverse
                   1416:                    rest reverse rest reverse def
                   1417:     wtx wtd join /wt set
                   1418:     wt { dup tag IntegerP eq { (universalNumber) dc } {    } ifelse } map /wt set
                   1419:     wt /arg1 set
                   1420:   ] pop
                   1421:   popVariables
                   1422:   arg1
                   1423: } def
                   1424: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1425: %%% functions to start ox_asir
                   1426: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1427: /asirconnectr {
                   1428:  [/in-asirconnectr /pass /peer /data /control /oxasir] pushVariables
                   1429:  [
1.25      takayama 1430:    [(getServerEnv) (bin/ox_asir)] extension tag 0 eq {
                   1431:      (Server bin/ox_sm1 is not found.) error
                   1432:    }{ } ifelse
                   1433:
1.23      takayama 1434:  /pass [(oxGenPass)] extension def
                   1435:  /peer [(oxGetPort) (localhost)] extension def
                   1436:  /data peer 1 get toString def
                   1437:  /control peer 3 get toString def
                   1438:  peer message
1.22      takayama 1439:  [
1.23      takayama 1440:   oxstart100
                   1441:   Xm_noX { ( -nox ) } {  } ifelse
                   1442:   ( -oxserver bin/ox_asir -e ) ( -reverse )
                   1443:   ( -data ) data ( -control ) control  ( -pass ) pass
                   1444:   ( )] cat execve
                   1445:  [(oxCreateClient2) peer 0 pass] extension /oxasir.ccc set
                   1446:                      %% 0 means connect from only localhost.
                   1447:  oxasir.ccc asir.init
                   1448:  /arg1 oxasir.ccc def
1.22      takayama 1449:  ] pop
                   1450:  popVariables
1.23      takayama 1451:  arg1
1.22      takayama 1452: } def
                   1453:
1.23      takayama 1454: [(asirconnectr)
                   1455:  [(asirconnectr server  (ox_asir function))
                   1456:   (array server;)
                   1457:   (Example: asirconnectr /oxasir.ccc set)
                   1458: ]] putUsages
                   1459:
                   1460: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1461: %%% functions to start ox_k0
                   1462: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1463: /oxk0.ccc load isArray
                   1464: { }
                   1465: { /oxk0.ccc [ ] def } ifelse
1.22      takayama 1466:
1.23      takayama 1467: /ox.k0.init {
                   1468:   % oxk0.ccc ( Print("Hello!"); ) oxsubmit
                   1469:   Xm_noX { oxk0.ccc (Xm_noX=true;) oxsubmit }
                   1470:          { oxk0.ccc (Xm_noX=false;) oxsubmit } ifelse
                   1471: } def
1.1       maekawa  1472:
1.23      takayama 1473: /k0connectr {
                   1474:  [/in-k0connectr /pass /peer /data /control ] pushVariables
                   1475:  [
1.25      takayama 1476:    [(getServerEnv) (bin/ox_k0)] extension tag 0 eq {
                   1477:      (Server bin/ox_sm1 is not found.) error
                   1478:    }{ } ifelse
                   1479:
1.23      takayama 1480:  /pass [(oxGenPass)] extension def
                   1481:  /peer [(oxGetPort) (localhost)] extension def
                   1482:  /data peer 1 get toString def
                   1483:  /control peer 3 get toString def
                   1484:  peer message
                   1485:  [
                   1486:   oxstart100
                   1487:   Xm_noX { ( -nox ) } {  } ifelse
                   1488:   ( -oxserver bin/ox_k0 -e ) ( -reverse )
                   1489:   ( -data ) data ( -control ) control  ( -pass ) pass
                   1490:   ( )] cat execve
                   1491:  [(oxCreateClient2) peer 0 pass] extension /oxk0.ccc set
                   1492:                      %% 0 means connect from only localhost.
                   1493:  (The server is binded to the variable oxk0.ccc) message
                   1494:   ox.k0.init
                   1495:   /arg1 oxk0.ccc def
                   1496:  ] pop
                   1497:  popVariables
                   1498:  arg1
                   1499: } def

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