Julia Language Documentation Release development Jeff Bezanson, Stefan Karpinski, Viral Shah, Alan Edelman, et al. February 02, 2013 CONTENTS 1 The Julia Manual 1 1.1 Introduction...............................................1 1.2 Getting Started..............................................2 1.3 Integers and Floating-Point Numbers..................................4 1.4 Mathematical Operations......................................... 11 1.5 Complex and Rational Numbers..................................... 16 1.6 Strings.................................................. 20 1.7 Functions................................................. 31 1.8 Control Flow............................................... 37 1.9 Variables and Scoping.......................................... 47 1.10 Types................................................... 51 1.11 Methods................................................. 65 1.12 Constructors............................................... 71 1.13 Conversion and Promotion........................................ 78 1.14 Arrays.................................................. 83 1.15 Sparse Matrices............................................. 88 1.16 Modules................................................. 90 1.17 Running External Programs....................................... 92 1.18 Metaprogramming............................................ 97 1.19 Parallel Computing............................................ 104 1.20 Calling C and Fortran Code....................................... 109 1.21 Performance Tips............................................. 113 2 The Julia Standard Library 117 2.1 Built-ins................................................. 117 2.2 Built-in Modules............................................. 150 2.3 Extras................................................... 155 2.4 Math & Numerical............................................ 179 3 Available Packages 197 3.1 ArgParse................................................. 197 3.2 Benchmark................................................ 197 3.3 BinDeps................................................. 197 3.4 Cairo................................................... 198 3.5 Calculus................................................. 198 3.6 Calendar................................................. 198 3.7 Clp.................................................... 199 3.8 Clustering................................................ 199 3.9 Color................................................... 199 i 3.10 Compose................................................. 200 3.11 DataFrames................................................ 200 3.12 Debug................................................... 200 3.13 DecisionTree............................................... 201 3.14 DimensionalityReduction........................................ 201 3.15 Distributions............................................... 201 3.16 Example................................................. 202 3.17 FITSIO.................................................. 202 3.18 FastaRead................................................ 202 3.19 FileFind.................................................. 203 3.20 GLM................................................... 203 3.21 GLUT.................................................. 203 3.22 Gadfly.................................................. 204 3.23 GetC................................................... 204 3.24 Graphs.................................................. 204 3.25 Grid.................................................... 205 3.26 HDF5................................................... 205 3.27 HTTP................................................... 205 3.28 HypothesisTests............................................. 206 3.29 ICU.................................................... 206 3.30 IniFile.................................................. 206 3.31 Iterators.................................................. 207 3.32 Ito..................................................... 207 3.33 JSON................................................... 207 3.34 Jump................................................... 208 3.35 KLDivergence.............................................. 208 3.36 LM.................................................... 208 3.37 Languages................................................ 209 3.38 Loss.................................................... 209 3.39 MAT................................................... 209 3.40 MCMC.................................................. 210 3.41 Mongrel2................................................. 210 3.42 Mustache................................................. 210 3.43 NHST................................................... 211 3.44 Named.................................................. 211 3.45 ODBC.................................................. 211 3.46 OpenGL................................................. 212 3.47 Optim................................................... 212 3.48 Options.................................................. 212 3.49 PLX.................................................... 213 3.50 PatternDispatch.............................................. 213 3.51 Profile.................................................. 213 3.52 ProjectTemplate............................................. 214 3.53 RDatasets................................................. 214 3.54 Resampling................................................ 214 3.55 Rif.................................................... 215 3.56 SDL.................................................... 215 3.57 Sims................................................... 215 3.58 SymbolicLP............................................... 216 3.59 TextAnalysis............................................... 216 3.60 TextWrap................................................. 216 3.61 Thyme.................................................. 217 3.62 Tk..................................................... 217 3.63 Trie.................................................... 217 ii 3.64 UTF16.................................................. 218 3.65 WAV................................................... 218 3.66 Winston.................................................. 218 3.67 ZMQ................................................... 219 3.68 kNN................................................... 219 4 Indices and tables 221 Python Module Index 223 Python Module Index 225 iii iv CHAPTER ONE THE JULIA MANUAL Release devel Date February 01, 2013 1.1 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® pro- grammers 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 pro- gramming 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 of argument types via multiple dispatch • Automatic generation of efficient, specialized code for different argument types • Good performance, approaching that of statically-compiled languages like C Although one sometimes speaks of dynamic languages as being “typeless”, they are definitely not: every object, whether primitive or user-defined, has a type. The lack of type declarations in most dynamic languages, however, means that one cannot instruct the compiler about the types of values, and often cannot explicitly talk about types at all. In static languages, on the other hand, while one can — and usually must — annotate types for the compiler, types exist only at compile time and cannot be manipulated or expressed at run time. In Julia, types are themselves run-time objects, and can also be used to convey information to the compiler. 1 Julia Language Documentation, Release development While the casual programmer need not explicitly use types or multiple dispatch, they are the core unifying features of Julia: functions are defined on different combinations of argument types, and applied
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages231 Page
-
File Size-