julia_port

所属分类:数学计算
开发工具:Elixir
文件大小:0KB
下载次数:0
上传日期:2018-10-15 09:01:36
上 传 者sh-1993
说明:  使用端口和元编程调用elixir中的julia函数进行科学计算的示例项目,
(example project to invoke julia functions in elixir to do scientific computing using port and metaprogramming,)

文件列表:
.formatter.exs (84, 2018-10-15)
LICENSE (1066, 2018-10-15)
config/ (0, 2018-10-15)
config/config.exs (1123, 2018-10-15)
data/ (0, 2018-10-15)
data/test (377653, 2018-10-15)
data/train (1453165, 2018-10-15)
doc/ (0, 2018-10-15)
doc/.build (246, 2018-10-15)
doc/404.html (2830, 2018-10-15)
doc/JuliaPort.GenFunction.html (4395, 2018-10-15)
doc/JuliaPort.html (16842, 2018-10-15)
doc/api-reference.html (3440, 2018-10-15)
doc/dist/ (0, 2018-10-15)
doc/dist/app-240d7fc7e5.css (23120, 2018-10-15)
doc/dist/app-a0c90688fa.js (219248, 2018-10-15)
doc/dist/sidebar_items-ac571aa12f.js (1216, 2018-10-15)
doc/fonts/ (0, 2018-10-15)
doc/fonts/icomoon.eot (3096, 2018-10-15)
doc/fonts/icomoon.svg (6884, 2018-10-15)
doc/fonts/icomoon.ttf (2932, 2018-10-15)
doc/fonts/icomoon.woff (3008, 2018-10-15)
doc/index.html (311, 2018-10-15)
doc/search.html (2602, 2018-10-15)
julia/ (0, 2018-10-15)
julia/lr.jl (640, 2018-10-15)
lib/ (0, 2018-10-15)
lib/gen_function.ex (1532, 2018-10-15)
lib/julia_port.ex (3157, 2018-10-15)
mix.exs (1363, 2018-10-15)
mix.lock (1060, 2018-10-15)
test/ (0, 2018-10-15)
test/julia_port_test.exs (120, 2018-10-15)
test/test_helper.exs (15, 2018-10-15)

## julia_port example project to invoke julia functions in elixir to do scientific computing using port and metaprogramming ### news * support julia v1.0.1 * support elixir v1.7.3 * support erlang 21.0 * the script_test is supported * the real_test is removed because it does not support julia v1.0.1 ### remarks * the author will experiment with [tensorflow.jl](https://github.com/malmaud/TensorFlow.jl) for good reason ### prerequisite * [julia](http://julialang.org/) installed and its access from shell ### Installation the package can be installed by adding `julia_port` to your list of dependencies in `mix.exs`: ```elixir def deps do [{:julia_port, "~> 0.2.0"}] end ``` remark: if you install the package as a dependency, in order to run `script_test`, you have to move `./deps/julia_port/julia` and `./deps/julia_port/data` to `./julia` and `./data` respectively ### usage * simple_test: arithmetics ```elixir def simple_test(port) do port_send(port, "1+2") IO.puts port_receive(port, true) end ``` * complex_test: linear algebra ```elixir use GenFunction, [rand: 2, sum: 1, *: 2] def complex_test(port) do rand(port, :a, 3, 3) rand(port, :b, 3, 3) JuliaPort.*(port, :c, :a, :b) port_receive(port, false) sum(port, :d, :c) IO.puts port_receive(port, true) end ``` * script_test: linear regression ```elixir use GenFunction, [load_data: 1, lr_train: 2, lr_test: 3] def script_test(port) do include_script(port, "./julia/lr.jl") load_data(port, {:x_train, :y_train}, "./data/train") load_data(port, {:x_test, :y_test}, "./data/test") lr_train(port, :beta, :x_train, :y_train) port_receive(port, false) lr_test(port, :error, :x_test, :y_test, :beta) IO.puts port_receive(port, true) end ``` * run ```elixir iex -S mix port = JuliaPort.init # => #Port<0.5310> JuliaPort.print_version port # => received data: v"1.0.0" JuliaPort.simple_test port # => received data: 3 JuliaPort.complex_test port # => received data: 5.710327361153192 JuliaPort.script_test port # => received data: 0.9587912087912088 JuliaPort.terminate port # => {#PID<0.143.0>, :close} ```

近期下载者

相关文件


收藏者