version 1.1, 2003/05/19 05:15:52 |
version 1.3, 2003/07/16 05:36:24 |
|
|
/* $OpenXM$ */ |
/* $OpenXM: OpenXM/src/asir-contrib/packages/doc/m.oxweave,v 1.2 2003/05/20 23:25:28 takayama Exp $ */ |
/* Use oxweave to generate documents on this source code |
/* 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. |
Use iso-2022 to write this file. No default use of GL and GR is allowed. |
*/ |
*/ |
Line 36 Note: @code{ox_reset} does not work. |
|
Line 36 Note: @code{ox_reset} does not work. |
|
@example |
@example |
@include opening.texi |
@include opening.texi |
[258] load("m")$ |
[258] load("m")$ |
m Version 19991113. m.start, m.tree_to_string, m.n_Eigenvalues |
m Version 19991113. mathematica.start, mathematica.tree_to_string, mathematica.n_Eigenvalues |
[259] m.start(); |
[259] mathematica.start(); |
ox_math has started. |
ox_math has started. |
ox_math: Portions copyright 2000 Wolfram Research, Inc. |
ox_math: Portions copyright 2000 Wolfram Research, Inc. |
See OpenXM/Copyright/Copyright.mathlink for details. |
See OpenXM/Copyright/Copyright.mathlink for details. |
0 |
0 |
[260] m.n_Eigenvalues([[1,2],[4,5]]); |
[260] mathematica.n_Eigenvalues([[1,2],[4,5]]); |
[-0.464102,6.4641] |
[-0.464102,6.4641] |
@end example |
@end example |
*/ |
*/ |
Line 72 Author of @code{ox_math}: Katsuyoshi Ohara, |
|
Line 72 Author of @code{ox_math}: Katsuyoshi Ohara, |
|
*/ |
*/ |
/*&jp-texi |
/*&jp-texi |
@menu |
@menu |
* m.start:: |
* mathematica.start:: |
@end menu |
@end menu |
@node m.start,,, Mathematica Functions |
@node mathematica.start,,, Mathematica Functions |
@subsection @code{m.start} |
@subsection @code{mathematica.start} |
@findex m.start |
@findex mathematica.start |
@table @t |
@table @t |
@item m.start() |
@item mathematica.start() |
:: Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B. |
:: Localhost $B$G(B @code{ox_math} $B$r5/F0$9$k(B. |
@end table |
@end table |
|
|
Line 96 Author of @code{ox_math}: Katsuyoshi Ohara, |
|
Line 96 Author of @code{ox_math}: Katsuyoshi Ohara, |
|
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
@menu |
@menu |
* m.start:: |
* mathematica.start:: |
@end menu |
@end menu |
@node m.start,,, Mathematica Functions |
@node mathematica.start,,, Mathematica Functions |
@subsection @code{m.start} |
@subsection @code{mathematica.start} |
@findex m.start |
@findex mathematica.start |
@table @t |
@table @t |
@item m.start() |
@item mathematica.start() |
:: Start @code{ox_math} on the localhost. |
:: Start @code{ox_math} on the localhost. |
@end table |
@end table |
|
|
|
|
*/ |
*/ |
/*&C-texi |
/*&C-texi |
@example |
@example |
P = m.start() |
P = mathematica.start() |
@end example |
@end example |
*/ |
*/ |
/*&jp-texi |
/*&jp-texi |
|
|
|
|
/*&jp-texi |
/*&jp-texi |
@menu |
@menu |
* m.tree_to_string:: |
* mathematica.tree_to_string:: |
@end menu |
@end menu |
@node m.tree_to_string,,, Mathematica Functions |
@node mathematica.tree_to_string,,, Mathematica Functions |
@subsection @code{m.tree_to_string} |
@subsection @code{mathematica.tree_to_string} |
@findex m.tree_to_string |
@findex mathematica.tree_to_string |
@table @t |
@table @t |
@item m.tree_to_string(@var{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 |
:: 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. |
$B$J$*$9(B. |
@end table |
@end table |
Line 175 ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B |
|
Line 175 ox_math $B$NLa$9(B Mathematica $B$NLZ9=B$%G!<%?(B |
|
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
@menu |
@menu |
* m.tree_to_string:: |
* mathematica.tree_to_string:: |
@end menu |
@end menu |
@node m.tree_to_string,,, Mathematica Functions |
@node mathematica.tree_to_string,,, Mathematica Functions |
@subsection @code{m.tree_to_string} |
@subsection @code{mathematica.tree_to_string} |
@findex m.tree_to_string |
@findex mathematica.tree_to_string |
@table @t |
@table @t |
@item m.tree_to_string(@var{t}) |
@item mathematica.tree_to_string(@var{t}) |
:: translates Mathematica tree data @var{t} into a string that can |
:: translates Mathematica tree data @var{t} into a string that can |
be understandable by @code{asir} as far as possible. |
be understandable by @code{asir} as far as possible. |
@end table |
@end table |
Line 212 be understandable by @code{asir}. |
|
Line 212 be understandable by @code{asir}. |
|
*/ |
*/ |
/*&C-texi |
/*&C-texi |
@example |
@example |
[267] m.start(); |
[267] mathematica.start(); |
0 |
0 |
[268] ox_execute_string(0,"Expand[(x-1)^2]"); |
[268] ox_execute_string(0,"Expand[(x-1)^2]"); |
0 |
0 |
[269] A=ox_pop_cmo(0); |
[269] A=ox_pop_cmo(0); |
[Plus,1,[Times,-2,x],[Power,x,2]] |
[Plus,1,[Times,-2,x],[Power,x,2]] |
[270] m.tree_to_string(A); |
[270] mathematica.tree_to_string(A); |
(1)+((-2)*(x))+((x)^(2)) |
(1)+((-2)*(x))+((x)^(2)) |
[271] eval_str(@@); |
[271] eval_str(@@); |
x^2-2*x+1 |
x^2-2*x+1 |
|
|
*/ |
*/ |
/*&C-texi |
/*&C-texi |
@example |
@example |
[259] m.tree_to_string(["List",1,2]); |
[259] mathematica.tree_to_string(["List",1,2]); |
[1 , 2] |
[1 , 2] |
[260] m.tree_to_string(["Plus",2,3]); |
[260] mathematica.tree_to_string(["Plus",2,3]); |
(2)+(3) |
(2)+(3) |
[261] m.tree_to_string(["Complex",2.3,4.55]); |
[261] mathematica.tree_to_string(["Complex",2.3,4.55]); |
m.complex(2.3 , 4.55) |
mathematica.complex(2.3 , 4.55) |
[362] m.tree_to_string(["Plus",["Complex",1.2,3.5],1/2]); |
[362] mathematica.tree_to_string(["Plus",["Complex",1.2,3.5],1/2]); |
(m.complex(1.2 , 3.5))+(1/2) |
(mathematica.complex(1.2 , 3.5))+(1/2) |
[380] eval_str(@@); |
[380] eval_str(@@); |
(1.7+3.5*@i) |
(1.7+3.5*@@i) |
@end example |
@end example |
*/ |
*/ |
/*&jp-texi |
/*&jp-texi |
@table @t |
@table @t |
@item $B;2>H(B |
@item $B;2>H(B |
@code{ox_pop_cmo}, @code{eval_str}, @code{m.rtomstr} |
@code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr} |
@end table |
@end table |
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
@table @t |
@table @t |
@item Reference |
@item Reference |
@code{ox_pop_cmo}, @code{eval_str}, @code{m.rtomstr} |
@code{ox_pop_cmo}, @code{eval_str}, @code{mathematica.rtomstr} |
@end table |
@end table |
*/ |
*/ |
/*&jp |
/*&jp |
Line 263 m.complex(2.3 , 4.55) |
|
Line 263 m.complex(2.3 , 4.55) |
|
|
|
/*&jp-texi |
/*&jp-texi |
@menu |
@menu |
* m.rtomstr:: |
* mathematica.rtomstr:: |
@end menu |
@end menu |
@node m.rtomstr,,, Mathematica Functions |
@node mathematica.rtomstr,,, Mathematica Functions |
@subsection @code{m.rtomstr} |
@subsection @code{mathematica.rtomstr} |
@findex m.rtomstr |
@findex mathematica.rtomstr |
@table @t |
@table @t |
@item m.rtomstr(@var{t}) |
@item mathematica.rtomstr(@var{t}) |
:: @var{t} $B$r$J$k$Y$/(B Mathematica $B$NM}2r2DG=$JJ8;zNs$KJQ$($k(B. |
:: @var{t} $B$r$J$k$Y$/(B Mathematica $B$NM}2r2DG=$JJ8;zNs$KJQ$($k(B. |
@end table |
@end table |
|
|
Line 289 m.complex(2.3 , 4.55) |
|
Line 289 m.complex(2.3 , 4.55) |
|
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
@menu |
@menu |
* m.rtomstr:: |
* mathematica.rtomstr:: |
@end menu |
@end menu |
@node m.rtomstr,,, Mathematica Functions |
@node mathematica.rtomstr,,, Mathematica Functions |
@subsection @code{m.rtomstr} |
@subsection @code{mathematica.rtomstr} |
@findex m.rtomstr |
@findex mathematica.rtomstr |
@table @t |
@table @t |
@item m.rtomstr(@var{t}) |
@item mathematica.rtomstr(@var{t}) |
:: translate the object @var{t} into a string that can be understandable |
:: translate the object @var{t} into a string that can be understandable |
by Mathematica as far as possible. |
by Mathematica as far as possible. |
@end table |
@end table |
Line 317 This function makes this sort of translations. |
|
Line 317 This function makes this sort of translations. |
|
*/ |
*/ |
/*&C-texi |
/*&C-texi |
@example |
@example |
[259] m.rtomstr([1,2,3]); |
[259] mathematica.rtomstr([1,2,3]); |
{1,2,3} |
@{1,2,3@} |
[260] m.rtomstr([[1,x,x^2],[1,y,y^2]]); |
[260] mathematica.rtomstr([[1,x,x^2],[1,y,y^2]]); |
@{@{1,x,x^2@},@{1,y,y^2@}@} |
@{@{1,x,x^2@},@{1,y,y^2@}@} |
@end example |
@end example |
*/ |
*/ |
/*&jp-texi |
/*&jp-texi |
$B$b$&0l$DNc$r$"$2$h$&(B. |
$B$b$&0l$DNc$r$"$2$h$&(B. |
$B<!$N4X?t(B @code{m.inverse(M)} $B$O(B @code{ox_math} |
$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. |
$B$r$h$s$G9TNs(B @code{M} $B$N5U9TNs$r7W;;$9$k4X?t$G$"$k(B. |
@code{m.inverse(M)} $B$O<!$N$h$&$K(B @code{r_tostr(M)} $B$rMQ$$$F(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 |
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 |
@code{ox_execute_string} $B$G(B Mathematica $B$K5U9TNs$r7W;;(B |
$B$5$;$F$$$k(B. |
$B$5$;$F$$$k(B. |
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
Let us see one more example. |
Let us see one more example. |
The following function @code{m.inverse(M)} outputs |
The following function @code{mathematica.inverse(M)} outputs |
the inverse matrix of the matrix @code{M} by calling @code{ox_math}. |
the inverse matrix of the matrix @code{M} by calling @code{ox_math}. |
It translates @code{asir} matrix @code{M} into a Mathematica expression |
It translates @code{asir} matrix @code{M} into a Mathematica expression |
by @code{r_tostr(M)} |
by @code{r_tostr(M)} |
Line 345 and makes Mathematica compute the inverse matrix of @c |
|
Line 345 and makes Mathematica compute the inverse matrix of @c |
|
@example |
@example |
def inverse(M) @{ |
def inverse(M) @{ |
P = 0; |
P = 0; |
A = m.rtomstr(M); |
A = mathematica.rtomstr(M); |
ox_execute_string(P,"Inverse["+A+"]"); |
ox_execute_string(P,"Inverse["+A+"]"); |
B = ox_pop_cmo(B); |
B = ox_pop_cmo(B); |
C = m.tree_to_string(B); |
C = mathematica.tree_to_string(B); |
return(eval_str(C)); |
return(eval_str(C)); |
@} |
@} |
|
|
[269] M=[[1,x,x^2],[1,y,y^2],[1,z,z^2]]; |
[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]] |
[[1,x,x^2],[1,y,y^2],[1,z,z^2]] |
[270] A=m.inverse(M)$ |
[270] A=mathematica.inverse(M)$ |
[271] red(A[0][0]); |
[271] red(A[0][0]); |
(z*y)/(x^2+(-y-z)*x+z*y) |
(z*y)/(x^2+(-y-z)*x+z*y) |
@end example |
@end example |
Line 363 def inverse(M) @{ |
|
Line 363 def inverse(M) @{ |
|
@table @t |
@table @t |
@item $B;2>H(B |
@item $B;2>H(B |
@code{ox_execute_string}, @code{ToExpression}(Mathematica), |
@code{ox_execute_string}, @code{ToExpression}(Mathematica), |
@code{m.tree_to_string} |
@code{mathematica.tree_to_string} |
@end table |
@end table |
*/ |
*/ |
/*&eg-texi |
/*&eg-texi |
@table @t |
@table @t |
@item Reference |
@item Reference |
@code{ox_execute_string}, @code{ToExpression}(Mathematica), |
@code{ox_execute_string}, @code{ToExpression}(Mathematica), |
@code{m.tree_to_string} |
@code{mathematica.tree_to_string} |
@end table |
@end table |
*/ |
*/ |
/*&jp |
/*&jp |
$B4X?t(B \verb+ m.rtomstr(L) + $B$O(B asir $B7A<0$N%*%V%8%'%/%H(B L $B$r$J$k$Y$/(B |
$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. |
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$?$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. |
$B$G0O$`$,(B, Mathematica $B$G$O(B, {\tt \{ }, {\tt \}} $B$G0O$`(B. |
Line 382 def inverse(M) @{ |
|
Line 382 def inverse(M) @{ |
|
$BNc(B: |
$BNc(B: |
{\footnotesize |
{\footnotesize |
\begin{verbatim} |
\begin{verbatim} |
[262] m.rtomstr([1,2,3]); |
[262] mathematica.rtomstr([1,2,3]); |
{1,2,3} |
{1,2,3} |
[375] A = newvect(3,[x+2,"Hello",[1/2,3]]); |
[375] A = newvect(3,[x+2,"Hello",[1/2,3]]); |
[ x+2 Hello [1/2,3] ] |
[ x+2 Hello [1/2,3] ] |
[376] m.rtomstr(A); |
[376] mathematica.rtomstr(A); |
{x+2,Hello,{1/2,3}} |
{x+2,Hello,{1/2,3}} |
\end{verbatim} |
\end{verbatim} |
} |
} |