[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.27

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

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