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

1.59    ! takayama    1: %%%%%%%%%%%  $OpenXM: OpenXM/src/kan96xx/Doc/ox.sm1,v 1.58 2013/09/19 10:15:11 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
1.34      takayama   18: oxstart100  message-quiet
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.46      takayama   51: /Xm_engineLogToStdout 0 def
1.1       maekawa    52:
1.23      takayama   53: /oxNoX {
                     54:    /Xm_noX 1 def
                     55: } def
1.1       maekawa    56:
1.59    ! takayama   57: (@@@.monitor) boundp {
        !            58: }{
        !            59:   /@@@.monitor ( ) def
        !            60: } ifelse
        !            61:
        !            62: /oxMonitor {
        !            63:   /@@@.monitor ( -monitor ) def
        !            64: } def
1.1       maekawa    65:
1.23      takayama   66: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                     67: %%%   basic functions for OX-RFC 100
                     68: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.1       maekawa    69: /SM_executeStringByLocalParser 268 def
                     70: /SM_execute 268 def
                     71: /SM_popString  263  def
                     72: /SM_mathcap 264 def
                     73:
                     74: /SM_popCMO 262 def
                     75: /SM_executeFunction 269 def
1.11      takayama   76: /SM_DUMMY_sendcmo   2147418112 1 add def    %%% SM_PRIVATE+1
1.1       maekawa    77: /SM_sync_ball 281 def
                     78:
                     79: /SM_pops  265  def
                     80: /SM_setName 266  def
                     81: /SM_evalName 267  def
                     82:
                     83: /SM_setMathCap 273 def
                     84:
                     85: /SM_getsp     275  def
                     86: /SM_dupErrors 276  def
                     87:
1.36      takayama   88: /SM_pushCMOtag 277 def
1.39      takayama   89: /SM_executeFunctionWithOptionalArgument 282 def
1.36      takayama   90:
1.1       maekawa    91: /SM_control_kill 1024 def
                     92: /SM_control_reset_connection  1030 def
1.15      takayama   93: /SM_control_spawn_server  1027 def
1.1       maekawa    94:
                     95: /Etag_error 257 def
                     96:
                     97: [(ox)
                     98:  [
                     99:   (client aa oxpushcmo (oxsendcmo), client oxpopcmo dd, client popstring dd, client ss oxrpc)
1.23      takayama  100:  (Example: oxsm1.ccc [1 2 3] oxpushcmo oxsm1.ccc oxpopcmo /ff set  ff :: )
1.1       maekawa   101:  (  )
                    102:  (client ss oxexecutestring(oxsubmit) <<executeString>>, client ss oxexec <<executeFunction>>)
1.39      takayama  103:  (client ss oxexecWithOpt )
1.1       maekawa   104:
1.23      takayama  105:  (Example: oxsm1.ccc (0 1 10 { pop $Hello$ message } for) oxexecutestring )
                    106:  (Example: oxsm1.ccc (2).. oxpushcmo oxsm1.ccc (10).. oxpushcmo )
                    107:  (         oxsm1.ccc (power) oxexec  oxsm1.ccc oxpopcmo :: )
1.1       maekawa   108:  (  )
                    109:  (client str oxevalname, client str oxsetname, client num oxpops, client oxget)
                    110:  (   )
                    111:  (client oxmathcap, client oxsetmathcap, oxgenportfile, oxremoveportfile)
1.36      takayama  112:  (client oxpushcmotag)
1.1       maekawa   113:  (   )
                    114:  (client oxgetsp --- get stack pointer,  client oxgeterrors --- get all errors)
1.47      takayama  115:  (client oxclearstack --- clear the stack of the ox server.)
1.1       maekawa   116:  (cleint oxisData, client oxreset, client oxshutdown)
1.27      takayama  117:  (oxhelp for this message)
                    118:  ([(oxWatch) client] extension to start a log.)
                    119:  $        ex 1.  (ox.sm1) run sm1connectr [(oxWatch) oxsm1.ccc] extension  $
                    120:  $               oxsm1.ccc ( [(cmoLispLike) 0] extension ) oxsubmit $
                    121:  $               oxsm1.ccc ( [(cmoLispLike) 1] extension ) oxsubmit $
1.1       maekawa   122:  ([(oxSerial)] extension serial-number-of-out-going-ox-packet.)
1.23      takayama  123:  (oxpopcmo1, oxpopcmo2, sm1connectr ox_launch, ox_launch_nox)
1.1       maekawa   124:  (oxNoX : set an environment to invoke oxlog without xterm and to call oxlog with >& /dev/null)
                    125:  $        ex 1.  (ox.sm1) run oxNoX sm1connectr $
1.23      takayama  126:  $        ex 2.  (ox.sm1) run oxNoX (x^2-1). fctr pmat ; $
1.27      takayama  127:  $   $
                    128:  $cf. extension-oxLog $
1.59    ! takayama  129:  (oxMonitor : ox_sm1 server outputs packet dumps.)
        !           130:  $        ex 1. (ox.sm1) run oxMonitor sm1connectr $
1.1       maekawa   131:  ]
                    132: ] putUsages
1.27      takayama  133:
                    134: [(extension-oxLog)
                    135: [
                    136: $Take the log of communication in files.$
                    137: $[(oxLog) client logfile_for_incomming_data logfile_for_outgoing_data] extension $
                    138: $Example:$
                    139: $  [(parse) (ox.sm1) pushfile] extension$
                    140: $  sm1connectr$
                    141: $  (i.t) (w) file /ii set$
                    142: $  (o.t) (w) file /oo set$
                    143: $  [(oxLog) oxsm1.ccc ii oo] extension $
                    144: $  [(oxWatch) oxsm1.ccc ] extension$
                    145: $  oxsm1.ccc 1 oxpushcmo ;$
                    146: $  oxsm1.ccc oxpopcmo ;$
                    147: $  [(oxLogStop) oxsm1.ccc] extension$
                    148: ]] putUsages
1.1       maekawa   149:
1.23      takayama  150: /oxconnect {
                    151:   /arg1 set
                    152:   [(oxCreateClient) arg1 aload pop] extension
1.1       maekawa   153: } def
                    154:
                    155: ox.verbose { oxhelp } {  } ifelse
                    156:
                    157: /oxpushcmo { oxsendcmo } def
                    158: /oxsendcmo {
                    159:   /arg1 set
                    160:   /arg2 set
                    161:   ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    162:   } {  } ifelse
                    163:   [(oxReq) arg2 SM_DUMMY_sendcmo arg1] extension pop
1.36      takayama  164: } def
                    165:
                    166: /oxpushcmotag {
                    167:   /arg2 set
                    168:   [(oxReq) arg2 SM_pushCMOtag ] extension pop
1.1       maekawa   169: } def
                    170:
                    171: /oxpopcmo {
                    172:   /arg1 set
                    173:   [(oxReq) arg1 SM_popCMO ] extension pop
                    174:   [(oxGet) arg1] extension
                    175: } def
                    176:
                    177: /oxgetsp {
                    178:   /arg1 set
                    179:   [(oxReq) arg1 SM_getsp ] extension pop
                    180:   [(oxReq) arg1 SM_popCMO ] extension pop
                    181:   [(oxGet) arg1] extension
                    182: } def
                    183:
                    184: /oxgeterrors {
                    185:   /arg1 set
                    186:   [(oxReq) arg1 SM_dupErrors ] extension pop
                    187:   [(oxReq) arg1 SM_popCMO ] extension pop
                    188:   [(oxGet) arg1] extension
                    189: } def
                    190:
                    191: /oxmathcap0 {
                    192:   /arg1 set
                    193:   [(oxReq) arg1 SM_mathcap ] extension pop
                    194: } def
                    195: /oxmathcap {
                    196:   /arg1 set
                    197:   [/in-oxmathcap /mypeer /mmm] pushVariables
                    198:   [ /mypeer arg1 def
                    199:     mypeer oxmathcap0
                    200:     mypeer oxpopcmo /mmm set
                    201:     mypeer 10 mmm put  %% set math cap.
                    202:   ] pop
                    203:   popVariables
                    204: } def
                    205: /oxsetmathcap {
                    206:   /arg1 set
                    207:   [/in-oxsetmathcap /mypeer /mymathcap] pushVariables
                    208:   [
                    209:     /mypeer arg1 def
                    210:     /mymathcap     [(cmoMathCap)] extension (array) dc def
                    211:     [(oxReq)
                    212:       mypeer   SM_setMathCap
                    213:       mymathcap
                    214:     ] extension pop
                    215:   ] pop
                    216:   popVariables
                    217: } def
1.23      takayama  218:
1.1       maekawa   219: /oxpopcmo1 {  %% ask of the transmission.
                    220:   /arg1 set
                    221:   [(oxReq) arg1 SM_popCMO ] extension pop
                    222: } def
                    223: /oxpopcmo2 {  %% wait the data.
                    224:   /arg1 set
                    225:   [(oxGet) arg1] extension
                    226: } def
                    227:
                    228:
                    229: /oxpopstring {
                    230:   /arg1 set
                    231:   [(oxReq) arg1 SM_popString ] extension pop
                    232:   [(oxGet) arg1] extension
                    233: } def
                    234:
                    235: /oxrpc {
                    236:   /arg1 set
                    237:   /arg2 set
                    238:   [/ans /ff] pushVariables
                    239:   [
                    240:    /ff arg2 def
                    241:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    242:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
                    243:    } {  } ifelse
                    244:    [(oxReq) ff SM_execute arg1] extension pop
                    245:    [(oxReq) ff SM_popCMO] extension pop
                    246:    [(oxGet) ff] extension /ans set
                    247:    ans etag Etag_error  eq {
                    248:      (Got an error object.) message
                    249:      /arg1 ans def
                    250:    }
                    251:    {  /arg1 ans def
                    252:     } ifelse
                    253:   ] pop
                    254:   popVariables
                    255:   arg1
                    256: } def
                    257:
                    258: /oxexecutestring { oxsubmit } def
                    259: /oxsubmit {
                    260:   /arg1 set
                    261:   /arg2 set
                    262:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    263:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeString) put
                    264:    } {  } ifelse
                    265:   [(oxReq) arg2 SM_execute arg1] extension pop
                    266: } def
                    267:
                    268: /oxexec {
                    269:   /arg1 set
                    270:   /arg2 set
                    271:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    272:                 ox.log [(oxSerial)] extension 1 add ox.mod (executeFunction) put
                    273:    } {  } ifelse
                    274:   [(oxReq) arg2 SM_executeFunction arg1] extension pop
                    275: } def
1.39      takayama  276: /oxexecWithOpt {
                    277:   /arg1 set
                    278:   /arg2 set
                    279:    ox.takelog { ox.log [(oxSerial)] extension ox.mod arg1 put
                    280:                 ox.log [(oxSerial)] extension 1 add ox.mod
                    281:                (executeFunctionWithOptionalArgument) put
                    282:    } {  } ifelse
                    283:   [(oxReq) arg2 SM_executeFunctionWithOptionalArgument arg1] extension pop
                    284: } def
                    285: [(oxexecWithOpt)
                    286:  [
                    287:   $Example: $
                    288:   $oxsm1.ccc (/foo { message message message } def) oxsubmit ;$
                    289:   $oxsm1.ccc (hello) oxpushcmo oxsm1.ccc 1 oxpushcmo oxsm1.ccc [[(opt) 0]] oxpushcmo ;$
                    290:   $oxsm1.ccc (foo) oxexecWithOpt $
                    291:  ]
                    292: ] putUsages
1.1       maekawa   293: /oxsubmit2 {
                    294:   oxexec
                    295: } def
                    296:
                    297: /oxpops {
                    298:   /arg1 set
                    299:   /arg2 set
                    300:   [(oxReq) arg2 SM_pops arg1] extension pop
                    301: } def
                    302:
                    303: /oxsetname {
                    304:   /arg1 set
                    305:   /arg2 set
                    306:   [(oxReq) arg2 SM_setName arg1] extension pop
                    307: } def
                    308:
                    309: /oxevalname {
                    310:   /arg1 set
                    311:   /arg2 set
                    312:   [(oxReq) arg2 SM_evalName arg1] extension pop
                    313: } def
                    314:
                    315:
                    316: /oxreset {
                    317:   /arg1 set
                    318:   [(oxReq) arg1 SM_control_reset_connection] extension pop
1.13      takayama  319: %%  [(oxGetFromControl) arg1 ] extension pop
1.1       maekawa   320:   [(oxGet) arg1] extension message
                    321: } def
                    322:
                    323: /oxisData {
                    324:   /arg1 set
                    325:   [/pp /ff] pushVariables
                    326:   [
                    327:     /ff arg1 def
                    328:     [(oxMultiSelect) [ff] 10] extension /pp set
                    329:     pp message
                    330:     pp 0 get 1 eq {
                    331:       pp 1 get 0 get 1 eq {  %% data is in the data stream.
                    332:         /arg1 [(oxGet) ff] extension def
                    333:       } {/arg1 (no data) def  } ifelse
                    334:     }
                    335:     { /arg1 (no data) def }
                    336:     ifelse
                    337:   ] pop
                    338:   popVariables
                    339:   arg1
                    340: } def
                    341:
                    342: /oxget {
                    343:   oxisData
                    344: } def
                    345:
                    346:
                    347: /oxshutdown {
                    348:   /arg1 set
                    349:   [(fp2fclose) arg1 1 get] extension
                    350:   [(oxReq) arg1 SM_control_kill] extension
                    351:   arg1 0 (closed) put
                    352: } def
                    353:
                    354: /oxgenportfile {
                    355:   [(oxGenPortFile)] extension
                    356: }def
                    357: /oxremoveportfile {
                    358:   [(oxRemovePortFile)] extension
                    359: }def
                    360:
                    361: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.4       takayama  362: /ox_launch_nox {
1.45      takayama  363:   Xm_noX /ox_launch_nox.save set
                    364:   oxNoX
1.4       takayama  365:   ox_launch_aux
1.45      takayama  366:   /Xm_noX ox_launch_nox.save def
1.4       takayama  367: } def
                    368: /ox_launch {
                    369:   ox_launch_aux
                    370: } def
                    371:
                    372: /ox_launch_aux {
                    373:  /arg1 set
                    374:  [/in-launch_nox /pass /peer /data /control /name /machine
                    375:   /your-peer /comm /remoteOpenXMbin /remoteServer /myhost
1.44      takayama  376:   /argNumber /aaa  /myssh
1.4       takayama  377:  ] pushVariables
                    378:  [
1.10      takayama  379:    /aaa arg1 def
                    380:    /argNumber aaa length def
                    381:    /machine aaa 0 get def
                    382:    machine (localhost) eq argNumber 5 lt and {
                    383:      aaa 1 get ox_launch_localhost /your-peer set
                    384:      /LLL.end goto
                    385:    } {
1.44      takayama  386:      /remoteServer aaa 1 get def
                    387:      /name aaa 2 get def
1.10      takayama  388:    } ifelse
1.4       takayama  389:
1.44      takayama  390:    /myssh [(which) (ssh)] oxshell def
                    391:    myssh tag 0 eq {
                    392:      (ssh is not found.) error
                    393:    } { } ifelse
1.45      takayama  394:
                    395:    [(gethostname)] extension /myhost set
                    396:
1.43      takayama  397:    /pass ox_encrypt_104_genPass def
1.4       takayama  398:    /peer [(oxGetPort) myhost] extension def
                    399:    /data peer 1 get toString def
                    400:    /control peer 3 get toString def
                    401:    peer message
1.44      takayama  402:    peer 0 get -1 eq {
                    403:      (Error in oxGetPort) error
                    404:    } { } ifelse
1.45      takayama  405:  [myssh ( -X -f ) machine ( -l ) name ( )
1.44      takayama  406:     [
                    407:      (ox100start ) % it must be on a path of the remote host
                    408:      @@@.quiet { ( -quiet ) } {  } ifelse
                    409:      Xm_noX { ( -nox ) } { } ifelse
                    410:      ( -oxserver ) remoteServer ( -e )
                    411:      ( -reverse )
1.45      takayama  412:      ( -host ) myhost
1.44      takayama  413:      ( -data ) data ( -control ) control   pass [1 2] get
                    414:     ] cat
1.4       takayama  415:  ] cat /comm set
1.44      takayama  416:  (Executing the command : ) messagen comm message
                    417:   comm execve 0 lt {
                    418:     (Fork exec failed) error
                    419:   } { } ifelse
1.45      takayama  420: % ipmask must be 1 to accept from a global address.
                    421:  [(oxCreateClient2) peer 1 , pass 0 get] extension /your-peer set
1.10      takayama  422:  /LLL.end
1.4       takayama  423:  /arg1 your-peer def
                    424:  ] pop
                    425:  popVariables
                    426:  arg1
                    427: } def
                    428:
                    429: [(ox_launch)
1.45      takayama  430: [( [remote-machine remote-ox-server-name remote-login-name] )
1.4       takayama  431:  (  ox_launch  client )
1.10      takayama  432:  $or $
                    433:  $ [(localhost) ox-server-name] ox_launch client$
1.45      takayama  434:  (This command launches ox server via ssh.)
                    435:  (My hostname is set by the function gethostname.)
1.4       takayama  436:  (Example 1: )
1.45      takayama  437:  $ [(orange2-clone) $
                    438:  $  (bin/ox_sm1) (taka)$
                    439:  $ ] ox_launch /@@@.oxsm1 set $
1.4       takayama  440: ]] putUsages
                    441:
                    442: [(ox_launch_nox)
1.45      takayama  443: [( [remote-machine remote-ox-server-name remote-login-name] )
1.4       takayama  444:  (  ox_launch_nox  client )
                    445:  (Example 1: )
1.44      takayama  446:  $ [(tau.math.kobe-u.ac.jp) $
1.45      takayama  447:  $  (bin/ox_math) (taka) $
1.4       takayama  448:  $ ] ox_launch_nox /@@@.oxmath set $
                    449: ]] putUsages
                    450:
1.10      takayama  451: /ox_launch_localhost {
                    452:  /arg1 set
                    453:  [/in-ox_launch_localhost /pass /peer /data /control /oxserver
                    454:   /my-peer] pushVariables
                    455:  [
                    456:     /oxserver arg1 def
1.43      takayama  457:     /pass ox_encrypt_104_genPass def
1.10      takayama  458:     /peer [(oxGetPort) (localhost)] extension def
                    459:     /data peer 1 get toString def
                    460:     /control peer 3 get toString def
                    461:     peer message
1.44      takayama  462:     [
                    463:      oxstart100
                    464:      @@@.quiet { ( -quiet ) } {  } ifelse
                    465:      Xm_noX { ( -nox ) } { } ifelse
                    466:      ( -oxserver ) oxserver ( -e )
                    467:      ( -reverse )
1.43      takayama  468:      ( -data ) data ( -control ) control   pass [1 2] get
1.44      takayama  469:     ] cat execve
1.43      takayama  470:     [(oxCreateClient2) peer 0 pass 0 get] extension /my-peer set
1.10      takayama  471:                          %% 0 means connect from only localhost.
                    472:     /arg1 my-peer def
                    473:  ] pop
                    474:  popVariables
                    475:  arg1
1.5       takayama  476: } def
1.1       maekawa   477:
1.23      takayama  478: /oxrpc2 {
                    479:   /arg2 set
                    480:   /arg1 set
                    481:  [/in-oxrpc2 /pid /n /comm /i] pushVariables
1.12      takayama  482:  [
1.23      takayama  483:    /pid arg1 def
                    484:    /comm arg2 def
                    485:    /n comm length def
                    486:    n 1 sub -1 1 {
                    487:        /i set
                    488:        pid comm i get oxsendcmo
                    489:    } for
                    490:    pid n 1 sub oxsendcmo
                    491:    pid comm 0 get oxexec
                    492:  ] pop
                    493:  popVariables
                    494: } def
                    495:
                    496: [(oxrpc2)
                    497:   [(Remote procedure call by using oxexec)
                    498:    (client [function-name  arg1 arg2 ...] oxrpc2 )
                    499:    (cf. ox-cmo-rpc in Risa/Asir)
                    500:    (Example: )
                    501:    $ (oxasir.sm1) run (x^2-1). fctr $
                    502:    (oxasir.ccc [(igcd) (6).. (10)..] oxrpc2)
                    503:    (oxasir.ccc oxpopcmo :: )
                    504:   ]
                    505: ] putUsages
                    506:
                    507: /oxIsServerReady {
                    508:   /arg1 set
                    509:   [/in-isServerReady /sdata /ans] pushVariables
                    510:   [
                    511:     /sdata arg1 def
                    512:     /ans 0 def
                    513:     sdata isArray {
                    514:      sdata length 1 gt {
                    515:        sdata 0 get (client) eq { /ans 1 def } { } ifelse
                    516:      } { } ifelse
                    517:     } { } ifelse
                    518:     /arg1 ans def
                    519:   ] pop
                    520:   popVariables
                    521:   arg1
                    522: } def
                    523:
                    524: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    525: %%%  Functions to start server by OX-RFC-101
                    526: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    527: /sm1StartControl101 {
                    528:  [/in-sm1connectr /pass /peer /data /control ] pushVariables
                    529:  [
1.43      takayama  530:  /pass ox_encrypt_104_genPass def
1.23      takayama  531:  /peer [(oxGetPort1) (localhost)] extension def
                    532:  /data peer 1 get toString def
                    533:  peer message
                    534:  [(/home/nobuki/OpenXM/src/oxc/oxc)
                    535:   ( -c ) pass ( -h ) (localhost) ( -p ) data ( -x )
                    536:   oxpath.null
                    537:   ( &)] cat system-csh
                    538:
                    539:  [(oxCreateControl_RFC_101) peer 0 pass] extension /oxsm1.ccc set
                    540:                      %% 0 means connect from only localhost.
                    541:  /ox.ccc oxsm1.ccc def
1.34      takayama  542:  (The server is binded to the variable oxsm1.ccc) message-quiet
1.23      takayama  543:   oxsm1.ccc
1.12      takayama  544:  ] pop
                    545:  popVariables
1.14      takayama  546: } def
                    547:
                    548: /sm1StartEngine101 {
1.15      takayama  549:  [/in-sm1StartEngine101 /peer /data /control /engineID] pushVariables
1.14      takayama  550:  [
                    551:     /peer [(oxGetPort1) (localhost)] extension def
                    552:     /data peer 1 get def
1.15      takayama  553:
1.23      takayama  554:     oxsm1.ccc data oxpushcmo
                    555:     oxsm1.ccc (/home/nobuki/OpenXM/bin/ox_sm1) oxpushcmo
                    556:     [(oxPushCMD) oxsm1.ccc SM_control_spawn_server] extension
                    557:     oxsm1.ccc oxpopcmo /engineID set
1.15      takayama  558:     [(oxCreateEngine_RFC_101) peer 0 (Empty) engineID] extension
                    559:     /ox.ddd set
1.34      takayama  560:     (The engine is binded to the variables ox.ddd) message-quiet
1.14      takayama  561:  ] pop
                    562:  popVariables
                    563:  arg1
1.12      takayama  564: } def
1.16      takayama  565:
1.23      takayama  566: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    567: %%% Functions for OX-RFC 103
                    568: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.24      takayama  569: [(chattr) 0 /ctrlC-hook] extension
1.23      takayama  570: /ctrlC-hook {
                    571:   ox103_reset
                    572: } def
                    573: /ox103_disable {
1.24      takayama  574:   [(chattr) 0 /ctrlC-hook] extension
1.23      takayama  575:   /ctrlC-hook {  } def
                    576: } def
                    577:
                    578: [(ox103_reset)
                    579:  [(ox103_reset broadcasts the OX reset to all processes)
                    580:   (cf. ctrlC-hook, register_hander)
                    581: ]] putUsages
                    582: /ox103_reset {
                    583:   [/in-ox103_reset /L /n /i] pushVariables
                    584:   [
                    585:      /L [(oxGetClientList)] extension def
                    586:     (In ox103_reset...) message
1.28      takayama  587:     (killall in oxshell...) message [(killall)] oxshell pop
1.23      takayama  588:      /n L length def
                    589:      0 1 n 1 sub {
                    590:        /i set
                    591:        L i get oxreset
                    592:      } for
                    593:      (Done) message
                    594:   ] pop
                    595:   popVariables
                    596: } def
                    597:
                    598: %%%%%%%
                    599: /ox103_asir_init {
                    600:   /arg1 set
                    601:   [/ttt] pushVariables
                    602:   [
                    603:     /ttt arg1 def
                    604:     %% ttt oxsetmathcap     ttt oxmathcap  %% It is done in asir.init
                    605:     %% Do nothing special for now.
                    606:   ] pop
                    607:   popVariables
                    608: } def
                    609: /ox103_sm1_init {
                    610:   /arg1 set
                    611:   [/ttt] pushVariables
                    612:   [
                    613:     /ttt arg1 def
                    614:     ttt oxsetmathcap
                    615:     ttt oxmathcap
                    616:     ttt ([(parse) (oxrfc103.sm1) pushfile] extension ) oxsubmit
                    617:   ] pop
                    618:   popVariables
                    619: } def
                    620: %%%
                    621:
                    622: /Xm_rfc103_shared [ ] def
                    623:
                    624: [(ox103_set_shared_variable)
                    625:  [(value name 2 ox103_set_shared_variable)
                    626:   (It broadcasts the <<value>> of a shared variable <<name>>)
                    627:   (to all processes.)
                    628:   (cf. Xm_rfc103_shared, )
                    629:   $Example:  (2).. (hoge) 2 ox103_set_shared_variable$
                    630: ]] putUsages
                    631: /ox103_set_shared_variable {
                    632:   /arg0 set  %% Dummy to be called by rpc2. Number of args
                    633:   /arg1 set  %% Name
                    634:   /arg2 set  %% Value,  [Name Value] not [Value Name]
                    635:   [/in-ox103_set_shared_variable /Name /Value
                    636:    /Found /N /i  /L
                    637:   ] pushVariables
                    638:   [
                    639:     /Name arg1 def
                    640:     /Value arg2 def
                    641:     Value message
                    642:     /Found 0 def
                    643:     /N  Xm_rfc103_shared length def
                    644:     0 1 N 1 sub {
                    645:       /i set
                    646:       Xm_rfc103_shared i get 0 get
                    647:       Name eq {
                    648:         Xm_rfc103_shared i [Name Value] put
                    649:         /Found 1 def
                    650:         exit
                    651:       } {  } ifelse
                    652:     } for
                    653:     Found 1 eq { }
                    654:     {
                    655:       Xm_rfc103_shared [Name Value] append
                    656:       /Xm_rfc103_shared set
                    657:     } ifelse
                    658:     /L [(oxGetClientList)] extension def
                    659:     0 1 L length 1 sub {
                    660:       /i set
                    661:       L i get [(ox103_set_shared_variable) Name Value] oxrpc2
                    662:     } for
                    663:
                    664:     (ox103_set_shared_variable: Xm_rfc103_shared=) message
                    665:     Xm_rfc103_shared message
                    666:     %% [(parse) [(/) Name ( ) Value toString ( def )] cat] extension
                    667:     %% Add $ $ when Value is a string.
                    668:
                    669:     /arg1 [Name Value] def
                    670:   ] pop
                    671:   popVariables
                    672:   arg1
                    673: } def
                    674:
                    675: /ox103_test {
                    676:   (x^2-1). fctr
                    677:   oxasir.ccc ( sm1_start(); ) oxexecutestring
                    678:   sm1connectr
                    679: } def
                    680:
                    681: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    682: %%%%%%%%   Starting ox_sm1.
                    683: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    684: /sm1connectr {
                    685:  [/in-sm1connectr /pass /peer /data /control ] pushVariables
                    686:  [
1.25      takayama  687:    [(getServerEnv) (bin/ox_sm1)] extension tag 0 eq {
                    688:      (Server bin/ox_sm1 is not found.) error
                    689:    }{ } ifelse
1.43      takayama  690:  /pass ox_encrypt_104_genPass def
1.23      takayama  691:  /peer [(oxGetPort) (localhost)] extension def
                    692:  /data peer 1 get toString def
                    693:  /control peer 3 get toString def
1.35      takayama  694:  peer message-quiet
1.23      takayama  695:  [
                    696:   oxstart100
1.34      takayama  697:   @@@.quiet { ( -quiet ) } {  } ifelse
1.23      takayama  698:   Xm_noX { ( -nox ) } {  } ifelse
1.46      takayama  699:   Xm_engineLogToStdout { ( -nox -engineLogToStdout ) } { } ifelse %bug.onlyForsm1
1.59    ! takayama  700:   ( -oxserver bin/ox_sm1 -e ) ( -reverse ) @@@.monitor
1.43      takayama  701:   ( -data ) data ( -control ) control   pass [1 2] get
1.23      takayama  702:   ( )] cat execve
1.43      takayama  703:  [(oxCreateClient2) peer 0 pass 0 get] extension /oxsm1.ccc set
1.23      takayama  704:                      %% 0 means connect from only localhost.
1.34      takayama  705:  (The server is binded to the variable oxsm1.ccc) message-quiet
1.23      takayama  706:   /ox.ccc oxsm1.ccc def
                    707:   oxsm1.ccc.init
                    708:   oxsm1.ccc
                    709:  ] pop
                    710:  popVariables
                    711: } def
                    712:
                    713: /oxsm1.ccc.init {
                    714:    oxsm1.ccc ( [(oxPrintMessage) 0] extension pop ) oxsubmit
                    715:    Xm_noX { oxsm1.ccc ( /@@@.Xm_noX 1 def ) oxsubmit }
                    716:           { oxsm1.ccc ( /@@@.Xm_noX 0 def ) oxsubmit } ifelse
                    717:    (Ox103_loaded) boundp
                    718:    { oxsm1.ccc ox103_sm1_init }
                    719:    { }  ifelse
                    720: } def
                    721:
                    722: /sm1connectr-ssh {
                    723: %% It has not yet implemented.
                    724:  /arg1 set
                    725:  [/in-sm1connectr /pass /peer /data /control /name /machine
                    726:   /your-peer /comm
                    727:  ] pushVariables
                    728:  [
                    729:  /machine arg1 0 get def
                    730:  /name arg1 1 get def
                    731:
1.43      takayama  732:  /pass ox_encrypt_104_genPass def
1.23      takayama  733:  /peer [(oxGetPort) myhostname-ssh] extension def
                    734:  /data peer 1 get toString def
                    735:  /control peer 3 get toString def
1.35      takayama  736:  peer message-quiet
1.23      takayama  737:  [(ssh -f ) machine ( -l ) name ( ")
                    738:   oxpath.oxlog.xterm-ssh  oxpath.ox-ssh ( -reverse -ox ) oxpath.oxsm1-ssh
                    739:   ( -host ) myhostname-ssh
1.43      takayama  740:   ( -data ) data ( -control ) control   pass [1 2] get
1.23      takayama  741:   oxpath.null
                    742:   ( ")
                    743:  ] cat /comm set
                    744:  (Executing the command : ) messagen comm message message
                    745:   comm system
                    746:  (sleep 5) system-csh
1.43      takayama  747:  [(oxCreateClient2) peer 1 pass 0 get] extension /your-peer set
1.23      takayama  748:  /arg1 your-peer def
                    749:  ] pop
                    750:  popVariables
                    751:  arg1
                    752: } def
                    753: [(sm1connectr-ssh)
                    754: [([hostname login-name] sm1connectr-ssh client)
                    755:  (Starting oxpath.oxsm1-ssh by the launcher oxpath.ox-ssh on the "hostname".)
1.59    ! takayama  756:  (cf. oxNoX  ox )
1.23      takayama  757:  (Set the following varialbes to appropriate values:)
                    758:  (oxpath.oxlog.xterm-ssh  oxpath.oxsm1-ssh  oxpath.ox-ssh myhostname-ssh )
                    759:  $Example 1: $
                    760:  $  *** Path names on the remote machine dc1.math.kobe-u.ac.jp $
                    761:  $    /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog /usr/X11R6/bin/xterm -icon -e ) def $
                    762:  $    /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
                    763:  $    /oxpath.ox-ssh    (/home/taka/OpenXM/bin/ox) def $
                    764:  $  *** The machine name on which you are running sm1. $
                    765:  $    /myhostname-ssh   (yama.math.kobe-u.ac.jp) def $
                    766:  $         [(dc1.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set  $
                    767:  $Example 2: $
                    768:  $  *** Path names on the remote machine dc2.math.kobe-u.ac.jp $
                    769:  $  *** We will not use X11 debug windows. $
                    770:  $    oxNoX $
                    771:  $    /oxpath.oxlog.xterm-ssh (/home/taka/OpenXM/bin/oxlog ) def $
                    772:  $    /oxpath.oxsm1-ssh (/home/taka/OpenXM/bin/ox_sm1) def $
                    773:  $    /oxpath.ox-ssh    (/home/taka/OpenXM/bin/ox) def $
                    774:  $  *** the machine name on which you are running sm1. $
                    775:  $    /myhostname-ssh   (dc1.math.kobe-u.ac.jp) def $
                    776:  $         [(dc2.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set  $
                    777: ]] putUsages
1.26      takayama  778:
                    779: %%% ntl
                    780: /ntlconnectr {
                    781:  [/in-ntlconnectr /pass /peer /data /control ] pushVariables
                    782:  [
                    783:    [(getServerEnv) (bin/ox_ntl)] extension tag 0 eq {
                    784:      (Server bin/ox_ntl is not found.) error
                    785:    }{ } ifelse
1.43      takayama  786:  /pass ox_encrypt_104_genPass def
1.26      takayama  787:  /peer [(oxGetPort) (localhost)] extension def
                    788:  /data peer 1 get toString def
                    789:  /control peer 3 get toString def
1.35      takayama  790:  peer message-quiet
1.26      takayama  791:  [
                    792:   oxstart100
                    793:   Xm_noX { ( -nox ) } {  } ifelse
                    794:   ( -oxserver bin/ox_ntl -e ) ( -reverse )
1.43      takayama  795:   ( -data ) data ( -control ) control   pass [1 2] get
1.26      takayama  796:   ( )] cat execve
1.43      takayama  797:  [(oxCreateClient2) peer 0 pass 0 get] extension /oxntl.ccc set
1.26      takayama  798:                      %% 0 means connect from only localhost.
1.34      takayama  799:  (The server is binded to the variable oxntl.ccc) message-quiet
1.26      takayama  800: %  oxntl.ccc.init
                    801:    oxntl.ccc
                    802:  ] pop
                    803:  popVariables
                    804: } def
1.23      takayama  805:
                    806: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    807: %%%   Aux functions for ox_asir
                    808: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.57      takayama  809: /ox_asirConnectMethod {
                    810:   asirconnectr /oxasir.ccc set
                    811:   [(getenv) (OX_ASIR_LOAD_FILE)] extension tag 0 eq { 0 }
                    812:   { /oxasir.loadfile [$load("$[(getenv) (OX_ASIR_LOAD_FILE)] extension $");$]
                    813:     cat  def
                    814:     oxasir.ccc oxasir.loadfile oxsubmit
                    815:     oxasir.ccc oxpopcmo } ifelse
                    816: } def
1.23      takayama  817: /oxasir.loadmethod 1 def   %% "..." oxsendcmo (load) ox...
                    818: /oxasir.verbose 0   def
                    819: /oxasir.ccc load isArray
                    820: { }
                    821: { /oxasir.ccc [ ] def } ifelse
                    822: /loadAsirFile {
                    823:   /arg1 set
                    824:   [/in-loadAsirFile /peer /fname] pushVariables
                    825:   [
                    826:     /peer arg1 0 get def
                    827:     /fname arg1 1 get def
                    828:     oxasir.loadmethod  {
                    829:       peer  fname oxsendcmo peer 1 oxsendcmo
                    830:       peer (load) oxexec
1.16      takayama  831:     }{
1.23      takayama  832:       peer  [$load("$ fname $");$] cat oxsubmit
1.16      takayama  833:     }ifelse
1.23      takayama  834:   ] pop
                    835:   popVariables
                    836: } def
                    837: [(loadAsirFile)
                    838: [$[client fname] loadAsirFile   (ox_asir function)$
                    839:  $Load a file into the client$
                    840: ]] putUsages
                    841:
                    842: /set_oxasir.rr_path {
                    843:  [(ostype)] extension  0 get (windows) eq {
                    844:   [(getenv) (OSTYPE)] extension tag 0 eq {
                    845:      /oxasir.rr.name  (oxasir-win.rr) def
                    846:   }{
                    847:    [(getenv) (OSTYPE)] extension (cygwin) eq {
                    848:      /oxasir.rr.name  (oxasir.asir) def
                    849:    }{
                    850:      /oxasir.rr.name  (oxasir-win.rr) def
                    851:    } ifelse
                    852:   } ifelse
                    853:  }{
                    854:      /oxasir.rr.name  (oxasir.asir) def
                    855:  } ifelse
                    856: } def
                    857: set_oxasir.rr_path
                    858: /oxasirpath.asirlib [[(getenv) (OpenXM_HOME)] extension
                    859:                       (/lib/sm1/) oxasir.rr.name] cat  def
                    860: oxasir.verbose {
                    861:  oxasirpath.asirlib message
                    862: } { } ifelse
                    863:
                    864: %% Note.  oxasir.asir is under OpenXM/src/kan96xx/lib/
                    865: %%        oxasir-win.asir is generated under OpenXM/misc/packages/Windows
                    866: %%       They are installed under $OpenXM_HOME/lib/sm1
                    867: %%       Todo:  ox_asir has to understand /cygdrive/c/... on windows-native.
                    868: %%              Since ox_asir is generated by cygwin, it will be OK.
                    869: /asir.init {
                    870:  %% gr and primdec are loaded by .asirrc
                    871:  /asir.init.peer set
                    872:  [(ostype)] extension  0 get (windows) eq {
                    873:   [(getenv) (OSTYPE)] extension tag 0 eq {
                    874:     [asir.init.peer (oxasir-win.rr)] oxasirParseFile
                    875:   }{
                    876:    [(getenv) (OSTYPE)] extension (cygwin) eq {
                    877:      [asir.init.peer  oxasirpath.asirlib] loadAsirFile
                    878:    }{
                    879:      [asir.init.peer  (oxasir-win.rr)] oxasirParseFile
                    880:    } ifelse
                    881:   } ifelse
                    882:  }{
                    883:    [asir.init.peer  oxasirpath.asirlib] loadAsirFile
                    884:  } ifelse
                    885:  asir.init.peer oxmathcap
                    886:  asir.init.peer oxsetmathcap
                    887:  Xm_noX {
                    888:    asir.init.peer (Xm_noX=1;) oxsubmit
                    889:  }{
                    890:    asir.init.peer (Xm_noX=0;) oxsubmit
                    891:  } ifelse
                    892:  (Ox103_loaded) boundp
                    893:  {
                    894:    asir.init.peer ox103_asir_init
                    895:  }{  } ifelse
                    896: } def
                    897:
                    898: [(asir)
                    899:  [(pid [asir-command, asir-arg1, asir-arg2, ...] asir result  (ox_asir function))
                    900:   (Call open asir server. You need to install ox_asir on your system)
                    901:   (to use this function. cf. primadec, fctr, asirconnect2, asirconnectr.)
                    902:   (If you interrupted the computation by typing ctrl-C, type in )
                    903:   (   oxasir.ccc oxreset  ; )
                    904:   (to interrupt the ox_asir server.)
1.38      takayama  905:   (NOTE: all asir-args must belong to the same ring. cf.oxasir.changeRing. )
1.23      takayama  906:   (Example: oxasir.ccc [(fctr) (x^10-1).] asir )
                    907:   (  )
                    908:   (This function requires plugins cmo, socket and ox_asir server. cf. oxasir)
1.38      takayama  909:   (See, http://www.math.kobe-u.ac.jp/Asir on asir)
1.23      takayama  910:  ]
                    911: ] putUsages
                    912:
                    913: /asir {
                    914:   /arg2 set
                    915:   /arg1 set
                    916:   [/pid  /asir-comm /comm /n /i /rr] pushVariables
                    917:   [(CurrentRingp)] pushEnv
                    918:   [
                    919:      /pid arg1 def
                    920:      /asir-comm arg2 def
                    921:      pid tag 6 eq {  } { (Invalid pid. See asir.) error } ifelse
                    922:      pid 0 get (client) eq { } { (Invalid pid. See asir.) error } ifelse
                    923:      asir-comm tag 6 eq {  } { (Invalid argument asir-comm. See asir) error } ifelse
                    924:
                    925:     [ %% Change the current ring if necessary to send a correct OxVlist.
                    926:       asir-comm oxasir.changeRing
                    927:     ] pop
                    928:     %%% Setting OxVlist to tell asir a way to change dist-poly <==> poly.
                    929:     (OxVlist=) getVlist2 toString (;) 3 cat_n /comm set
                    930:      %% comm message
                    931:      pid comm oxsubmit
                    932:      pid (print(OxVlist);) oxsubmit
                    933:
                    934:
                    935:      /n asir-comm length def
                    936:      n 1 sub -1 1 {
                    937:        /i set
                    938:        pid asir-comm i get oxsendcmo
                    939:        pid 1 oxsendcmo pid (ox_dtop) oxexec
                    940:      } for
                    941:      pid n 1 sub oxsendcmo
                    942:      pid asir-comm 0 get oxexec
                    943:
                    944:      pid 1 oxsendcmo pid (ox_ptod) oxexec
                    945:      pid oxpopcmo /arg1 set
                    946:
1.16      takayama  947:
1.23      takayama  948:   ] pop
                    949:   popEnv
                    950:   popVariables
                    951:   arg1
                    952: } def
                    953:
                    954: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    955: %%% Mathematical functions for asir
                    956: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                    957: /oxasir.changeRing {
1.38      takayama  958:   /oxasir.changeRing.rr.prev 0 def
                    959:   oxasir.changeRing2
                    960: } def
                    961: /oxasir.changeRing2 {
1.23      takayama  962:   /arg1 set
1.38      takayama  963:   [/in-oxasir.changeRing2 /f /rr ] pushVariables
1.23      takayama  964:   [
                    965:      /f arg1 def
                    966:      f isArray {
1.38      takayama  967:        f {oxasir.changeRing2} map
1.23      takayama  968:      }{
                    969:        f isPolynomial {
                    970:          f (0). eq { }
1.38      takayama  971:          { f (ring) dc /rr set [(CurrentRingp) rr] system_variable
                    972:            oxasir.changeRing.rr.prev tag 1 eq { }
                    973:            {
                    974:               oxasir.changeRing.rr.prev rr eq  {  }
                    975:               {  (asir : arguments must belong to the same ring.) error } ifelse
                    976:            } ifelse
                    977:            /oxasir.changeRing.rr.prev rr def
                    978:          } ifelse
1.23      takayama  979:        } {  } ifelse
                    980:      } ifelse
                    981:   ] pop
                    982:   popVariables
                    983: } def
                    984:
                    985: /fctr {
                    986:   /arg1 set
                    987:   [/f /comm /vv] pushVariables
                    988:   [(CurrentRingp)] pushEnv
                    989:   [
                    990:     /f arg1 def
                    991:     oxasir.ccc [ ] eq {
                    992:        (Starting ox_asir server.) message
                    993:         ox_asirConnectMethod
                    994:     } {  } ifelse
                    995:
                    996:     f isPolynomial not {
                    997:       /vv f 1 get def
                    998:       vv isArray { /vv vv from_records  def } {  } ifelse
                    999:       /f f 0 get def
                   1000:       [vv ring_of_polynomials 0] define_ring
                   1001:       f . /f set
1.16      takayama 1002:     }{ } ifelse
1.23      takayama 1003:     oxasir.ccc [(fctr) f] asir /arg1 set
1.16      takayama 1004:   ] pop
1.23      takayama 1005:   popEnv
1.16      takayama 1006:   popVariables
                   1007:   arg1
                   1008: } def
                   1009:
1.23      takayama 1010: [(fctr)
                   1011:  [(You need to install ox_asir server to use this function. (ox_asir function))
                   1012:   (f fctr g)
                   1013:   (poly f; array g;)
                   1014:   ([f v] fctr g ;  string f, string or array of string v)
                   1015:   (This function factors the polynomial f over Q.)
                   1016:   ( )
                   1017:   (Example 1:  [(x^10-y^10) (x,y)] fctr ::)
                   1018:   (Example 2:  (x^10-1). fctr ::)
                   1019:   ( )
                   1020:   (If you interrupted the computation by typing ctrl-C, type in )
                   1021:   (   oxasir.ccc oxreset  ; )
                   1022:   (to interrupt the ox_asir server.)
                   1023:   (  )
                   1024:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1025: ]] putUsages
                   1026:
                   1027:
                   1028: [(primadec)
                   1029:  [(You need to install ox_asir server to use this function. (ox_asir function))
                   1030:   ([ ii ] primadec [[q1 p1] [q2 p2] ... ] )
                   1031:   ( array of poly ii; array of poly q1, p1, q2, p2 ...;)
                   1032:   ( q1, q2, ... are primary components of the primary ideal decomposition)
                   1033:   ( of the ideal generated by << ii >>.)
                   1034:   (  )
                   1035:   ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
                   1036:   ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
                   1037:   (<< v >> is an array of independent variables.)
                   1038:   (  )
                   1039:   ([ ii v ] primadec [[q1 p1] [q2 p2] ... ] )
                   1040:   ( array of poly or string ii; array of string v; array of poly q1, p1, q2, p2 ...;)
                   1041:   ( v  is a string of variables separated by , )
                   1042:   (  )
                   1043:   (Example:  [(x,y) ring_of_polynomials 0] define_ring)
                   1044:   (          [ [(x^2-1). (x y).] ] primadec pmat ;)
                   1045:   (  )
                   1046:   (Example:  [ [(x^2-1) (x y)] [(x) (y)]] primadec pmat ;)
                   1047:   (  )
                   1048:   (If you interrupted the computation by typing ctrl-C, type in )
                   1049:   (   oxasir.ccc oxreset  ; )
                   1050:   (to interrupt the ox_asir server.)
                   1051:   (  )
                   1052:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1053: ]] putUsages
                   1054:
                   1055: /primadec {
                   1056:   /arg1 set
                   1057:   [/in-primadec /aa /f  /comm /vvv /r /setarg] pushVariables
                   1058:   [(CurrentRingp)] pushEnv
                   1059:   [
                   1060:     /aa arg1 def
                   1061:     aa isArray { } { (<<array>> primadec) error } ifelse
                   1062:     /setarg 0 def
                   1063:     oxasir.ccc [ ] eq {
                   1064:        (Starting ox_asir server.) message
                   1065:         ox_asirConnectMethod
                   1066:     } {  } ifelse
                   1067:     aa { tag } map /typev set
                   1068:     typev [ ArrayP ] eq
                   1069:     {  /f aa 0 get def
                   1070:        f 0 get (ring) dc /r set
                   1071:        [(CurrentRingp) r] system_variable
                   1072:        /vvv getVariableNames def
                   1073:        /setarg 1 def
                   1074:     } { } ifelse
                   1075:     typev [ArrayP StringP] eq
                   1076:     {  /f aa 0 get def
                   1077:        /vvv [ aa 1 get to_records pop ] def
                   1078:        /setarg 1 def
                   1079:     } { } ifelse
                   1080:     typev [ArrayP ArrayP] eq
                   1081:     {  /f aa 0 get def
                   1082:        /vvv aa 1 get {toString} map def
                   1083:        /setarg 1 def
                   1084:     } { } ifelse
                   1085:     setarg { } { (primadec : Argument mismatch) error } ifelse
                   1086:
                   1087:     f 0 get isPolynomial {
                   1088:       /r f 0 get (ring) dc def
1.42      takayama 1089:       /vvv vvv { r __ } map def
1.23      takayama 1090:     }
                   1091:     {
                   1092:       [vvv from_records ring_of_polynomials 0] define_ring
                   1093:       f { toString . } map /f set
                   1094:       vvv { . } map /vvv set
                   1095:     } ifelse
                   1096:     oxasir.ccc [(primadec) f vvv] asir /arg1 set
1.16      takayama 1097:   ] pop
1.23      takayama 1098:   popEnv
1.16      takayama 1099:   popVariables
                   1100:   arg1
                   1101: } def
1.20      takayama 1102:
1.23      takayama 1103:
                   1104: /getVlist2 {
                   1105:   [/n  /i ] pushVariables
1.20      takayama 1106:   [
1.23      takayama 1107:     /n [(N)] system_variable def
                   1108:     [
                   1109:       0 1 n 1 sub { /i set (x) i (dollar) dc 2 cat_n } for
                   1110:       0 1 n 1 sub { /i set (d) i (dollar) dc 2 cat_n } for
                   1111:     ] /arg1 set
1.20      takayama 1112:   ] pop
                   1113:   popVariables
                   1114:   arg1
                   1115: } def
                   1116:
1.23      takayama 1117: %%%%%%%%%%%%%%%%%%%
                   1118: /getVlist {
                   1119:   [/n  /i ] pushVariables
                   1120:   [
                   1121:     /n [(N)] system_variable def
                   1122:     [
                   1123:       0 1 n 1 sub { /i set [(x) (var) i] system_variable } for
                   1124:       0 1 n 1 sub { /i set [(D) (var) i] system_variable } for
                   1125:     ] /arg1 set
                   1126:   ] pop
                   1127:   popVariables
                   1128:   arg1
                   1129: } def
1.40      takayama 1130:
1.41      takayama 1131: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1.40      takayama 1132: /polygcd {
                   1133:   /arg1 set
                   1134:   [/pp /f /g /comm /vv] pushVariables
                   1135:   [(CurrentRingp)] pushEnv
                   1136:   [
                   1137:     /pp arg1 def
                   1138:     oxasir.ccc [ ] eq {
                   1139:        (Starting ox_asir server.) message
                   1140:         ox_asirConnectMethod
                   1141:     } {  } ifelse
                   1142:
                   1143:     pp isArray {
                   1144:       /f pp 0 get def
                   1145:       /g pp 1 get def
                   1146:       pp length 3 eq {
                   1147:         /vv pp 2 get def
                   1148:         vv isArray { /vv vv from_records  def } {  } ifelse
                   1149:         [vv ring_of_polynomials 0] define_ring
                   1150:         f . /f set
                   1151:         g . /g set
                   1152:       } { } ifelse
                   1153:     }{ (usage: [f g] polygcd) error } ifelse
                   1154:     oxasir.ccc [(gcd) f g] asir /arg1 set
                   1155:   ] pop
                   1156:   popEnv
                   1157:   popVariables
                   1158:   arg1
                   1159: } def
                   1160: [(polygcd)
                   1161:  [( [f g] polygcd r )
                   1162:   ( [f g v] polygcd r)
                   1163:   (Example: [(x^2-1) (x-1) [(x)]] polygcd )
                   1164:  ]
                   1165: ] putUsages
                   1166: /polylcm {
                   1167:   /arg1 set
                   1168:   [/pp /f /g /comm /vv] pushVariables
                   1169:   [(CurrentRingp)] pushEnv
                   1170:   [
                   1171:     /pp arg1 def
                   1172:     oxasir.ccc [ ] eq {
                   1173:        (Starting ox_asir server.) message
                   1174:         ox_asirConnectMethod
                   1175:     } {  } ifelse
                   1176:
                   1177:     pp isArray {
                   1178:       /f pp 0 get def
                   1179:       /g pp 1 get def
                   1180:       pp length 3 eq {
                   1181:         /vv pp 2 get def
                   1182:         vv isArray { /vv vv from_records  def } {  } ifelse
                   1183:         [vv ring_of_polynomials 0] define_ring
                   1184:         f . /f set
                   1185:         g . /g set
                   1186:       } { } ifelse
                   1187:     }{ (usage: [f g] polylcm) error } ifelse
                   1188:     oxasir.ccc [(lcm) f g] asir /arg1 set
                   1189:   ] pop
                   1190:   popEnv
                   1191:   popVariables
                   1192:   arg1
                   1193: } def
                   1194: [(polylcm)
                   1195:  [( [f g] polylcm r )
                   1196:   ( [f g v] polylcm r)
                   1197:   (Example: [(x^2-1) (x-1) [(x)]] polylcm )
                   1198:  ]
                   1199: ] putUsages
1.41      takayama 1200:
                   1201: /asir_red {
                   1202:   /arg1 set
                   1203:   [/pp /f /g /rr /vv] pushVariables
                   1204:   [(CurrentRingp)] pushEnv
                   1205:   [
                   1206:     /pp arg1 def
                   1207:     oxasir.ccc [ ] eq {
                   1208:        (Starting ox_asir server.) message
                   1209:         ox_asirConnectMethod
                   1210:     } {  } ifelse
                   1211:     {
                   1212:      pp isRational {
                   1213:       /f pp numerator def
                   1214:       /g pp denominator def
                   1215:       [[f g]] reduceByAsir /rr set
                   1216:      }{ } ifelse
                   1217:      exit
                   1218:
                   1219:      pp isArray {
                   1220:        /vv pp 2 get def
                   1221:        /f pp 0 get 0 get def
                   1222:        /g pp 0 get 1 get def
                   1223:        [[f toString g toString] vv] reduceByAsir /rr set
                   1224:      } {  } ifelse
                   1225:      exit
                   1226:
                   1227:      (asir_red: not implemented) error exit
                   1228:     } loop
                   1229:
                   1230:     rr 1 get isPolynomial {
                   1231:       rr 0 get rr 1 get div /rr set
                   1232:     }{
                   1233:       rr 1 get (1).. eq {
                   1234:          rr 0 get /rr set
                   1235:       }{
                   1236:          rr 0 get rr 1 get div /rr set
                   1237:       } ifelse
                   1238:     } ifelse
                   1239:
                   1240:     /arg1 rr def
                   1241:   ] pop
                   1242:   popEnv
                   1243:   popVariables
                   1244:   arg1
                   1245: } def
                   1246: [(asir_red)
                   1247:  [(Calling the function red of asir. It simplifies a rational function.)
                   1248:   (cf. cancel)
                   1249:   (Example:  (x^2). (x). div asir_red )
                   1250: ]] putUsages
                   1251:
                   1252: /asir_fctr { fctr } def
                   1253: [(asir_fctr)
                   1254:  [(Calling the factorizer of asir.)
                   1255: ]] putUsages
                   1256:
                   1257: /asir_primadec { primadec } def
                   1258: [(asir_primadec)
                   1259:  [(Calling the primadec of asir.)
                   1260: ]] putUsages
1.20      takayama 1261:
1.23      takayama 1262: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1263: [(chattr) 0 /findIntegralRoots] extension pop
                   1264: /findIntegralRoots {
                   1265:   /arg1 set
                   1266:   [/in-findIntegralRoots /pp ] pushVariables
1.20      takayama 1267:   [
1.23      takayama 1268:     /pp arg1 def
                   1269:     oxasir.ccc [ ] eq {
                   1270:       (Starting ox_asir server.) message
                   1271:        ox_asirConnectMethod
                   1272:     } {  } ifelse
                   1273:     oxasir.ccc oxIsServerReady
                   1274:     { pp findIntegralRoots.oxasir /arg1 set}
                   1275:     { pp findIntegralRoots.slow /arg1 set} ifelse
1.20      takayama 1276:   ] pop
                   1277:   popVariables
                   1278:   arg1
                   1279: } def
1.23      takayama 1280:
                   1281: /findIntegralRoots.oxasir {
1.20      takayama 1282:   /arg1 set
1.23      takayama 1283:   [/in-findIntegralRoots /f /r /g /aa /rlist] pushVariables
                   1284:   [(CurrentRingp) (KanGBmessage)] pushEnv
1.20      takayama 1285:   [
1.23      takayama 1286:     /f arg1 def
                   1287:     [(s) ring_of_polynomials 0] define_ring
                   1288:     f toString . /f set
                   1289:     f fctr rest /g set
                   1290:     g {
                   1291:          0 get /aa set
                   1292:          aa (s). degree 1 eq {
                   1293:            aa (s). coeff 1 get /aa set
                   1294:            aa length 1 eq { 0 }
                   1295:            {  aa 0 get (1). eq {
                   1296:                  0 << aa 1 get (integer) dc >> sub
                   1297:               } { } ifelse
                   1298:            } ifelse
                   1299:          }{ } ifelse
                   1300:      } map
                   1301:     /rlist set
                   1302:     %% rlist ::
                   1303:     [-1000000] rlist join shell rest /arg1 set
1.20      takayama 1304:   ] pop
1.23      takayama 1305:   popEnv
1.20      takayama 1306:   popVariables
                   1307:   arg1
1.21      takayama 1308: } def
                   1309:
1.23      takayama 1310: %%%%%%%%%%%%%   From gbhg3/Int/intw.sm1
                   1311: %% This function needs solv1.asir and ox_asir.
                   1312: %% See solv1.asir for the usage of this function.
                   1313: /rationalRoots2 {
                   1314:   /arg1 set
                   1315:   [/in-rationalRoots2 /aa /f  /comm /vvv /r /setarg
                   1316:    /w /ans
                   1317:   ] pushVariables
                   1318:   [(CurrentRingp) (KanGBmessage)] pushEnv
1.21      takayama 1319:   [
1.23      takayama 1320:     /aa arg1 def
                   1321:     aa isArray { } { (<<array>> rationalRoots2) error } ifelse
                   1322:     /setarg 0 def
                   1323:     oxasir.ccc [ ] eq {
                   1324:        (Starting ox_asir server.) message
                   1325:         ox_asirConnectMethod
                   1326:     } {  } ifelse
                   1327:     aa { tag } map /typev set
                   1328:     typev [ArrayP StringP ArrayP] eq
                   1329:     {  /f aa 0 get def
                   1330:        /vvv [ aa 1 get to_records pop ] def
                   1331:        /w aa 2 get def
                   1332:        /setarg 1 def
                   1333:     } { } ifelse
                   1334:     typev [ArrayP ArrayP ArrayP] eq
                   1335:     {  /f aa 0 get def
                   1336:        /vvv aa 1 get {toString} map def
                   1337:        /setarg 1 def
                   1338:        /w aa 2 get def
                   1339:     } { } ifelse
                   1340:     setarg { } { (rationalRoots2 : Argument mismatch) error } ifelse
                   1341:
                   1342:
                   1343:     [vvv from_records ring_of_polynomials 0] define_ring
                   1344:     f { toString . } map /f set
                   1345:     vvv { . } map /vvv set
                   1346:     w { toString . } map /w set
                   1347:
                   1348:     (rationalRoots2 -- f = ) messagen f messagen
                   1349:     ( , vvv= ) messagen vvv messagen ( , w = ) messagen w message
                   1350:
                   1351:     vvv length 1 eq w 0 get (1). eq and
                   1352:     {
                   1353:        [(KanGBmessage) 0] system_variable
                   1354:        [f] groebner_sugar 0 get /f set
                   1355:        vvv 0 get toString (s) eq {
                   1356:        }{ [[vvv 0 get toString (s)] from_records ring_of_polynomials 0] define_ring}
                   1357:        ifelse
                   1358:        f 0 get toString . [[vvv 0 get toString . (s).]] replace
                   1359:        findIntegralRoots /ans set
                   1360:     }
                   1361:     {
                   1362:       oxasir.ccc [(sm1_rationalRoots2) f vvv w] asir
                   1363:       {(integer) dc} map
                   1364:       /ans set
1.21      takayama 1365:     } ifelse
1.23      takayama 1366:
1.21      takayama 1367:     /arg1 ans def
                   1368:   ] pop
1.23      takayama 1369:   popEnv
                   1370:   popVariables
                   1371:   arg1
                   1372: } def
                   1373: [(rationalRoots2)
                   1374: [(rationalRoots2  (ox_asir function) called from intw.sm1 to analyze integral)
                   1375:  (roots.)
                   1376: ]] putUsages
                   1377:
                   1378: /ptozp_subst  {
                   1379:   /arg1 set
                   1380:   [/in-ptozp_subst /aaa /fff /xxx /vvv /vlist] pushVariables
                   1381:   [(CurrentRingp)] pushEnv
                   1382:   [
                   1383:      /aaa arg1 def
                   1384:      /fff aaa 0 get def
                   1385:      /xxx aaa 1 get toString def
                   1386:      /vvv aaa 2 get {toString ..} map def
                   1387:      aaa length 4 eq {
                   1388:        /vlist aaa 3 get def
                   1389:      } {
                   1390:        /vlist 0 def
                   1391:      } ifelse
                   1392:      oxasir.ccc [ ] eq {
                   1393:         (Starting ox_asir server.) message
                   1394:         ox_asirConnectMethod
                   1395:      } {  } ifelse
                   1396:      fff isPolynomial {
                   1397:        fff (ring) dc ring_def
                   1398:        fff toString /fff set
                   1399:      }
                   1400:      { vlist isInteger { (ptozp_subst: need variable names.) error } {  } ifelse
                   1401:        [vlist ring_of_differential_operators 0] define_ring
                   1402:      } ifelse
                   1403:      oxasir.ccc [(sm1_ptozp_subst) fff . xxx .  vvv] asir
                   1404:      /arg1 set
                   1405:   ] pop
                   1406:   popEnv
                   1407:   popVariables
                   1408:   arg1
                   1409: } def
                   1410:
                   1411: [(ptozp_subst)
                   1412:  [$[f  s  [p q] v] ptozp_subst g   (ox_asir function)$
                   1413:   $It returns ptozp(subst(f,s,p/q))$
                   1414:   $Example 1:  [ (x Dx - s) (s) [2 3] (x,s)] ptozp_subst $
                   1415:   $   ===>     3 x Dx - 2 $
                   1416: ]] putUsages
                   1417:
                   1418: /reduceByAsir  {
                   1419:   /arg1 set
                   1420:   [/in-reduceByAsir /aaa /fff /fff0 /fff1 /vlist] pushVariables
                   1421:   [(CurrentRingp)] pushEnv
                   1422:   [
                   1423:      /aaa arg1 def
                   1424:      /fff aaa 0 get def
                   1425:      aaa length 2 eq {
                   1426:        /vlist aaa 1 get def
                   1427:      } {
                   1428:        /vlist 0 def
                   1429:      } ifelse
                   1430:      oxasir.ccc [ ] eq {
                   1431:         (Starting ox_asir server.) message
                   1432:         ox_asirConnectMethod
                   1433:      } {  } ifelse
                   1434:      fff isArray {
                   1435:        fff length 2 eq {
                   1436:          /fff0 fff 0 get def
                   1437:          /fff1 fff 1 get def
                   1438:        } {
                   1439:          ([ << [f g] >> vlist ] reduceByAsir ) error
                   1440:        } ifelse
                   1441:      } {
                   1442:        ([ << [f g] >> vlist ] reduceByAsir ) error
                   1443:      } ifelse
                   1444:      fff0 isPolynomial fff1 isPolynomial and {
                   1445:        fff0 (ring) dc ring_def
                   1446:        fff0 toString . /fff0 set
                   1447:        fff1 (ring) dc ring_def
                   1448:        fff1 toString . /fff1 set
                   1449:      }
                   1450:      { vlist isInteger { (reduceByAsir: need variable names.) error } {  } ifelse
                   1451:        [vlist ring_of_differential_operators 0] define_ring
                   1452:        fff0 toString . /fff0 set
                   1453:        fff1 toString . /fff1 set
                   1454:      } ifelse
                   1455:      oxasir.ccc [(sm1_rat2plist2) [fff0 fff1]] asir
                   1456:      /arg1 set
                   1457:   ] pop
                   1458:   popEnv
                   1459:   popVariables
                   1460:   arg1
                   1461: } def
                   1462:
                   1463: [(reduceByAsir)
                   1464: [$ [[f g] v] reduceByAsir [ff gg]   (ox_asir function)$
                   1465:  $ [[f g]] reduceByAsir [ff gg]  $
                   1466:  $Example 1: [[(2 x -2) (4 x - 8)] (x)] reduceByAsir $
                   1467:  (Note that there may be a gcd that is more than 1 among the coefficients.)
                   1468: ]] putUsages
                   1469:
                   1470: %% File should be preprocessed by OpenXM/misc/packages/Windows/oxpp
                   1471: %% and ./oxapp --removeSharp
                   1472: [(oxasirParseFile)
                   1473: [$[peer filename] oxasirParseFile $
                   1474:  $File should be preprocessed by OpenXM/misc/packages/Windows/oxpp$
                   1475:  $and ./oxapp --removeSharp $
                   1476: ]] putUsages
                   1477:
                   1478: /oxasirParseFile {
                   1479:   /arg1 set
                   1480:   [/in-oxasirParseFile /fname /sss] pushVariables
                   1481:   [
                   1482:     /fname arg1 1 get def
                   1483:     /peer  arg1 0 get def
                   1484:     fname pushfile /sss set
                   1485:     peer
                   1486:     [$if (1) { ; $ sss (}$)] cat
                   1487:     oxsubmit
                   1488:   ] pop
                   1489:   popVariables
                   1490: } def
                   1491:
                   1492: [(bfct)
                   1493:  [
                   1494:   ( f bfct b )
                   1495:   ( poly f; poly b)
                   1496:   ([f v] bfct b)
                   1497:   ( string f )
                   1498:   ( b is the global b-function of the polynomial f.)
                   1499:   (Example: [(x^3-y^2) (x,y)] bfct fctr :: )
                   1500:   (Algorithm: M.Noro, Mathematical Software, icms 2002, pp.147--157.)
                   1501:   (  )
                   1502:   (If you interrupted the computation by typing ctrl-C, type in )
                   1503:   (   oxasir.ccc oxreset  ; )
                   1504:   (to interrupt the ox_asir server.)
                   1505:   (  )
                   1506:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1507:   (You need to install ox_asir server to use this function. (ox_asir function))
                   1508: ]] putUsages
                   1509:
                   1510: /bfct {
                   1511:   /arg1 set
                   1512:   [/in-bfct /f /comm /vv] pushVariables
                   1513:   [(CurrentRingp)] pushEnv
                   1514:   [
                   1515:     /f arg1 def
                   1516:     oxasir.ccc [ ] eq {
                   1517:        (Starting ox_asir server.) message
                   1518:         ox_asirConnectMethod
                   1519:     } {  } ifelse
                   1520:
                   1521:     f isPolynomial not {
                   1522:       /vv f 1 get def
                   1523:       vv isArray { /vv vv from_records  def } {  } ifelse
                   1524:       /f f 0 get def
                   1525:       [vv ring_of_polynomials 0] define_ring
                   1526:       f . /f set
                   1527:     }{ } ifelse
                   1528:     oxasir.ccc [(oxasir_bfct) f] asir /f set
                   1529:     [(s) ring_of_polynomials 0] define_ring
                   1530:     f . /f set
                   1531:     [f f fctr] /arg1 set
                   1532:   ] pop
                   1533:   popEnv
1.21      takayama 1534:   popVariables
                   1535:   arg1
                   1536: } def
                   1537:
1.23      takayama 1538: [(generic_bfct)
                   1539:  [
                   1540:   ( [ii weight] generic_bfct b )
                   1541:   ( list of poly ii; list weight)
                   1542:   ([ii weight variables] generic_bfct b)
                   1543:   ( list of string ii; list weight; list variables)
                   1544:   ( b is the general b-function of the ideal ii w.r.t the weight.)
                   1545:   (Example: [[(Dx^2) (Dy^2)] [(x) -1 (Dx) 1] [(x) (y)]] generic_bfct :: )
                   1546:   (Notion: Saito, Sturmfels, Takayama, Grobner deformations of hypergeometric differential equaitons)
                   1547:   (Algorithm:  M.Noro, Mathematical Software, icms 2002, pp.147--157.)
                   1548:   (  )
                   1549:   (If you interrupted the computation by typing ctrl-C, type in )
                   1550:   (   oxasir.ccc oxreset  ; )
                   1551:   (to interrupt the ox_asir server.)
                   1552:   (  )
                   1553:   (This function requires plugins cmo, socket and ox_asir server. cf.oxasir)
                   1554:   (You need to install ox_asir server to use this function. (ox_asir function))
                   1555: ]] putUsages
                   1556:
                   1557: /generic_bfct {
                   1558:   /arg1 set
                   1559:   [/in-generic_bfct /aa /f  /comm /vvv0 /n /vvv /ddd /r /setarg
                   1560:    /bf /wt ] pushVariables
                   1561:   [(CurrentRingp)] pushEnv
                   1562:   [
                   1563:     /aa arg1 def
                   1564:     aa isArray { } { (<<array>> generic_bfct) error } ifelse
                   1565:     /setarg 0 def
                   1566:     aa { tag } map /typev set
                   1567:     typev [ ArrayP ArrayP] eq
                   1568:     {  /f aa 0 get def
                   1569:        f 0 tag PolyP { } {  (The first argument must be a list of differential operators. Give the third variable: a list of variables) error } ifelse
                   1570:        f 0 get (ring) dc /r set
                   1571:        [(CurrentRingp) r] system_variable
                   1572:        /wt aa 1 get def
                   1573:
                   1574:        /vvv0 getVariableNames def
                   1575:        /n [(N)] system_variable def
                   1576:        /vvv vvv0 n carN rest reverse rest reverse def
                   1577:        /ddd vvv0 reverse n carN reverse
                   1578:                    rest reverse rest reverse def
                   1579:
                   1580:        /wt wt generic_bfct.aux1 def
                   1581:
                   1582:        /setarg 1 def
                   1583:     } { } ifelse
                   1584:     typev [ArrayP ArrayP StringP] eq
                   1585:     {  /f aa 0 get def
                   1586:        /vvv [ aa 2 get to_records pop ] def
                   1587:        /wt aa 1 get def
                   1588:
                   1589:        /n vvv length def
                   1590:        /ddd vvv { (D) 2 1 roll 2 cat_n } map def
                   1591:
                   1592:        /setarg 1 def
                   1593:     } { } ifelse
                   1594:     typev [ArrayP ArrayP ArrayP] eq
                   1595:     {  /f aa 0 get def
                   1596:        /vvv aa 2 get {toString} map def
                   1597:        /wt aa 1 get def
                   1598:
                   1599:        /n vvv length def
                   1600:        /ddd vvv { (D) 2 1 roll 2 cat_n } map def
                   1601:
                   1602:        /setarg 1 def
                   1603:     } { } ifelse
                   1604:     setarg { } { (generic_bfct : Argument mismatch) error } ifelse
                   1605:
                   1606:     f 0 get isPolynomial {
                   1607:
                   1608:     }
                   1609:     {
                   1610:       [vvv from_records ring_of_differential_operators 0] define_ring
                   1611:       f { toString . } map /f set
                   1612:       vvv { . } map /vvv set
                   1613:       ddd { . } map /ddd set
1.33      takayama 1614:       /wt [vvv ddd wt] generic_bfct.aux1 def
1.23      takayama 1615:     } ifelse
                   1616:     [f vvv ddd wt] message
                   1617:
                   1618:     oxasir.ccc [ ] eq {
                   1619:        (Starting ox_asir server.) message
                   1620:         ox_asirConnectMethod
                   1621:     } {  } ifelse
                   1622:
                   1623:     oxasir.ccc [(oxasir_generic_bfct) f vvv ddd wt] asir /bf set
                   1624:     [(s) ring_of_polynomials 0] define_ring
                   1625:     bf . /bf set
                   1626:     [bf bf fctr] /arg1 set
                   1627:   ] pop
                   1628:   popEnv
                   1629:   popVariables
                   1630:   arg1
1.20      takayama 1631: } def
1.22      takayama 1632:
1.23      takayama 1633: /generic_bfct.aux1 {
1.22      takayama 1634:   /arg1 set
1.33      takayama 1635:   [/in-generic_bfct.aux1 /ii /jj /wt /wtx /wtd /vv /dd /n]  pushVariables
1.23      takayama 1636:   [
1.33      takayama 1637:     arg1 2 get /wt set
                   1638:     arg1 0 get /vv set
                   1639:     arg1 1 get /dd set
                   1640:     /wtx [ 0 1 vv length 1 sub { pop (0).. } for ] def
                   1641:     /n wt length def
                   1642:     0 2 n 1 sub {
                   1643:       /ii set
                   1644:       0 1 vv length 1 sub {
                   1645:         /jj set
                   1646:         wt ii get toString dd jj get toString eq {
                   1647:           wtx jj << wt ii 1 add get >> put
                   1648:         } {  } ifelse
                   1649:       } for
                   1650:     } for
                   1651:
                   1652:     wtx /wt set
1.23      takayama 1653:     wt { dup tag IntegerP eq { (universalNumber) dc } {    } ifelse } map /wt set
                   1654:     wt /arg1 set
                   1655:   ] pop
                   1656:   popVariables
                   1657:   arg1
                   1658: } def
1.30      takayama 1659: /verbose.wgr  1 def
                   1660: %[ ff vv ww ] asir.wgb [gb  init]
                   1661: /asir.wgr {
                   1662:   /arg1 set
                   1663:   [/in-asir.gb  /ff /vv /ww /vvx /vvd /avv /comm /wvec /i] pushVariables
                   1664:   [
                   1665:     /ff arg1 0 get def
                   1666:     /vv arg1 1 get def
                   1667:     /ww arg1 2 get def
                   1668:
                   1669:     oxasir.ccc [ ] eq {
                   1670:        (Starting ox_asir server.) message
                   1671:         ox_asirConnectMethod
                   1672:     } {  } ifelse
                   1673:
                   1674:     vv isArray {
                   1675:       vv from_records /vv set
                   1676:     } {  } ifelse
                   1677:     oxasir.ccc [(dp_gr_print) (2)..] asir
                   1678:     [vv to_records pop] /vvx set
                   1679:     vvx { toString (D) 2 1 roll 2 cat_n  } map /vvd set
                   1680:
                   1681:     [
                   1682:       0 1 vvx length 1 sub {
                   1683:         /i set
                   1684:        vvx i get
                   1685:        0 ww i get  sub
                   1686:        vvd i get
                   1687:        ww i get
                   1688:       } for
                   1689:      ] /wvec set
                   1690:
                   1691:     [vv ring_of_differential_operators
                   1692:      [wvec] weight_vector
                   1693:     0] define_ring
                   1694:
1.38      takayama 1695:     ff { toString . dehomogenize homogenize } map /ff set
1.30      takayama 1696:     vvx { . } map /vvx set %%ex  [x,y]
                   1697:     vvd { . } map /vvd set %%ex  [Dx,Dy]
                   1698:     vvx vvd join [(h).] join /avv set
                   1699:
                   1700:     verbose.wgr {
                   1701:     (Asir (-w,w) gb in the Weyl algebra) message
                   1702:     (wvec=) messagen wvec message
                   1703:     (ff=) messagen ff message
                   1704:     (avv=) messagen avv message
                   1705:     } {  } ifelse
                   1706:
1.32      takayama 1707:     [$dp_weyl_set_weight(newvect($  ww length toString $,$
1.30      takayama 1708:      ww toString $));$ ] cat /comm set
                   1709:
                   1710:     verbose.wgr {
                   1711:       comm message
                   1712:     } { } ifelse
                   1713:
                   1714:     oxasir.ccc comm oxsubmit ;
                   1715:
                   1716:     oxasir.ccc [(dp_weyl_gr_main) ff avv (0).. (1).. (11)..] asir
                   1717:     /arg1 set
                   1718:   ] pop
                   1719:   popVariables
                   1720:   arg1
                   1721: } def
                   1722: [(asir.wgr)
                   1723: [([ ff vv ww ] asir.wgr g)
1.31      takayama 1724:  $It computes the (-ww,ww) Grobner basis of ff in the homogenized Weyl algebra.$
1.30      takayama 1725:  (Homogenization is automatically done.)
                   1726:  $Example 1: $
                   1727:  $ [ [(x*Dx+y*Dy-1)  (Dx*Dy)] $
                   1728:  $   (x,y)  $
                   1729:  $   [1 2 ] ] asir.wgr   $
                   1730: ]] putUsages
                   1731:
1.56      takayama 1732: /print_tex_form.aux {
                   1733:   /arg1 set
                   1734:   [/f /ans] pushVariables
                   1735:   [
                   1736:      arg1 /f set
                   1737:      [(UseDsmall)] system_variable /vv set
                   1738:      [(UseDsmall) 1] system_variable
                   1739:      f isArray {
                   1740:        f { print_tex_form.aux } map /ans set
                   1741:      }{
                   1742:        [$quote($, f toString, $) $] cat /ans set
                   1743:      } ifelse
                   1744:     [(UseDsmall) vv] system_variable
                   1745:      ans /arg1 set
                   1746:   ] pop
                   1747:   popVariables
                   1748:   arg1
                   1749: } def
                   1750:
                   1751: /print_tex_form {
                   1752:   /arg1 set
                   1753:   [/f /comm /vv] pushVariables
                   1754:   [(CurrentRingp)] pushEnv
                   1755:   [
                   1756:     /f arg1 def
                   1757:     oxasir.ccc [ ] eq {
                   1758:        (Starting ox_asir server.) message
                   1759:         ox_asirConnectMethod
                   1760:     } {  } ifelse
                   1761:
                   1762:     oxasir.ccc ( quotetotex_env("conv_rule",7); ) oxsubmit
                   1763:     oxasir.ccc oxpopcmo ;
                   1764:
                   1765:     f print_tex_form.aux /f set
                   1766:     [$ print_tex_form($,  f $); $] cat /comm set
                   1767:     oxasir.ccc comm oxsubmit
                   1768:     oxasir.ccc oxpopcmo /arg1 set
                   1769:   ] pop
                   1770:   popEnv
                   1771:   popVariables
                   1772:   arg1
                   1773: } def
                   1774:
                   1775: [(print_tex_form)
                   1776: [ (obj print_tex_form str)
                   1777: ]] putUsages
1.23      takayama 1778: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1779: %%% functions to start ox_asir
                   1780: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1781: /asirconnectr {
                   1782:  [/in-asirconnectr /pass /peer /data /control /oxasir] pushVariables
                   1783:  [
1.25      takayama 1784:    [(getServerEnv) (bin/ox_asir)] extension tag 0 eq {
                   1785:      (Server bin/ox_sm1 is not found.) error
                   1786:    }{ } ifelse
                   1787:
1.43      takayama 1788:  /pass ox_encrypt_104_genPass def
1.23      takayama 1789:  /peer [(oxGetPort) (localhost)] extension def
                   1790:  /data peer 1 get toString def
                   1791:  /control peer 3 get toString def
1.35      takayama 1792:  peer message-quiet
1.22      takayama 1793:  [
1.23      takayama 1794:   oxstart100
1.34      takayama 1795:   @@@.quiet { ( -quiet ) } {  } ifelse
1.23      takayama 1796:   Xm_noX { ( -nox ) } {  } ifelse
1.46      takayama 1797:   Xm_engineLogToStdout { ( -nox -engineLogToStdout ) } { } ifelse %bug.onlyForasir
1.23      takayama 1798:   ( -oxserver bin/ox_asir -e ) ( -reverse )
1.43      takayama 1799:   ( -data ) data ( -control ) control   pass [1 2] get
1.23      takayama 1800:   ( )] cat execve
1.43      takayama 1801:  [(oxCreateClient2) peer 0 pass 0 get] extension /oxasir.ccc set
1.23      takayama 1802:                      %% 0 means connect from only localhost.
                   1803:  oxasir.ccc asir.init
                   1804:  /arg1 oxasir.ccc def
1.22      takayama 1805:  ] pop
                   1806:  popVariables
1.23      takayama 1807:  arg1
1.22      takayama 1808: } def
                   1809:
1.23      takayama 1810: [(asirconnectr)
                   1811:  [(asirconnectr server  (ox_asir function))
                   1812:   (array server;)
                   1813:   (Example: asirconnectr /oxasir.ccc set)
                   1814: ]] putUsages
                   1815:
                   1816: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1817: %%% functions to start ox_k0
                   1818: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   1819: /oxk0.ccc load isArray
                   1820: { }
                   1821: { /oxk0.ccc [ ] def } ifelse
1.22      takayama 1822:
1.23      takayama 1823: /ox.k0.init {
                   1824:   % oxk0.ccc ( Print("Hello!"); ) oxsubmit
                   1825:   Xm_noX { oxk0.ccc (Xm_noX=true;) oxsubmit }
                   1826:          { oxk0.ccc (Xm_noX=false;) oxsubmit } ifelse
                   1827: } def
1.1       maekawa  1828:
1.23      takayama 1829: /k0connectr {
                   1830:  [/in-k0connectr /pass /peer /data /control ] pushVariables
                   1831:  [
1.25      takayama 1832:    [(getServerEnv) (bin/ox_k0)] extension tag 0 eq {
                   1833:      (Server bin/ox_sm1 is not found.) error
                   1834:    }{ } ifelse
                   1835:
1.43      takayama 1836:  /pass ox_encrypt_104_genPass def
1.23      takayama 1837:  /peer [(oxGetPort) (localhost)] extension def
                   1838:  /data peer 1 get toString def
                   1839:  /control peer 3 get toString def
1.35      takayama 1840:  peer message-quiet
1.23      takayama 1841:  [
                   1842:   oxstart100
                   1843:   Xm_noX { ( -nox ) } {  } ifelse
                   1844:   ( -oxserver bin/ox_k0 -e ) ( -reverse )
1.43      takayama 1845:   ( -data ) data ( -control ) control   pass [1 2] get
1.23      takayama 1846:   ( )] cat execve
1.43      takayama 1847:  [(oxCreateClient2) peer 0 pass 0 get] extension /oxk0.ccc set
1.23      takayama 1848:                      %% 0 means connect from only localhost.
1.34      takayama 1849:  (The server is binded to the variable oxk0.ccc) message-quiet
1.23      takayama 1850:   ox.k0.init
                   1851:   /arg1 oxk0.ccc def
                   1852:  ] pop
                   1853:  popVariables
                   1854:  arg1
                   1855: } def
1.29      takayama 1856: /@@@polymake.k0.ccc [ ] def
                   1857:
1.37      takayama 1858: /ox_server_mode {
                   1859:   /:: {   } def  % do nothing
1.43      takayama 1860: } def
                   1861:
                   1862: %% Encryption methods
                   1863: /ox_encrypt_104.NONE  0 def
                   1864: /ox_encrypt_104.FILE  1 def
                   1865: /ox_encrypt_104.RSA   2 def
                   1866: /@@@.ox_encrypt_104.method  ox_encrypt_104.NONE  def
                   1867: /ox_encrypt_104.1 {
                   1868:   /arg1 set
                   1869:   [/sss /rrr] pushVariables
                   1870:   [
                   1871:     /sss arg1 def
                   1872:     sss toString /sss set
                   1873:     {
                   1874:       @@@.ox_encrypt_104.method  ox_encrypt_104.NONE  eq {
                   1875:         /rrr [sss] def
                   1876:         exit
                   1877:       } {  } ifelse
                   1878:       (The encryption method has not yet been implemented.) error
                   1879:     } loop
                   1880:     /arg1 rrr def
                   1881:   ] pop
                   1882:   popVariables
                   1883:   arg1
                   1884: } def
1.37      takayama 1885:
1.43      takayama 1886: %<
                   1887: % Usages: ox_encrypt_104_genPass
                   1888: %  [[ c-pass d-pass ] [c-pass-encrypted d-pass-encrypted ox-command-str ] ...]
                   1889: %>
                   1890: /ox_encrypt_104_genPass {
                   1891:   [/sss /p1 /p2 /e1 /e2 /rrr] pushVariables
                   1892:   [
                   1893:     /r1 [(oxGenPass)] extension def
                   1894:     /r2 [(oxGenPass)] extension def
                   1895:     r1 ox_encrypt_104.1 /e1 set
                   1896:     r2 ox_encrypt_104.1 /e2 set
                   1897:     {
                   1898:       @@@.ox_encrypt_104.method  ox_encrypt_104.NONE  eq {
                   1899:         [( -passControl ) e1 0 get ( -passData ) e2 0 get ( )] cat /sss set
                   1900:         [[r1 r2] [e1 0 get , e2 0 get , sss]] /rrr set
                   1901:         exit
                   1902:       } { } ifelse
                   1903:       (The encryption method has not been implemented.) error
                   1904:     } loop
                   1905:     rrr /arg1 set
                   1906:   ] pop
                   1907:   popVariables
                   1908:   arg1
1.47      takayama 1909: } def
                   1910:
                   1911: [[(lines),[10,-1]],
                   1912:  [(where),[(shell), (length)]],
1.54      takayama 1913:  [(reason_of_error), (invalid argument)],
                   1914:  [(asir_where),[[(toplevel),10],[(string),(foo),3],[(string),(hoge),-1]]
1.58      takayama 1915: ]]
1.47      takayama 1916: /i1 set
                   1917: %% /translateErrorForCfep.sampleInput  set
                   1918:
                   1919: [(translateErrorForCfep)
                   1920: [
                   1921:  (translate the error packet defined in ox-rfc-103 into series of commands for cfep.)
                   1922: ]
                   1923: ] putUsages
                   1924: /translateErrorForCfep {
                   1925:   /arg1 set
1.54      takayama 1926:   [/ee /ans /tt /lf /i /nn /ee.orig /tt2] pushVariables
1.47      takayama 1927:   [
                   1928:    /ee arg1 def
                   1929:    {
                   1930:     ee etag 257 eq {
1.53      takayama 1931:       ee (body) dc 1 get /ee set  ee /ee.orig set
1.47      takayama 1932:       ee length 3 gt {
                   1933:         ee 3 get /ee set
1.53      takayama 1934:         ee [[(reason_of_error) ee.orig 2 get toString ]] join /ee set
1.52      takayama 1935:       }{
                   1936:         %% nn should be 2, [serial, common error no, short message]
                   1937:         ee length /nn set
                   1938:         nn 0 gt {
                   1939:           /ee [(reason_of_error) ee nn 1 sub get toString ] def
                   1940:         } {  /ee [ ] def } ifelse
                   1941:       } ifelse
1.47      takayama 1942:     }{ } ifelse
                   1943:     ee etag 6 eq not { /ans [ ] def exit } { } ifelse
                   1944:     /ans [ ] def
1.50      takayama 1945:     /lf 12 (string) dc def  % line feed.
1.51      takayama 1946:     ans [(Begin) nl lf] join /ans set
1.47      takayama 1947:
                   1948:     ee (lines) getNode  /tt set
                   1949:     tt tag 0 eq {
                   1950:       ee (parse_error_at) getNode /tt set
                   1951:     } { } ifelse
                   1952:     tt isArray {
                   1953:       tt length 0 gt {
                   1954:          ans
1.50      takayama 1955:          [(gotoLine, ) tt 0 get toString  nl lf] join /ans set
1.47      takayama 1956:       }{ } ifelse
                   1957:     } { } ifelse
                   1958:     tt isInteger {
1.50      takayama 1959:       [(gotoLine, ) tt toString  nl lf] join /ans set
1.47      takayama 1960:     } { } ifelse
                   1961:
                   1962:     ee (where) getNode  /tt set
                   1963:     tt isArray {
                   1964:       tt length 0 gt {
                   1965:          ans
1.50      takayama 1966:          [(findAndSelect, ) tt 0 get (string) dc  nl lf] join /ans set
1.47      takayama 1967:       }{ } ifelse
1.51      takayama 1968:       1 1, tt length 1 sub {
                   1969:         /i set
                   1970:          ans
                   1971:          [(findAndShow, ) tt i get (string) dc  nl lf] join /ans set
                   1972:       } for
1.47      takayama 1973:     } { } ifelse
                   1974:
                   1975:     ee (reason_of_error) getNode  /tt set
                   1976:     tt tag 0 eq {
                   1977:       ee (reason_of_parse_error) getNode /tt set
                   1978:     } { } ifelse
                   1979:     tt tag 0 eq not {
1.52      takayama 1980:       ans [(printErrorMessage, )
                   1981:            tt (string) dc localizedString  % for translation.
                   1982:            nl lf] join /ans set
1.47      takayama 1983:     }{ } ifelse
1.53      takayama 1984:
1.54      takayama 1985: %% Keyword from asir.  [(asir_where) [[(toplevel),3],[(string),(foo),3],[(filename),(func),4]]]
                   1986:     ee (asir_where) getNode  /tt set
                   1987:     tt (toplevel) getNode /tt2 set
                   1988:     tt2 isInteger, tt2 tag 15 eq, or {
                   1989:       ans [(gotoLine, ) tt2 toString  nl lf] join /ans set
1.53      takayama 1990:     } { } ifelse
1.54      takayama 1991:     tt isArray {
                   1992:       0 1 tt length 1 sub {
                   1993:          /i set
                   1994:         tt i get /tt2 set
                   1995:         tt2 (string) getNode tag 0 eq { }
                   1996:         {
                   1997:            tt2 length 2 gt {
                   1998:               tt2 2 get /tt2 set
                   1999:               tt2 isInteger, tt2 tag 15 eq, or {
                   2000:                 tt2 toString .. /tt2 set
                   2001:                 tt2 (-1).. gt, tt2 (4294967295).. lt, and {
                   2002:                   ans [(gotoLine, ) tt2 toString  nl lf] join /ans set
                   2003:                 } { } ifelse
                   2004:               } { } ifelse
                   2005:            }{ } ifelse
                   2006:         } ifelse
                   2007:       } for
                   2008:     }{ } ifelse
1.47      takayama 2009:
                   2010:     exit
                   2011:    } loop
1.51      takayama 2012:    ans [(End) nl lf] join /ans set
1.47      takayama 2013:    ans cat /arg1 set
                   2014:   ] pop
                   2015:   popVariables
                   2016:   arg1
                   2017: } def
                   2018:
                   2019: /oxclearstack {
                   2020:   /arg1 set
                   2021:   [/cl /n] pushVariables
                   2022:   [
                   2023:     /cl arg1 def
                   2024:     cl oxgetsp /n set
                   2025:     n tag 0 eq { /n 0 def } { } ifelse
                   2026:     n tag 15 eq { n (integer) dc /n set } { } ifelse
1.55      takayama 2027:     cl n oxpops
1.47      takayama 2028:   ] pop
                   2029:   popVariables
                   2030: } def

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