Julia Programming Language - RxJS, ggplot2, Python Data ...

Julia Programming 1

Julia Programming

About the Tutorial

One of the facts about scientific programming is that it requires high performance flexible dynamic programming language. Unfortunately, to a great extent, the domain experts have moved to slower dynamic programming languages. There can be many good reasons for using such dynamic programming languages and, in fact, their use cannot be diminished as well. On the flip side, what can we expect from modern language design and compiler techniques? Some of the expectations are as follows:

It should eradicate the performance trade-off.

It should provide the domain experts a single environment that is productive enough for prototyping and efficient for deploying performance-intensive applications.

The Julia programming language fulfill these expectations. It is a general purpose highperformance flexible programming language which can be used to write any applications. It is well-suited for scientific and numerical computing.

Audience

This tutorial will be useful for graduates, post-graduates, and research students who either have an interest in Julia Programming or have these subjects as a part of their curriculum. The reader can be a beginner or an advanced learner.

Prerequisites

The reader should have knowledge on basic computer programming languages.

Copyright & Disclaimer

Copyright 2020 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at contact@

2

Julia Programming

Table of Contents

About the Tutorial ........................................................................................................................................... 2 Audience.......................................................................................................................................................... 2 Prerequisites.................................................................................................................................................... 2 Copyright & Disclaimer .................................................................................................................................... 2 Table of Contents ............................................................................................................................................ 3 1. Julia -- Overview ....................................................................................................................................10 What is Julia Programming Language?.......................................................................................................... 10 History of Julia ............................................................................................................................................... 10 Features of Julia............................................................................................................................................. 11 The Scope of Julia .......................................................................................................................................... 11 Comparison with other languages................................................................................................................. 12 2. Julia Programming -- Environment Setup...............................................................................................13 Installing Julia ................................................................................................................................................ 13 Julia's working environment.......................................................................................................................... 15 Packages ........................................................................................................................................................ 16 Installing IJulia ............................................................................................................................................... 20 Installing Juno ................................................................................................................................................ 21 3. Julia Programming -- Basic Syntax..........................................................................................................22 Variables ........................................................................................................................................................ 22 Comments ..................................................................................................................................................... 23 4. Julia -- Arrays .........................................................................................................................................24 Creating Simple 1D Arrays ............................................................................................................................. 24 Creating 2D arrays & matrices....................................................................................................................... 26 Creating arrays using range objects .............................................................................................................. 26 Creating arrays using comprehensions and generators ................................................................................ 29 Populating an Array ....................................................................................................................................... 30

3

Julia Programming

Array Constructor .......................................................................................................................................... 32 Arrays of arrays ............................................................................................................................................. 33 Copying arrays ............................................................................................................................................... 33 Matrix Operations ......................................................................................................................................... 33 Accessing the contents of arrays ................................................................................................................... 34 Adding Elements............................................................................................................................................ 36 Removing Elements ....................................................................................................................................... 38 5. Julia -- Tuples .........................................................................................................................................41 Creating tuples .............................................................................................................................................. 41 Named tuples ................................................................................................................................................ 42 Creating named tuples .................................................................................................................................. 42 Named tuples as keyword arguments ........................................................................................................... 44 6. Julia -- Integers and Floating-Point Numbers .........................................................................................45 Integers.......................................................................................................................................................... 45 Floating-point numbers ................................................................................................................................. 47 Special floating-point values ......................................................................................................................... 49 7. Julia -- Rational and Complex Numbers..................................................................................................51 Rational Numbers .......................................................................................................................................... 51 Complex Numbers ......................................................................................................................................... 52 8. Julia -- Basic Operators ..........................................................................................................................55 Arithmetic Operators..................................................................................................................................... 55 Bitwise Operators .......................................................................................................................................... 56 Updating Operators....................................................................................................................................... 57 Vectorized "dot" Operators........................................................................................................................... 58 Numeric Comparisons Operators .................................................................................................................. 59 Chaining Comparisons ................................................................................................................................... 60 Operator Precedence & Associativity............................................................................................................ 61 9. Julia -- Basic Mathematical Functions ....................................................................................................63

4

Julia Programming

Numerical Conversions.................................................................................................................................. 63 Rounding functions........................................................................................................................................ 64 Division functions .......................................................................................................................................... 66 Sign and Absolute value functions ................................................................................................................ 68 Power, Logs, and Roots ................................................................................................................................. 70 Trigonometric and hyperbolic functions ....................................................................................................... 73 10. Julia -- Strings.........................................................................................................................................75 Characters...................................................................................................................................................... 75 Unicode and UTF-8 ........................................................................................................................................ 77 String Concatenation ..................................................................................................................................... 78 Interpolation.................................................................................................................................................. 79 Triple-quoted strings ..................................................................................................................................... 79 Common String Operations ........................................................................................................................... 80 Non-standard String Literals.......................................................................................................................... 81 11. Julia -- Functions ....................................................................................................................................84 Defining Functions......................................................................................................................................... 84 Optional Arguments ...................................................................................................................................... 85 Keyword Arguments ...................................................................................................................................... 86 Anonymous Functions ................................................................................................................................... 87 Recursive Functions....................................................................................................................................... 87 Map ............................................................................................................................................................... 88 Filter .............................................................................................................................................................. 89 Generic Functions.......................................................................................................................................... 89 Multiple dispatch........................................................................................................................................... 89 12. Julia -- Flow Control ...............................................................................................................................91 Ternary expressions....................................................................................................................................... 91 Boolean Switching expressions ..................................................................................................................... 91 If, elseif and else ............................................................................................................................................ 92

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download