当前位置:K88软件开发文章中心编程语言非主流编程语言Julia → 文章内容

Julia 开始

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 16:28:01

由 陈 创建, 最后一次修改 2016-08-12 开始Julia 的安装,不管是使用编译好的程序,还是自己从源代码编译,都很简单。按照 这儿 的说明下载并安装即可。使用交互式会话(也记为 repl),是学习 Julia 最简单的方法:$ julia _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_) | Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type "help()" to list help topics | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.3.0-prerelease+3690 (2014-06-16 05:11 UTC) _/ |\__'_|_|_|\__'_| | Commit 1b73f04* (0 days old master)|__/ | x86_64-apple-darwin13.1.0julia> 1 + 23julia> ans3输入 ^D — ctrl 键加 d 键,或者输入 quit() ,可以退出交互式会话。交互式模式下, julia 会显示一个横幅,并提示用户来输入。一旦用户输入了完整的表达式,例如 1 + 2 ,然后按回车,交互式会话就对表达式求值并返回这个值。如果输入的表达式末尾有分号,就不会显示它的值了。变量 ans 的值就是上一次计算的表达式的值,无论上一次是否被显示。变量 ans 仅适用于交互式会话,不适用于以其它方式运行的 Julia 代码。如果想运行写在源文件 file.jl 中的代码,可以输入命令 include("file.jl") 。要在非交互式模式下运行代码,你可以把它当做 Julia 命令行的第一个参数:$ julia script.jl arg1 arg2...如这个例子所示,julia 后面跟着的命令行参数,被认为是程序 script.jl 的命令行参数。这些参数使用全局变量 ARGS 来传递。使用 -e 选项,也可以在命令行设置 ARGS 参数。可如下操作,来打印传递的参数:$ julia -e 'for x in ARGS; println(x); end' foo barfoobar也可以把代码放在一个脚本中,然后运行:$ echo 'for x in ARGS; println(x); end' > script.jl$ julia script.jl foo barfoobarJulia 可以用 -p 或 --machinefile 选项来开启并行模式。 -p n 会发起额外的 n 个工作进程,而 --machinefile file 会为文件 file 的每一行发起一个工作进程。 file 定义的机器,必须要能经由无密码的 ssh 访问,且每个机器上的 Julia 安装的位置应完全相同,每个机器的定义为 [user@]host[:port] [bind_addr] 。 user 默认为当前的用户,port 默认为标准 ssh 端口。可选择的,万一是多网主机,bind_addr 可被用来精确指定接口。如果你想让 Julia 在启动时运行一些代码,可以将代码放入 ~/.juliarc.jl :$ echo 'println("Greetings! 你好! ??????")' > ~/.juliarc.jl$ juliaGreetings! 你好! ??????...运行 Julia 有各种可选项:julia [options] [program] [args...] -v, --version Display version information -h, --help Print this message -q, --quiet Quiet startup without banner -H, --home <dir> Set location of julia executable -e, --eval <expr> Evaluate <expr> -E, --print <expr> Evaluate and show <expr> -P, --post-boot <expr> Evaluate <expr> right after boot -L, --load <file> Load <file> right after boot on all processors -J, --sysimage <file> Start up with the given system image file -p <n> Run n local processes --machinefile <file> Run processes on hosts listed in <file> -i Force isinteractive() to be true --no-history-file Don't load or save history -f, --no-startup Don't load ~/.juliarc.jl -F Load ~/.juliarc.jl, then handle remaining inputs --color={yes|no} Enable or disable color text --code-coverage Count executions of source lines --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations) --int-literals={32|64} Select integer literal size independent of platform资源除了本手册,还有一些其它的资源:Julia 和 IJulia 使用说明速学 JuliaMIT 讲师 Homer Reid 数值分析课的教程介绍 julia 的演讲来自 MIT 的 Julia 视频教程Forio 的 Julia 教程

Julia 开始