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

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

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