Matrices and arrays
The Julia programming language provides extensive capabilities for creating and editing matrices. In this example, some of them will be considered.
To create a matrix consisting of several rows, separate the elements of the matrix with a semicolon:
a = [1 3 5; 2 4 6; 7 8 10]
Julia allows you to process all the values in a matrix using a single arithmetic operator or function by specifying a dot in front of it, which means applying the operator element-by-element.:
a .+ 10
Piecemeal exponentiation:
a .^ 3
You can also apply functions to matrices:
sin(a)
The matrix can be transposed in two ways, the first is by specifying an apostrophe.:
a'
The second way is to use the transpose function:
transpose(a)
Matrices are concatenated when they are indicated in square brackets, separated by semicolons or without them, which means, respectively, vertical and horizontal addition.:
A = [a; a]
Concatenation of matrices horizontally:
A = [a a]
You can also use complex numbers as array elements by defining them using im:
c = [3+4im 4+3im; -im 10im]