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

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

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