Tutorial by Examples

One can initialize a Julia array by hand, using the square-brackets syntax: julia> x = [1, 2, 3] 3-element Array{Int64,1}: 1 2 3 The first line after the command shows the size of the array you created. It also shows the type of its elements and its dimensionality (int this case Int64 ...
In Julia, Arrays have types parametrized by two variables: a type T and a dimensionality D (Array{T, D}). For a 1-dimensional array of integers, the type is: julia> x = [1, 2, 3]; julia> typeof(x) Array{Int64, 1} If the array is a 2-dimensional matrix, D equals to 2: julia> x = [1 2 ...
In Julia, you can have an Array that holds other Array type objects. Consider the following examples of initializing various types of Arrays: A = Array{Float64}(10,10) # A single Array, dimensions 10 by 10, of Float64 type objects B = Array{Array}(10,10,10) # A 10 by 10 by 10 Array. Each ele...
We can use the [] to create an empty Array in Julia. The simplest example would be: A = [] # 0-element Array{Any,1} Arrays of type Any will generally not perform as well as those with a specified type. Thus, for instance, we can use: B = Float64[] ## 0-element Array{Float64,1} C = Array{Flo...
Vectors are one-dimensional arrays, and support mostly the same interface as their multi-dimensional counterparts. However, vectors also support additional operations. First, note that Vector{T} where T is some type means the same as Array{T,1}. julia> Vector{Int} Array{Int64,1} julia> V...
It is often useful to build matrices out of smaller matrices. Horizontal Concatenation Matrices (and vectors, which are treated as column vectors) can be horizontally concatenated using the hcat function. julia> hcat([1 2; 3 4], [5 6 7; 8 9 10], [11, 12]) 2×6 Array{Int64,2}: 1 2 5 6 7 ...

Page 1 of 1