In Julia a matrix is a tabular representation of numeric, two-dimensional (rows and columns) data. We declare it with a friendly syntax (columns separated by spaces, rows separated by semicolons).
A = [10.5 9.5; 8.5 7.5; 6.5 5.5]
A
3×2 Matrix{Float64}:
10.5 9.5
8.5 7.5
6.5 5.5
In mathematics by convention we denote matrices with a single capital letter. However, since I’m not a mathematician then I’ll use the lowercase names (they are easier for the fingers).
I remember that the first time that I was introduced to the matrix algebra I found it pretty boring and burdensome. However, believe it or not, matrices are very useful in mathematics and in everyday life, e.g statistical programs or programs rendering computer graphics rely on them heavily (chances are you used them without even being aware of it).
Anyway, here is the task. Read about matrix multiplication, e.g. on Math is Fun or watch a Khan Academy’s video on the topic and write a function with the following signature
multiply(m1::Matrix{Int}, m2::Matrix{Int})::Int
that for
# Math is Fun example
a = [1 2 3; 4 5 6]
2×3 Matrix{Int64}:
1 2 3
4 5 6
and
# Math is Fun example
b = [7 8; 9 10; 11 12]
3×2 Matrix{Int64}:
7 8
9 10
11 12
Should return the following matrix
[58 64; 139 154]
2×2 Matrix{Int64}:
58 64
139 154
Compare multiply
against Julia’s built-in *
operator (on some matrices of your choice) to ensure its correct functioning.