Matrices

We know that the notation [1, 2, 3] is used to create an array. In fact, this notation denotes a special type of array, called a (column) vector in Julia, as shown in the following screenshot:

To create this as a row vector (1 2 3), use the notation [1 2 3] with spaces instead of commas. This array is of type 1 x 3 Array{Int64,2}, so it has two dimensions. (The spaces used in [1, 2, 3] are for readability only, we could have written this as [1,2,3]).

A matrix is a two- or multidimensional array (in fact, a matrix is an alias for the two-dimensional case). We can write this as follows:

Array{Int64, 1} == Vector{Int64} #> true Array{Int64, ...

Get Julia 1.0 Programming Complete Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.