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

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

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