@overfullrule=0pt
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
| 1.1.1 mathematica.start | ||
| 1.1.2 mathematica.tree_to_string | ||
| 1.1.3 mathematica.rtomstr | 
この節では Mathematica の ox サーバ ox_math
とのインタフェース関数を解説する.
これらの関数はファイル  ‘mathematica.rr’ 
で定義されているのでこのファイルを
load("mathematica.rr")$ 
でロードしてから使用しないといけない.
‘mathematica.rr’ は ‘$(OpenXM_HOME)/lib/asir-contrib’ にある.
注意: ox_reset は動かない.
[258] load("mathematica.rr")$
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]
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 http://www.wolfram.com.
The copyright and license agreement of the mathlink is put at 
OpenXM/Copyright/Copyright.mathlink
Note that the licence prohibits to connect to a mathematica
kernel via the internet.
Author of ox_math: Katsuyoshi Ohara.  
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
mathematica.start::  Localhost で ox_math を起動する.
整数
ox_math を起動する.
    起動された ox_math の識別番号を戻す.
Xm_noX =1 としておくと, ox_math 用の debug window が開かない.
M_proc に格納される.
P = mathematica.start()
ox_launch
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
mathematica.tree_to_string::  ox_math の戻す Mathematica の木構造データ t を asir 形式に
なおす.
文字列
リスト
ox_math の戻す Mathematica の木構造データ.
asir 形式に
なおす.
m_ をキーワードの先頭につけて, 関数呼出形式の文字列へ
   かえる.
[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
[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)
ox_pop_cmo, eval_str, mathematica.rtomstr
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
mathematica.rtomstr:: t をなるべく Mathematica の理解可能な文字列に変える.
文字列
オブジェクト
asir ではリストを [, ] で囲むが,
   Mathematica では {, } で囲む.
   この関数はこの変換をおこなう.
[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}}
もう一つ例をあげよう.
次の関数 mathematica.inverse(M) は ox_math
をよんで行列 M の逆行列を計算する関数である.
mathematica.inverse(M) は次のように r_tostr(M) を用いて
asir の行列を Mathematica 形式に変換してから 
ox_execute_string で Mathematica に逆行列を計算
させている.
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)
ox_execute_string, ToExpression(Mathematica),
mathematica.tree_to_string
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] | 
| Jump to: | M | 
|---|
| Index Entry | Section | ||
|---|---|---|---|
|  | |||
| M | |||
| mathematica.rtomstr | 1.1.3 mathematica.rtomstr | ||
| mathematica.start | 1.1.1 mathematica.start | ||
| mathematica.tree_to_string | 1.1.2 mathematica.tree_to_string | ||
|  | |||
| Jump to: | M | 
|---|
| [Top] | [Contents] | [Index] | [ ? ] | 
| [Top] | [Contents] | [Index] | [ ? ] | 
| [Top] | [Contents] | [Index] | [ ? ] | 
This document was generated on October 31, 2025 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
| Button | Name | Go to | From 1.2.3 go to | 
|---|---|---|---|
| [ << ] | FastBack | Beginning of this chapter or previous chapter | 1 | 
| [ < ] | Back | Previous section in reading order | 1.2.2 | 
| [ Up ] | Up | Up section | 1.2 | 
| [ > ] | Forward | Next section in reading order | 1.2.4 | 
| [ >> ] | FastForward | Next chapter | 2 | 
| [Top] | Top | Cover (top) of document | |
| [Contents] | Contents | Table of contents | |
| [Index] | Index | Index | |
| [ ? ] | About | About (help) | 
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
 
  This document was generated on October 31, 2025 using texi2html 5.0.