Julia Language Documentation Release Development
Total Page:16
File Type:pdf, Size:1020Kb
Julia Language Documentation Release development Jeff Bezanson, Stefan Karpinski, Viral Shah, Alan Edelman, et al. September 08, 2014 Contents 1 The Julia Manual 1 1.1 Introduction...............................................1 1.2 Getting Started..............................................2 1.3 Integers and Floating-Point Numbers..................................6 1.4 Mathematical Operations......................................... 12 1.5 Complex and Rational Numbers..................................... 17 1.6 Strings.................................................. 21 1.7 Functions................................................. 32 1.8 Control Flow............................................... 39 1.9 Variables and Scoping.......................................... 48 1.10 Types................................................... 52 1.11 Methods................................................. 66 1.12 Constructors............................................... 72 1.13 Conversion and Promotion........................................ 79 1.14 Modules................................................. 84 1.15 Metaprogramming............................................ 86 1.16 Arrays.................................................. 93 1.17 Sparse Matrices............................................. 99 1.18 Parallel Computing............................................ 100 1.19 Running External Programs....................................... 105 1.20 Calling C and Fortran Code....................................... 111 1.21 Performance Tips............................................. 115 2 The Julia Standard Library 119 2.1 Built-ins................................................. 119 2.2 Built-in Modules............................................. 160 2.3 Extras................................................... 162 2.4 Math & Numerical............................................ 187 3 Available Packages 205 3.1 ArgParse................................................. 205 3.2 Benchmark................................................ 205 3.3 BinDeps................................................. 206 3.4 BloomFilters............................................... 206 3.5 Cairo................................................... 206 3.6 Calculus................................................. 207 3.7 Calendar................................................. 207 3.8 Clp.................................................... 207 i 3.9 Clustering................................................ 208 3.10 CoinMP.................................................. 208 3.11 Color................................................... 208 3.12 Compose................................................. 209 3.13 ContinuedFractions............................................ 209 3.14 DataFrames................................................ 209 3.15 Debug................................................... 210 3.16 DecisionTree............................................... 210 3.17 Devectorize................................................ 210 3.18 DimensionalityReduction........................................ 211 3.19 Distance................................................. 211 3.20 Distributions............................................... 211 3.21 Example................................................. 212 3.22 FITSIO.................................................. 212 3.23 FastaRead................................................ 212 3.24 FileFind.................................................. 213 3.25 GLM................................................... 213 3.26 GLPK................................................... 213 3.27 GLUT.................................................. 214 3.28 Gadfly.................................................. 214 3.29 GetC................................................... 214 3.30 Graphs.................................................. 215 3.31 Grid.................................................... 215 3.32 Gtk.................................................... 215 3.33 HDF5................................................... 216 3.34 HTTP................................................... 216 3.35 Hadamard................................................ 216 3.36 HypothesisTests............................................. 217 3.37 ICU.................................................... 217 3.38 IniFile.................................................. 217 3.39 Iterators.................................................. 218 3.40 Ito..................................................... 218 3.41 JSON................................................... 218 3.42 Jyacas................................................... 219 3.43 KLDivergence.............................................. 219 3.44 LM.................................................... 219 3.45 Languages................................................ 220 3.46 LinProgGLPK.............................................. 220 3.47 Loss.................................................... 220 3.48 MAT................................................... 221 3.49 MCMC.................................................. 221 3.50 MLBase................................................. 221 3.51 MarketTechnicals............................................. 222 3.52 MathProg................................................. 222 3.53 Mongrel2................................................. 222 3.54 Mustache................................................. 223 3.55 NHST................................................... 223 3.56 Named.................................................. 223 3.57 ODBC.................................................. 224 3.58 OpenGL................................................. 224 3.59 Optim................................................... 224 3.60 Options.................................................. 225 3.61 PLX.................................................... 225 3.62 PatternDispatch.............................................. 225 ii 3.63 Profile.................................................. 226 3.64 ProjectTemplate............................................. 226 3.65 RDatasets................................................. 226 3.66 Resampling................................................ 227 3.67 Rif.................................................... 227 3.68 SDL.................................................... 227 3.69 Seq.................................................... 228 3.70 Sims................................................... 228 3.71 Stats................................................... 228 3.72 SymbolicLP............................................... 229 3.73 TextAnalysis............................................... 229 3.74 TextWrap................................................. 229 3.75 TimeSeries................................................ 230 3.76 Tk..................................................... 230 3.77 Trie.................................................... 230 3.78 UTF16.................................................. 231 3.79 WAV................................................... 231 3.80 Winston.................................................. 231 3.81 ZMQ................................................... 232 3.82 kNN................................................... 232 4 Indices and tables 233 Python Module Index 235 Python Module Index 237 iii iv CHAPTER 1 The Julia Manual Release devel Date September 08, 2014 1.1 Introduction Scientific computing has traditionally required the highest performance, yet domain experts have largely moved to slower dynamic languages for daily work. We believe there are many good reasons to prefer dynamic languages for these applications, and we do not expect their use to diminish. Fortunately, modern language design and compiler techniques make it possible to mostly eliminate the performance trade-off and provide a single environment productive enough for prototyping and efficient enough for deploying performance-intensive applications. The Julia programming language fills this role: it is a flexible dynamic language, appropriate for scientific and numerical computing, with performance comparable to traditional statically-typed languages. Julia features optional typing, multiple dispatch, and good performance, achieved using type inference and just-in-time (JIT) compilation, implemented using LLVM. It is multi-paradigm, combining features of imperative, functional, and object-oriented programming. The syntax of Julia is similar to MATLAB® and consequently MATLAB programmers should feel immediately comfortable with Julia. While MATLAB is quite effective for prototyping and exploring numerical linear algebra, it has limitations for programming tasks outside of this relatively narrow scope. Julia keeps MATLAB’s ease and expressiveness for high-level numerical computing, but transcends its general programming limitations. To achieve this, Julia builds upon the lineage of mathematical programming languages, but also borrows much from popular dynamic languages, including Lisp, Perl, Python, Lua, and Ruby. The most significant departures of Julia from typical dynamic languages are: • The core language imposes very little; the standard library is written in Julia itself, including primitive operations like integer arithmetic • A rich language of types for constructing and describing objects, that can also optionally be used to make type declarations • The ability to define function behavior across many combinations