官术网_书友最值得收藏!

Installing and working with IJulia

IJulia (https://github.com/JuliaLang/IJulia.jl) is a combination of the IPython web frontend interactive environment (http://ipython.org/) with a Julia-language backend. It allows you to work with IPython's powerful graphical notebook (which combines code, formatted text, math, and multimedia in a single document) with qtconsole and regular REPL. Detailed instructions for installation are found at the GitHub page for IJulia (https://github.com/JuliaLang/IJulia.jl) and in the Julia at MIT notes (https://github.com/stevengj/julia-mit/blob/master/README.md). Here is a summary of the steps:

  1. Install Version 1.0 or later of IPython via easy_install or pip (on OS X and Windows, this is included in the Anaconda Python installation). On Linux, use apt-get install ipython. (For more information, refer to the IPython home page).
  2. Install PyQt4 or PySide for qtconsole.
  3. Install the IJulia package from the REPL with Pkg.add("IJulia").
  4. Install the PyPlot package with Pkg.add("PyPlot").

You can work with IJulia in either of two ways:

  • Start an IPython notebook in your web browser by typing the following command in a console:
    ipython notebook --profile julia
    
  • Start qtconsole with:
    ipython qtconsole --profile Julia
    
Installing and working with IJulia

The IJulia dashboard on Ubuntu

Verify that you have started IJulia. You must see IJ and the Julia logo in the upper-left corner of the browser window. Julia code is entered in the input cells (input can be multiline) and then executed with Shift + Enter. Here is a small example:

Installing and working with IJulia

An IJulia session example

In the first input cell, the value of b is calculated from a:

a = 5
b = 2a^2 + 30a + 9

In the second input cell, we use PyPlot (this requires the installation of matplotlib; for example, on Linux, this is done by sudo apt-get install python-matplotlib).

The linspace(0, 5) command defines an array of 100 equally spaced values between 0 and 5, y is defined as a function of x and is then shown graphically with the plot as follows:

using PyPlot
x = linspace(0, 5)
y = cos(2x + 5)
plot(x, y, linewidth=2.0, linestyle="--")
title("a nice cosinus")
xlabel("x axis")
ylabel("y axis")

Save a notebook in file format (with the extension .ipynb) by downloading it from the menu. If working in an IPython notebook is new for you, you can take a look at the demo at http://ipython.org/notebook.html to get started. After installing a new Julia version, always run Pkg.build("IJulia") in the REPL in order to rebuild the IJulia package with this new version.

主站蜘蛛池模板: 易门县| 崇信县| 交口县| 阿合奇县| 伊通| 温宿县| 高唐县| 高平市| 大方县| 台中县| 阿图什市| 仪征市| 罗定市| 冷水江市| 太康县| 寻甸| 乌兰县| 若尔盖县| 平阴县| 金门县| 太保市| 永宁县| 项城市| 孝义市| 彭阳县| 罗田县| 万年县| 乌鲁木齐县| 鄂伦春自治旗| 琼中| 青川县| 辽中县| 凭祥市| 长海县| 惠水县| 利川市| 西藏| 昭觉县| 翼城县| 罗田县| 南木林县|