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

File: [local] / OpenXM / src / asir-contrib / packages / doc / Attic / m.oxweave (download)

Revision 1.4, Sun Jul 27 13:18:46 2003 UTC (20 years, 11 months ago) by takayama
Branch: MAIN
CVS Tags: RELEASE_1_2_2_KNOPPIX
Changes since 1.3: +8 -19 lines

Fixed wrong node dependencies.

/* $OpenXM: OpenXM/src/asir-contrib/packages/doc/m.oxweave,v 1.4 2003/07/27 13:18:46 takayama Exp $ */
/* Use oxweave to generate documents on this source code
   Use iso-2022 to write this file. No default use of GL and GR is allowed.
*/


/*&C-texi
@c DO NOT EDIT THIS FILE   oxmath.texi  It is automatically generated
@c from asir-contrib/packages/doc/m.oxweave
@node Mathematica Functions,,, Top
@menu
* mathematica.start::
* mathematica.tree_to_string::
* mathematica.rtomstr::
@end menu


*/
/*&jp-texi
@chapter Mathematica $BH!?t(B

$B$3$N@a$G$O(B Mathematica $B$N(B ox $B%5!<%P(B @code{ox_math}
$B$H$N%$%s%?%U%'!<%94X?t$r2r@b$9$k(B.
$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
@code{load("m")$} $B$G$3$N%U%!%$%k$r%m!<%I$7$F$+$i;HMQ$7$J$$$H$$$1$J$$(B.
@file{m} $B$O(B @file{$(OpenXM_HOME)/lib/asir-contrib} $B$K$"$k(B.

$BCm0U(B: @code{ox_reset} $B$OF0$+$J$$(B.
*/
/*&eg-texi
@chapter Mathematica Functions

This chapter describes  interface functions for
Mathematica ox server @code{ox_math}.
These interface functions are defined in the file @file{m}.
You need to load the file before using the interface functions.
by the command @code{load("m")$}.
The file @file{m} is at @file{$(OpenXM_HOME)/lib/asir-contrib}.

Note: @code{ox_reset} does not work.
*/
/*&C-texi
@example
@include opening.texi
[258] load("m")$
m Version 19991113. mathematica.start, mathematica.tree_to_string, mathematica.n_Eigenvalues
[259] mathematica.start();
ox_math has started.
ox_math: Portions copyright 2000 Wolfram Research, Inc. 
See OpenXM/Copyright/Copyright.mathlink  for details.
0
[260] mathematica.n_Eigenvalues([[1,2],[4,5]]);
[-0.464102,6.4641]
@end example
*/

/*&C-texi
@noindent
@code{Mathematica} is the trade mark of Wolfram Research Inc.
This package requires Mathmatica Version 3.0, so you need
Mathematica to make this package work.
See @code{http://www.wolfram.com}.
The copyright and license agreement of the mathlink is put at 
@code{OpenXM/Copyright/Copyright.mathlink}
Note that the licence prohibits to connect to a mathematica
kernel via the internet.

@noindent
Author of @code{ox_math}: Katsuyoshi Ohara,  
@code{ohara@@air.s.kanazawa-u.ac.jp}.
*/


/*&jp-texi
@section $BH!?t0lMw(B
*/ 
/*&eg-texi
@section Functions
*/ 
/*&jp-texi
@node mathematica.start,,, Mathematica Functions
@subsection @code{mathematica.start}
@findex mathematica.start
@table @t
@item mathematica.start()
::  Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B.
@end table

@table @var
@item return
$B@0?t(B
@end table

@itemize @bullet
@item Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B.
    $B5/F0$5$l$?(B @code{ox_math} $B$N<1JLHV9f$rLa$9(B.
@item @code{Xm_noX =1} $B$H$7$F$*$/$H(B, @code{ox_math} $BMQ$N(B debug window $B$,3+$+$J$$(B.
@item $B<1JLHV9f$O(B @code{M_proc} $B$K3JG<$5$l$k(B.
@end itemize
*/
/*&eg-texi
@node mathematica.start,,, Mathematica Functions
@subsection @code{mathematica.start}
@findex mathematica.start
@table @t
@item mathematica.start()
::  Start  @code{ox_math} on the localhost.
@end table

@table @var
@item return
Integer
@end table

@itemize @bullet
@item Start @code{ox_math} on the localhost.
    It returns the descriptor of @code{ox_math}.
@item Set @code{Xm_noX = 1} to start @code{ox_math} without a debug window.
@item The descriptor is stored in the variable @code{M_proc}.
@end itemize
*/
/*&C-texi
@example
P = mathematica.start()
@end example
*/
/*&jp-texi
@table @t
@item $B;2>H(B
@code{ox_launch}
@end table
*/
/*&eg-texi
@table @t
@item Reference
@code{ox_launch}
@end table
*/

/*&jp
  $B0J2<$G(BMathematica $B$r8F$V$?$a$NJd=u4X?t$rDj5A$9$k(B.
*/

/*&jp-texi
@node mathematica.tree_to_string,,, Mathematica Functions
@subsection @code{mathematica.tree_to_string}
@findex mathematica.tree_to_string
@table @t
@item mathematica.tree_to_string(@var{t})
::  ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B @var{t} $B$r(B @code{asir} $B7A<0$K(B
$B$J$*$9(B.
@end table

@table @var
@item return
$BJ8;zNs(B
@item t
$B%j%9%H(B
@end table
@itemize @bullet
@item 
t $B$O(B @code{ox_math} $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B.
@item 
ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B @var{t} $B$r(B @code{asir} $B7A<0$K(B
$B$J$*$9(B.
@item
   @var{t} $B$r$J$k$Y$/(B asir $B$,M}2r$G$-$k7A$G$N(B, $BA0CV$^$?$OCfCV5-K!(B
   $B$NJ8;zNs$KJQ49$9$k(B. 
   @var{t}$B$N@hF,MWAG$NJ8;zNs$,%-!<%o!<%I$G$"$k$,(B, $B$=$NJ8;z$,JQ49%F!<%V%k$K$J$$(B
   $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
   $B$+$($k(B.
@end itemize
*/
/*&eg-texi
@node mathematica.tree_to_string,,, Mathematica Functions
@subsection @code{mathematica.tree_to_string}
@findex mathematica.tree_to_string
@table @t
@item mathematica.tree_to_string(@var{t})
::  translates Mathematica tree data  @var{t} into a string that can 
be understandable by @code{asir} as far as possible.
@end table

@table @var
@item return
String
@item t
List
@end table
@itemize @bullet
@item 
t is a Mathematica tree data which is generated by @code{ox_math}.
@item 
This function
 translates Mathematica tree data  @var{t} into a string that may 
be understandable by @code{asir}.
@item
   This function translates @var{t} into a prefix or infix expression that may be understantable by @code{asir}.
   The first element of the list @var{t}
  is a key word string of the Mathematica object.
  If this function recognizes the key word, it translates @code{t} into
  the form that can be understandable by @code{asir}.
  If it cannot recognizes the key word, it translates @code{t} into
  a function call with the function name
  @code{m_(the key word)}.
@end itemize
*/
/*&C-texi
@example
[267] mathematica.start();
0
[268] ox_execute_string(0,"Expand[(x-1)^2]");
0
[269] A=ox_pop_cmo(0);  
[Plus,1,[Times,-2,x],[Power,x,2]]
[270] mathematica.tree_to_string(A);
(1)+((-2)*(x))+((x)^(2))
[271] eval_str(@@);
x^2-2*x+1
@end example
*/
/*&C-texi
@example
[259] mathematica.tree_to_string(["List",1,2]);
[1 , 2]
[260] mathematica.tree_to_string(["Plus",2,3]);
(2)+(3)
[261] mathematica.tree_to_string(["Complex",2.3,4.55]);
mathematica.complex(2.3 , 4.55)
[362] mathematica.tree_to_string(["Plus",["Complex",1.2,3.5],1/2]);
(mathematica.complex(1.2 , 3.5))+(1/2)
[380] eval_str(@@);
(1.7+3.5*@@i)
@end example
*/
/*&jp-texi
@table @t
@item $B;2>H(B
@code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr}
@end table
*/
/*&eg-texi
@table @t
@item Reference
@code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr}
@end table
*/
/*&jp 
  {\tt m\_tree\_to\_string(L)} $B$O(B, {\tt MathLink} $B$N(B $BLZ7A<0$GM?$($l$?(B
  $B%*%V%8%(%'%/%H$r$J$k$Y$/(B asir $B$,M}2r$G$-$k7A$G$N(B, $BA0CV$^$?$OCfCV5-K!(B
   $B$NJ8;zNs$KJQ49$9$k(B. \\
   $BNc(B: {\tt m\_tree\_to\_string(["Plus",1,2])} $B$OJ8;zNs(B
       {\tt 1+2} $B$rLa$9(B. \\
   $B%j%9%H$N@hF,$NJ8;zNs$,%-!<%o!<%I$G$"$k$,(B, $B$=$NJ8;z$,JQ49%F!<%V%k$K$J$$(B
   $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
   $BJQ$($k(B.
*/

/*&jp-texi
@node mathematica.rtomstr,,, Mathematica Functions
@subsection @code{mathematica.rtomstr}
@findex mathematica.rtomstr
@table @t
@item mathematica.rtomstr(@var{t})
::  @var{t} $B$r$J$k$Y$/(B Mathematica $B$NM}2r2DG=$JJ8;zNs$KJQ$($k(B.
@end table

@table @var
@item return
$BJ8;zNs(B
@item t
$B%*%V%8%'%/%H(B
@end table
@itemize @bullet
@item
   @var{t} $B$r$J$k$Y$/(B Mathematica $B$,M}2r$G$-$k7A$NJ8;zNs$KJQ49$9$k(B. 
   $B$?$H$($P(B, @code{asir} $B$G$O%j%9%H$r(B @code{[}, @code{]} $B$G0O$`$,(B,
   Mathematica $B$G$O(B @code{@{}, @code{@}} $B$G0O$`(B.
   $B$3$N4X?t$O$3$NJQ49$r$*$3$J$&(B.
@end itemize
*/
/*&eg-texi
@node mathematica.rtomstr,,, Mathematica Functions
@subsection @code{mathematica.rtomstr}
@findex mathematica.rtomstr
@table @t
@item mathematica.rtomstr(@var{t})
::  translate the object @var{t} into a string that can be understandable
by Mathematica as far as possible.
@end table

@table @var
@item return
String
@item t
Object
@end table
@itemize @bullet
@item
 It  translates the object @var{t} into a string that can be understandable
by Mathematica as far as possible.
For example, @code{asir} uses  @code{[}, @code{]} to express a list,
but @code{Mathematica} uses @code{@{}, @code{@}}.
This function makes this sort of translations.
@end itemize
*/
/*&C-texi
@example
[259] mathematica.rtomstr([1,2,3]);
@{1,2,3@}
[260] mathematica.rtomstr([[1,x,x^2],[1,y,y^2]]);
@{@{1,x,x^2@},@{1,y,y^2@}@}
@end example
*/
/*&jp-texi
$B$b$&0l$DNc$r$"$2$h$&(B.
$B<!$N4X?t(B @code{mathematica.inverse(M)} $B$O(B @code{ox_math}
$B$r$h$s$G9TNs(B @code{M} $B$N5U9TNs$r7W;;$9$k4X?t$G$"$k(B.
@code{mathematica.inverse(M)} $B$O<!$N$h$&$K(B @code{r_tostr(M)} $B$rMQ$$$F(B
asir $B$N9TNs$r(B Mathematica $B7A<0$KJQ49$7$F$+$i(B 
@code{ox_execute_string} $B$G(B Mathematica $B$K5U9TNs$r7W;;(B
$B$5$;$F$$$k(B.
*/
/*&eg-texi
Let us see one more example.
The following function @code{mathematica.inverse(M)} outputs
the inverse matrix of the matrix @code{M} by calling @code{ox_math}.
It translates @code{asir} matrix @code{M} into a Mathematica expression
by @code{r_tostr(M)}
and makes Mathematica compute the inverse matrix of @code{M} by
@code{ox_execute_string}.
*/
/*&C-texi
@example
def inverse(M) @{
  P = 0;
  A = mathematica.rtomstr(M);
  ox_execute_string(P,"Inverse["+A+"]");
  B = ox_pop_cmo(B);
  C = mathematica.tree_to_string(B);
  return(eval_str(C));
@}

[269] M=[[1,x,x^2],[1,y,y^2],[1,z,z^2]];
[[1,x,x^2],[1,y,y^2],[1,z,z^2]]
[270] A=mathematica.inverse(M)$
[271] red(A[0][0]);
(z*y)/(x^2+(-y-z)*x+z*y)
@end example
*/
/*&jp-texi
@table @t
@item $B;2>H(B
@code{ox_execute_string}, @code{ToExpression}(Mathematica),
@code{mathematica.tree_to_string}
@end table
*/
/*&eg-texi
@table @t
@item Reference
@code{ox_execute_string}, @code{ToExpression}(Mathematica),
@code{mathematica.tree_to_string}
@end table
*/
/*&jp
  $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
  Mathematica $B$,M}2r$G$-$k7A$NJ8;zNs$KJQ49$9$k(B.
  $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 ]}
  $B$G0O$`$,(B, Mathematica $B$G$O(B, {\tt \{ }, {\tt \}} $B$G0O$`(B.
  $B8=:_$N$H$3$m$3$N4X?t$O$3$NJQ49$N$_9T$J$C$F$$$k(B. \\
  $BNc(B:
  {\footnotesize
  \begin{verbatim}
   [262] mathematica.rtomstr([1,2,3]);
   {1,2,3}
   [375] A = newvect(3,[x+2,"Hello",[1/2,3]]);
   [ x+2 Hello [1/2,3] ]
   [376] mathematica.rtomstr(A);
   {x+2,Hello,{1/2,3}}
  \end{verbatim}
  }
*/

end$