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

Annotation of OpenXM/src/asir-contrib/packages/doc/mathematica/mathematica.oxw, Revision 1.1

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

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