無料配布のMathematicaカーネルをIronRubyから自由自在に使ってみよう

[pukiwiki]
すごく面白そうな記事だったので、将来遊ぶときのためにメモ
今は仕事があるのでガマン。。。
[/pukiwiki]


[pukiwiki]
hirax.netより
-[[無料配布のMathematicaカーネルをIronRubyから自由自在に使ってみよう:http://www.hirax.net/diaryweb/2009/09/28.html#8385]]
-[[IronRuby + Mathematica Player で無料数学演習講座:http://www.hirax.net/diaryweb/2009/09/29.html#8388]]
-[[IronRubyから有償版Mathematicaを.NET/Linkで使ってみる:http://www.hirax.net/diaryweb/2009/09/30.html#8390]]
-[[ronRuby+Mathematica Playerでグラフィック表示(試行錯誤中):http://www.hirax.net/diaryweb/2009/10/01.html#8393]]
-[[IronRubyとMathematica Playerの良い組み合わせ方を考える:http://www.hirax.net/diaryweb/2009/10/02.html#8394]]
-[[「IronRuby」+「Mathematica Player」=「∞の可能性」:http://www.hirax.net/diaryweb/2009/10/03.html#8397]]
-[[IronRubyとMathematica Playerで経済データも自由自在:http://www.hirax.net/diaryweb/2009/10/04.html#8398]]
☆特にコレにはびっくりしました
-[[引数付きのMathLinkFactory.CreateKernelLinkの書き方:http://www.hirax.net/diaryweb/2009/10/12.html#8415]]
<<追記>> MathKernel.exeの絶対パスを指定して起動。

*IronPythonからも
こちらは別のサイトより。ただし、無料版MathPlayerでは、以下のサンプルは動かないかもです。
-[[IronPython + Mathematica .NET/Link:http://d.hatena.ne.jp/NyaRuRu/20060916/p1]]
-[[Mathlink on IronPython 1.0:http://d.hatena.ne.jp/niwaii/20060911]]
*関連?
-[[ヒスイ 1.10~ C# で OpenGL するフリーの Framework:http://www.quatouch.com/products/hisui/index.html]]
IronPythonが組み込みスクリプトとして使えるみたいです

—-
でも、ちょっとだけ遊んでしまいました。 誘惑に弱い私(^^;
[[上記記事のサンプルより:http://www.hirax.net/diaryweb/2009/10/02.html#8394]]
連立方程式の解を求めるプログラムをIronPythonで。
[/pukiwiki]

#!cmd ipy.exe
import clr
clr.AddReferenceToFile("Wolfram.NETLink.dll")
#clr.AddReferenceByPartialName("Wolfram.NETLink") これでもよい?
from Wolfram.NETLink import *

kernelLink=MathLinkFactory.CreateKernelLink()
kernelLink.WaitAndDiscardAnswer()
result=kernelLink.EvaluateToInputForm(
            "Solve[ {x+y==3,y==2x},{x,y}]", 0)
print result
kernelLink.Close()

連立方程式を解いてくれます。賢い(汗

{{x -> 1, y -> 2}}

コメントを残す

メールアドレスが公開されることはありません。