Created
September 7, 2019 02:12
-
-
Save genkuroki/24e7090e08c7f99b11e64091d90a6076 to your computer and use it in GitHub Desktop.
/Math/Math0027/MathLink.jlのインストールの仕方.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "# MathLink.jlのインストールの仕方\n\n黒木玄\n\n2019-09-07\n\n[MathLink.jl](https://github.com/JuliaInterop/MathLink.jl) は MathLink ライブラリを利用して, Mathematica または WolframEngine の MathKernel を利用するためのパッケージです.\n\n私は [Free Wolfram Engine](https://nbviewer.jupyter.org/github/genkuroki/msfd28/blob/master/Free+Wolfram+Engine.ipynb) をインストールして利用しています. 環境は Windows 8.1 です.\n\n**インストール方法**\n\n(1) 環境変数の設定. `JULIA_MATHKERNEL` と `JULIA_MATHLINK` の2つの環境変数を設定します. 私は以下のように設定しました. 各自の環境の合わせて設定して下さい.\n\n```\nJULIA_MATHKERNEL = C:\\Program Files\\Wolfram Research\\Wolfram Engine\\12.0\\MathKernel.exe\nJULIA_MATHLINK = C:\\Program Files\\Wolfram Research\\Wolfram Engine\\12.0\\SystemFiles\\Links\\MathLink\\DeveloperKit\\Windows-x86-64\\SystemAdditions\\ml64i4.dll\n```\n\n[MathLink.jl](https://github.com/JuliaInterop/MathLink.jl) のREADMEでは `JULIA_MATHLINL` を「Windows では libML64.dll または libML32.dll」という名前のライブラリのパスを設定しろと書いてあるのですが, 私の環境では ml64i4.dll にする必要がありました. この辺は柔軟かつ正しくに対処することが要求されます. 柔軟に正しく対処するためにはコンピューターに関する直観的で正しい理解が必要であり, そういう部分でも教養が問われることになるのだと思います. [Windowsでの環境変数の設定の仕方](https://www.google.com/search?q=Windows%E3%81%A7%E3%81%AE%E7%92%B0%E5%A2%83%E5%A4%89%E6%95%B0%E3%81%AE%E8%A8%AD%E5%AE%9A%E3%81%AE%E4%BB%95%E6%96%B9)が分からないなら, 検索してみて下さい.\n\n(2) julia を起動して `]` を押してパッケージモードで以下を実行する.\n\n```\npkg> add https://github.com/JuliaInterop/MathLink.jl.git\n```\n\n(3) エラーが出たら, (1)に戻ってやり直す." | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "versioninfo()", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "Julia Version 1.2.0\nCommit c6da87ff4b (2019-08-20 00:03 UTC)\nPlatform Info:\n OS: Windows (x86_64-w64-mingw32)\n CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz\n WORD_SIZE: 64\n LIBM: libopenlibm\n LLVM: libLLVM-6.0.1 (ORCJIT, haswell)\nEnvironment:\n JULIA_CMDSTAN_HOME = C:\\CmdStan\n JULIA_MATHKERNEL = C:\\Program Files\\Wolfram Research\\Wolfram Engine\\12.0\\MathKernel.exe\n JULIA_MATHLINK = C:\\Program Files\\Wolfram Research\\Wolfram Engine\\12.0\\SystemFiles\\Links\\MathLink\\DeveloperKit\\Windows-x86-64\\SystemAdditions\\ml64i4.dll\n JULIA_NUM_THREADS = 4\n JULIA_PKGDIR = C:\\JuliaPkg\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "using MathLink", | |
"execution_count": 2, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "W\"Sin\"", | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 3, | |
"data": { | |
"text/plain": "W\"Sin\"" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sin1 = W\"Sin\"(1.0)", | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 4, | |
"data": { | |
"text/plain": "W\"Sin\"(1.0)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sinx = W\"Sin\"(W\"x\")", | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 5, | |
"data": { | |
"text/plain": "W\"Sin\"(W\"x\")" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "W`Sin[1]`", | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 6, | |
"data": { | |
"text/plain": "W\"Sin\"(1)" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "weval(sin1)", | |
"execution_count": 7, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 7, | |
"data": { | |
"text/plain": "0.8414709848078965" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "weval(sinx)", | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 8, | |
"data": { | |
"text/plain": "W\"Sin\"(W\"x\")" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "weval(W\"Integrate\"(sinx, (W\"x\", 0, 1)))", | |
"execution_count": 9, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 9, | |
"data": { | |
"text/plain": "W\"Plus\"(1, W\"Times\"(-1, W\"Cos\"(1)))" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "weval(W`Integrate[Sin[x], {x, 0, 1}]`)", | |
"execution_count": 10, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 10, | |
"data": { | |
"text/plain": "W\"Plus\"(1, W\"Times\"(-1, W\"Cos\"(1)))" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "このように現在の MathLink.jl の仕様では表示が数式に整形されません. しかし, これによって, Julia言語からWolfram言語を使用する道が開かれたわけで, さらなる発展が期待されます." | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "julia-1.2", | |
"display_name": "Julia 1.2.0", | |
"language": "julia" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.2.0" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": true, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "/Math/Math0027/MathLink.jlのインストールの仕方.ipynb", | |
"public": true | |
} | |
}, | |
"@webio": { | |
"lastKernelId": null, | |
"lastCommId": null | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment