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

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

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