[BACK]Return to m.oxweave CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / packages / doc

Annotation of OpenXM/src/asir-contrib/packages/doc/m.oxweave, Revision 1.2

1.2     ! takayama    1: /* $OpenXM: OpenXM/src/asir-contrib/packages/doc/m.oxweave,v 1.1 2003/05/19 05:15:52 takayama Exp $ */
1.1       takayama    2: /* Use oxweave to generate documents on this source code
                      3:    Use iso-2022 to write this file. No default use of GL and GR is allowed.
                      4: */
                      5:
                      6:
                      7: /*&C-texi
                      8: @c DO NOT EDIT THIS FILE   oxmath.texi  It is automatically generated
                      9: @c from asir-contrib/packages/doc/m.oxweave
                     10: @node Mathematica Functions,,, Top
                     11: */
                     12: /*&jp-texi
                     13: @chapter Mathematica $BH!?t(B
                     14:
                     15: $B$3$N@a$G$O(B Mathematica $B$N(B ox $B%5!<%P(B @code{ox_math}
                     16: $B$H$N%$%s%?%U%'!<%94X?t$r2r@b$9$k(B.
                     17: $B$3$l$i$N4X?t$O%U%!%$%k(B  @file{m} $B$GDj5A$5$l$F$$$k$N$G$3$N%U%!%$%k$r(B
                     18: @code{load("m")$} $B$G$3$N%U%!%$%k$r%m!<%I$7$F$+$i;HMQ$7$J$$$H$$$1$J$$(B.
                     19: @file{m} $B$O(B @file{$(OpenXM_HOME)/lib/asir-contrib} $B$K$"$k(B.
                     20:
                     21: $BCm0U(B: @code{ox_reset} $B$OF0$+$J$$(B.
                     22: */
                     23: /*&eg-texi
                     24: @chapter Mathematica Functions
                     25:
                     26: This chapter describes  interface functions for
                     27: Mathematica ox server @code{ox_math}.
                     28: These interface functions are defined in the file @file{m}.
                     29: You need to load the file before using the interface functions.
                     30: by the command @code{load("m")$}.
                     31: The file @file{m} is at @file{$(OpenXM_HOME)/lib/asir-contrib}.
                     32:
                     33: Note: @code{ox_reset} does not work.
                     34: */
                     35: /*&C-texi
                     36: @example
                     37: @include opening.texi
                     38: [258] load("m")$
1.2     ! takayama   39: m Version 19991113. mathematica.start, mathematica.tree_to_string, mathematica.n_Eigenvalues
        !            40: [259] mathematica.start();
1.1       takayama   41: ox_math has started.
                     42: ox_math: Portions copyright 2000 Wolfram Research, Inc.
                     43: See OpenXM/Copyright/Copyright.mathlink  for details.
                     44: 0
1.2     ! takayama   45: [260] mathematica.n_Eigenvalues([[1,2],[4,5]]);
1.1       takayama   46: [-0.464102,6.4641]
                     47: @end example
                     48: */
                     49:
                     50: /*&C-texi
                     51: @noindent
                     52: @code{Mathematica} is the trade mark of Wolfram Research Inc.
                     53: This package requires Mathmatica Version 3.0, so you need
                     54: Mathematica to make this package work.
                     55: See @code{http://www.wolfram.com}.
                     56: The copyright and license agreement of the mathlink is put at
                     57: @code{OpenXM/Copyright/Copyright.mathlink}
                     58: Note that the licence prohibits to connect to a mathematica
                     59: kernel via the internet.
                     60:
                     61: @noindent
                     62: Author of @code{ox_math}: Katsuyoshi Ohara,
                     63: @code{ohara@@air.s.kanazawa-u.ac.jp}.
                     64: */
                     65:
                     66:
                     67: /*&jp-texi
                     68: @section $BH!?t0lMw(B
                     69: */
                     70: /*&eg-texi
                     71: @section Functions
                     72: */
                     73: /*&jp-texi
                     74: @menu
1.2     ! takayama   75: * mathematica.start::
1.1       takayama   76: @end menu
1.2     ! takayama   77: @node mathematica.start,,, Mathematica Functions
        !            78: @subsection @code{mathematica.start}
        !            79: @findex mathematica.start
1.1       takayama   80: @table @t
1.2     ! takayama   81: @item mathematica.start()
1.1       takayama   82: ::  Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B.
                     83: @end table
                     84:
                     85: @table @var
                     86: @item return
                     87: $B@0?t(B
                     88: @end table
                     89:
                     90: @itemize @bullet
                     91: @item Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B.
                     92:     $B5/F0$5$l$?(B @code{ox_math} $B$N<1JLHV9f$rLa$9(B.
                     93: @item @code{Xm_noX =1} $B$H$7$F$*$/$H(B, @code{ox_math} $BMQ$N(B debug window $B$,3+$+$J$$(B.
                     94: @item $B<1JLHV9f$O(B @code{M_proc} $B$K3JG<$5$l$k(B.
                     95: @end itemize
                     96: */
                     97: /*&eg-texi
                     98: @menu
1.2     ! takayama   99: * mathematica.start::
1.1       takayama  100: @end menu
1.2     ! takayama  101: @node mathematica.start,,, Mathematica Functions
        !           102: @subsection @code{mathematica.start}
        !           103: @findex mathematica.start
1.1       takayama  104: @table @t
1.2     ! takayama  105: @item mathematica.start()
1.1       takayama  106: ::  Start  @code{ox_math} on the localhost.
                    107: @end table
                    108:
                    109: @table @var
                    110: @item return
                    111: Integer
                    112: @end table
                    113:
                    114: @itemize @bullet
                    115: @item Start @code{ox_math} on the localhost.
                    116:     It returns the descriptor of @code{ox_math}.
                    117: @item Set @code{Xm_noX = 1} to start @code{ox_math} without a debug window.
                    118: @item The descriptor is stored in the variable @code{M_proc}.
                    119: @end itemize
                    120: */
                    121: /*&C-texi
                    122: @example
1.2     ! takayama  123: P = mathematica.start()
1.1       takayama  124: @end example
                    125: */
                    126: /*&jp-texi
                    127: @table @t
                    128: @item $B;2>H(B
                    129: @code{ox_launch}
                    130: @end table
                    131: */
                    132: /*&eg-texi
                    133: @table @t
                    134: @item Reference
                    135: @code{ox_launch}
                    136: @end table
                    137: */
                    138:
                    139: /*&jp
                    140:   $B0J2<$G(BMathematica $B$r8F$V$?$a$NJd=u4X?t$rDj5A$9$k(B.
                    141: */
                    142:
                    143: /*&jp-texi
                    144: @menu
1.2     ! takayama  145: * mathematica.tree_to_string::
1.1       takayama  146: @end menu
1.2     ! takayama  147: @node mathematica.tree_to_string,,, Mathematica Functions
        !           148: @subsection @code{mathematica.tree_to_string}
        !           149: @findex mathematica.tree_to_string
1.1       takayama  150: @table @t
1.2     ! takayama  151: @item mathematica.tree_to_string(@var{t})
1.1       takayama  152: ::  ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B @var{t} $B$r(B @code{asir} $B7A<0$K(B
                    153: $B$J$*$9(B.
                    154: @end table
                    155:
                    156: @table @var
                    157: @item return
                    158: $BJ8;zNs(B
                    159: @item t
                    160: $B%j%9%H(B
                    161: @end table
                    162: @itemize @bullet
                    163: @item
                    164: t $B$O(B @code{ox_math} $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B.
                    165: @item
                    166: ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B @var{t} $B$r(B @code{asir} $B7A<0$K(B
                    167: $B$J$*$9(B.
                    168: @item
                    169:    @var{t} $B$r$J$k$Y$/(B asir $B$,M}2r$G$-$k7A$G$N(B, $BA0CV$^$?$OCfCV5-K!(B
                    170:    $B$NJ8;zNs$KJQ49$9$k(B.
                    171:    @var{t}$B$N@hF,MWAG$NJ8;zNs$,%-!<%o!<%I$G$"$k$,(B, $B$=$NJ8;z$,JQ49%F!<%V%k$K$J$$(B
                    172:    $B$H$-$O(B, @code{m_} $B$r%-!<%o!<%I$N@hF,$K$D$1$F(B, $B4X?t8F=P7A<0$NJ8;zNs$X(B
                    173:    $B$+$($k(B.
                    174: @end itemize
                    175: */
                    176: /*&eg-texi
                    177: @menu
1.2     ! takayama  178: * mathematica.tree_to_string::
1.1       takayama  179: @end menu
1.2     ! takayama  180: @node mathematica.tree_to_string,,, Mathematica Functions
        !           181: @subsection @code{mathematica.tree_to_string}
        !           182: @findex mathematica.tree_to_string
1.1       takayama  183: @table @t
1.2     ! takayama  184: @item mathematica.tree_to_string(@var{t})
1.1       takayama  185: ::  translates Mathematica tree data  @var{t} into a string that can
                    186: be understandable by @code{asir} as far as possible.
                    187: @end table
                    188:
                    189: @table @var
                    190: @item return
                    191: String
                    192: @item t
                    193: List
                    194: @end table
                    195: @itemize @bullet
                    196: @item
                    197: t is a Mathematica tree data which is generated by @code{ox_math}.
                    198: @item
                    199: This function
                    200:  translates Mathematica tree data  @var{t} into a string that may
                    201: be understandable by @code{asir}.
                    202: @item
                    203:    This function translates @var{t} into a prefix or infix expression that may be understantable by @code{asir}.
                    204:    The first element of the list @var{t}
                    205:   is a key word string of the Mathematica object.
                    206:   If this function recognizes the key word, it translates @code{t} into
                    207:   the form that can be understandable by @code{asir}.
                    208:   If it cannot recognizes the key word, it translates @code{t} into
                    209:   a function call with the function name
                    210:   @code{m_(the key word)}.
                    211: @end itemize
                    212: */
                    213: /*&C-texi
                    214: @example
1.2     ! takayama  215: [267] mathematica.start();
1.1       takayama  216: 0
                    217: [268] ox_execute_string(0,"Expand[(x-1)^2]");
                    218: 0
                    219: [269] A=ox_pop_cmo(0);
                    220: [Plus,1,[Times,-2,x],[Power,x,2]]
1.2     ! takayama  221: [270] mathematica.tree_to_string(A);
1.1       takayama  222: (1)+((-2)*(x))+((x)^(2))
                    223: [271] eval_str(@@);
                    224: x^2-2*x+1
                    225: @end example
                    226: */
                    227: /*&C-texi
                    228: @example
1.2     ! takayama  229: [259] mathematica.tree_to_string(["List",1,2]);
1.1       takayama  230: [1 , 2]
1.2     ! takayama  231: [260] mathematica.tree_to_string(["Plus",2,3]);
1.1       takayama  232: (2)+(3)
1.2     ! takayama  233: [261] mathematica.tree_to_string(["Complex",2.3,4.55]);
        !           234: mathematica.complex(2.3 , 4.55)
        !           235: [362] mathematica.tree_to_string(["Plus",["Complex",1.2,3.5],1/2]);
        !           236: (mathematica.complex(1.2 , 3.5))+(1/2)
1.1       takayama  237: [380] eval_str(@@);
                    238: (1.7+3.5*@i)
                    239: @end example
                    240: */
                    241: /*&jp-texi
                    242: @table @t
                    243: @item $B;2>H(B
1.2     ! takayama  244: @code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr}
1.1       takayama  245: @end table
                    246: */
                    247: /*&eg-texi
                    248: @table @t
                    249: @item Reference
1.2     ! takayama  250: @code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr}
1.1       takayama  251: @end table
                    252: */
                    253: /*&jp
                    254:   {\tt m\_tree\_to\_string(L)} $B$O(B, {\tt MathLink} $B$N(B $BLZ7A<0$GM?$($l$?(B
                    255:   $B%*%V%8%(%'%/%H$r$J$k$Y$/(B asir $B$,M}2r$G$-$k7A$G$N(B, $BA0CV$^$?$OCfCV5-K!(B
                    256:    $B$NJ8;zNs$KJQ49$9$k(B. \\
                    257:    $BNc(B: {\tt m\_tree\_to\_string(["Plus",1,2])} $B$OJ8;zNs(B
                    258:        {\tt 1+2} $B$rLa$9(B. \\
                    259:    $B%j%9%H$N@hF,$NJ8;zNs$,%-!<%o!<%I$G$"$k$,(B, $B$=$NJ8;z$,JQ49%F!<%V%k$K$J$$(B
                    260:    $B$H$-$O(B, {\tt m\_} $B$r%-!<%o!<%I$N@hF,$K$D$1$F(B, $B4X?t8F=P7A<0$NJ8;zNs$X(B
                    261:    $BJQ$($k(B.
                    262: */
                    263:
                    264: /*&jp-texi
                    265: @menu
1.2     ! takayama  266: * mathematica.rtomstr::
1.1       takayama  267: @end menu
1.2     ! takayama  268: @node mathematica.rtomstr,,, Mathematica Functions
        !           269: @subsection @code{mathematica.rtomstr}
        !           270: @findex mathematica.rtomstr
1.1       takayama  271: @table @t
1.2     ! takayama  272: @item mathematica.rtomstr(@var{t})
1.1       takayama  273: ::  @var{t} $B$r$J$k$Y$/(B Mathematica $B$NM}2r2DG=$JJ8;zNs$KJQ$($k(B.
                    274: @end table
                    275:
                    276: @table @var
                    277: @item return
                    278: $BJ8;zNs(B
                    279: @item t
                    280: $B%*%V%8%'%/%H(B
                    281: @end table
                    282: @itemize @bullet
                    283: @item
                    284:    @var{t} $B$r$J$k$Y$/(B Mathematica $B$,M}2r$G$-$k7A$NJ8;zNs$KJQ49$9$k(B.
                    285:    $B$?$H$($P(B, @code{asir} $B$G$O%j%9%H$r(B @code{[}, @code{]} $B$G0O$`$,(B,
                    286:    Mathematica $B$G$O(B @code{@{}, @code{@}} $B$G0O$`(B.
                    287:    $B$3$N4X?t$O$3$NJQ49$r$*$3$J$&(B.
                    288: @end itemize
                    289: */
                    290: /*&eg-texi
                    291: @menu
1.2     ! takayama  292: * mathematica.rtomstr::
1.1       takayama  293: @end menu
1.2     ! takayama  294: @node mathematica.rtomstr,,, Mathematica Functions
        !           295: @subsection @code{mathematica.rtomstr}
        !           296: @findex mathematica.rtomstr
1.1       takayama  297: @table @t
1.2     ! takayama  298: @item mathematica.rtomstr(@var{t})
1.1       takayama  299: ::  translate the object @var{t} into a string that can be understandable
                    300: by Mathematica as far as possible.
                    301: @end table
                    302:
                    303: @table @var
                    304: @item return
                    305: String
                    306: @item t
                    307: Object
                    308: @end table
                    309: @itemize @bullet
                    310: @item
                    311:  It  translates the object @var{t} into a string that can be understandable
                    312: by Mathematica as far as possible.
                    313: For example, @code{asir} uses  @code{[}, @code{]} to express a list,
                    314: but @code{Mathematica} uses @code{@{}, @code{@}}.
                    315: This function makes this sort of translations.
                    316: @end itemize
                    317: */
                    318: /*&C-texi
                    319: @example
1.2     ! takayama  320: [259] mathematica.rtomstr([1,2,3]);
1.1       takayama  321: {1,2,3}
1.2     ! takayama  322: [260] mathematica.rtomstr([[1,x,x^2],[1,y,y^2]]);
1.1       takayama  323: @{@{1,x,x^2@},@{1,y,y^2@}@}
                    324: @end example
                    325: */
                    326: /*&jp-texi
                    327: $B$b$&0l$DNc$r$"$2$h$&(B.
1.2     ! takayama  328: $B<!$N4X?t(B @code{mathematica.inverse(M)} $B$O(B @code{ox_math}
1.1       takayama  329: $B$r$h$s$G9TNs(B @code{M} $B$N5U9TNs$r7W;;$9$k4X?t$G$"$k(B.
1.2     ! takayama  330: @code{mathematica.inverse(M)} $B$O<!$N$h$&$K(B @code{r_tostr(M)} $B$rMQ$$$F(B
1.1       takayama  331: asir $B$N9TNs$r(B Mathematica $B7A<0$KJQ49$7$F$+$i(B
                    332: @code{ox_execute_string} $B$G(B Mathematica $B$K5U9TNs$r7W;;(B
                    333: $B$5$;$F$$$k(B.
                    334: */
                    335: /*&eg-texi
                    336: Let us see one more example.
1.2     ! takayama  337: The following function @code{mathematica.inverse(M)} outputs
1.1       takayama  338: the inverse matrix of the matrix @code{M} by calling @code{ox_math}.
                    339: It translates @code{asir} matrix @code{M} into a Mathematica expression
                    340: by @code{r_tostr(M)}
                    341: and makes Mathematica compute the inverse matrix of @code{M} by
                    342: @code{ox_execute_string}.
                    343: */
                    344: /*&C-texi
                    345: @example
                    346: def inverse(M) @{
                    347:   P = 0;
1.2     ! takayama  348:   A = mathematica.rtomstr(M);
1.1       takayama  349:   ox_execute_string(P,"Inverse["+A+"]");
                    350:   B = ox_pop_cmo(B);
1.2     ! takayama  351:   C = mathematica.tree_to_string(B);
1.1       takayama  352:   return(eval_str(C));
                    353: @}
                    354:
                    355: [269] M=[[1,x,x^2],[1,y,y^2],[1,z,z^2]];
                    356: [[1,x,x^2],[1,y,y^2],[1,z,z^2]]
1.2     ! takayama  357: [270] A=mathematica.inverse(M)$
1.1       takayama  358: [271] red(A[0][0]);
                    359: (z*y)/(x^2+(-y-z)*x+z*y)
                    360: @end example
                    361: */
                    362: /*&jp-texi
                    363: @table @t
                    364: @item $B;2>H(B
                    365: @code{ox_execute_string}, @code{ToExpression}(Mathematica),
1.2     ! takayama  366: @code{mathematica.tree_to_string}
1.1       takayama  367: @end table
                    368: */
                    369: /*&eg-texi
                    370: @table @t
                    371: @item Reference
                    372: @code{ox_execute_string}, @code{ToExpression}(Mathematica),
1.2     ! takayama  373: @code{mathematica.tree_to_string}
1.1       takayama  374: @end table
                    375: */
                    376: /*&jp
1.2     ! takayama  377:   $B4X?t(B \verb+ mathematica.rtomstr(L) + $B$O(B asir $B7A<0$N%*%V%8%'%/%H(B L $B$r$J$k$Y$/(B
1.1       takayama  378:   Mathematica $B$,M}2r$G$-$k7A$NJ8;zNs$KJQ49$9$k(B.
                    379:   $B$?$H$($P(B, $B%j%9%H(B, $B%Y%/%H%k(B, $B9TNs(B $B$O(B asir $B$G$O(B {\tt [}, {\tt ]}
                    380:   $B$G0O$`$,(B, Mathematica $B$G$O(B, {\tt \{ }, {\tt \}} $B$G0O$`(B.
                    381:   $B8=:_$N$H$3$m$3$N4X?t$O$3$NJQ49$N$_9T$J$C$F$$$k(B. \\
                    382:   $BNc(B:
                    383:   {\footnotesize
                    384:   \begin{verbatim}
1.2     ! takayama  385:    [262] mathematica.rtomstr([1,2,3]);
1.1       takayama  386:    {1,2,3}
                    387:    [375] A = newvect(3,[x+2,"Hello",[1/2,3]]);
                    388:    [ x+2 Hello [1/2,3] ]
1.2     ! takayama  389:    [376] mathematica.rtomstr(A);
1.1       takayama  390:    {x+2,Hello,{1/2,3}}
                    391:   \end{verbatim}
                    392:   }
                    393: */
                    394:
                    395: end$
                    396:

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