Matrices
Matrix
A matrix is a collection of numbers that can be indexed in a particular way, this indexing mimics a two dimensional grid. The dimensions of a matrix are stated as where
r
,
c
∈
N
1
when it has
m
rows and
n
columns.
Suppose that
A
is a matrix, then we can access the value at the
i
-th row and
j
-th column by writing
A
i
,
j
, we can graphically represent this information by introducing variables for the coefficients and writing them like this:
A
=
[
a
1
,
1
a
1
,
2
…
a
1
,
n
a
2
,
1
a
2
,
2
…
a
2
,
n
⋮
⋮
⋱
⋮
a
m
,
1
a
m
,
2
…
a
m
,
n
]
Matrices are denoted by capital letters such as
A
,
B
,
M
,
N
.
Set of Matrices
Suppose that
r
,
c
∈
N
1
then we denote the set of all
r
×
c
matrices with cofficients from the set
T
as
M
r
×
c
(
T
)
Row Matrix
Any matrix
R
∈
M
1
×
c
(
T
)
for some
c
∈
N
1
is known as a row matrix.
Row of a Matrix
Suppose that
A
is a matrix, then if we want to extract the
i
−
t
h
row of
A
we can write
A
i
,
−
.
Note that this is a function of the form
M
r
×
c
(
T
)
→
M
1
×
c
(
T
)
The notation
A
i
,
−
intends to mimic freezing at a certain row and then sweeping over all columns.
Row Matrix Representation
Given a matrix
A
, there is an associated
row matrix representation, of the following form
A
=
[
←
A
1
,
−
→
←
A
2
,
−
→
←
⋮
→
←
A
m
,
−
→
]
Where the arrows are there to remind you that they expand horizontally. Also observe that this matrix is an element of
M
r
×
1
(
M
1
×
c
(
R
)
)
Column Matrix
Any matrix
C
∈
M
r
×
1
(
T
)
for some
r
∈
N
1
is known as a row matrix.
We will denote column or row matrices with a lower case boldfaced character, like
x
Column of a Matrix
Suppose that
A
is a matrix, then if we want to extract the
j
-th row of
A
we can write
A
∣
,
j
.
Note that this is a function of the form
M
r
×
c
(
T
)
→
M
r
×
1
(
T
)
The
∣
denotes that the row variable may be varied vertically, while the column index is fixed in place. If we want to represent the matrix as columns graphically, we may do so like this
Column Matrix Representation
Given a matrix
A
, there is an associated
column matrix representation, of the following form
A
=
[
↑
↑
↑
↑
A
∣
,
1
A
∣
,
2
…
A
∣
,
n
↓
↓
↓
↓
]
Where the arrows are there to remind you that they expand graphically expand vertically. Also observe that this matrix is an element of
M
1
×
c
(
M
r
×
1
(
R
)
)
.
We can connect some of the previous definitions here to say that
R
is a
column matrix whose entries are
row matrices.
Matrix Multiplication
Suppose
r
A
,
c
A
,
r
B
,
c
B
∈
N
1
such that
c
A
=
r
B
and that we have two matrices
A
,
B
∈
M
r
A
×
c
A
(
R
)
,
M
r
B
×
c
B
(
R
)
, defined as
A
=
[
a
1
,
1
a
1
,
2
…
a
1
,
c
A
a
2
,
1
a
2
,
2
…
a
2
,
c
A
⋮
⋮
⋱
⋮
a
r
A
,
1
a
r
A
,
2
…
a
r
A
,
c
A
]
,
B
=
[
b
1
,
1
b
1
,
2
…
b
1
,
c
B
b
2
,
1
b
2
,
2
…
b
2
,
c
B
⋮
⋮
⋱
⋮
b
r
B
,
1
b
r
B
,
2
…
b
r
B
,
c
B
]
Then we define the matrix multiplication of
A
and
B
as the matrix
P
∈
M
r
A
×
c
B
P
=
[
c
1
,
1
c
1
,
2
…
c
1
,
c
P
c
2
,
1
c
2
,
2
…
c
2
,
c
P
⋮
⋮
⋱
⋮
c
r
P
,
1
c
r
P
,
2
…
c
r
P
,
c
P
]
Where:
c
i
,
j
:=
a
i
,
1
b
1
,
j
+
a
i
,
2
b
2
,
j
+
⋯
+
a
i
,
c
A
b
c
A
,
j
=
∑
k
=
1
c
A
a
i
,
k
b
k
,
j
Matrix Functions
Suppose that
M
∈
M
r
,
c
(
T
)
and that
f
:
T
→
S
is a function, then we augment this function to
f
:
M
r
,
c
(
T
)
→
M
r
,
c
(
S
)
as follows:
f
(
[
m
1
,
1
m
1
,
2
…
m
1
,
c
M
m
2
,
1
m
2
,
2
…
m
2
,
c
M
⋮
⋮
⋱
⋮
m
r
M
,
1
m
r
M
,
2
…
m
r
M
,
c
M
]
)
=
[
f
(
m
1
,
1
)
f
(
m
1
,
2
)
…
f
(
m
1
,
c
M
)
f
(
m
2
,
1
)
f
(
m
2
,
2
)
…
f
(
m
2
,
c
M
)
⋮
⋮
⋱
⋮
f
(
m
r
M
,
1
)
f
(
m
r
M
,
2
)
…
f
(
m
r
M
,
c
M
)
]
Packing Function
Suppose that
x
∈
R
, then we define the following function
pack
:
R
→
M
1
×
1
(
R
)
as
pack
(
x
)
:=
[
x
]
Unpacking Function
Suppose that
[
x
]
∈
M
1
×
1
(
R
)
, then we define the following function
unpack
:
R
→
M
1
×
1
(
R
)
as
unpack
(
[
x
]
)
:=
x
The Packing and Unpacking Functions are Inverses
TODO
One by one Matrices are Isomorphic to R
R
and
M
1
,
1
(
R
)
are isomorphic.
Row and Column Matrices are Isomorphic to
R
n
Suppose that
n
∈
N
1
, then
M
1
,
n
(
R
)
and
M
n
,
1
(
R
)
are isomorphic to
R
n
Nested Matrix Multiplication Unpacking
Given two matrices
A
∈
M
a
×
b
(
R
)
B
∈
M
c
×
d
(
R
)
then
product is equal to
unpack
(
[
A
1
,
−
⋅
B
∣
,
1
A
1
,
−
⋅
B
∣
,
2
…
A
1
,
−
⋅
B
∣
,
d
A
2
,
−
⋅
B
∣
,
1
A
2
,
−
⋅
B
∣
,
2
…
A
2
,
−
⋅
B
∣
,
d
⋮
⋮
⋱
⋮
A
a
,
−
⋅
B
∣
,
1
A
a
,
−
⋅
B
∣
,
2
…
A
a
,
−
⋅
B
∣
,
d
]
)
With
A
i
,
−
B
∣
,
j
and
unpack
is being used as a matrix function
Matrix Multiplication with Rows and Columns
Suppose that
A
,
B
are matrices, and that
A
R
,
B
C
are their row matrix and column matrix representations, then
unpack
(
A
R
B
C
)
=
A
B
where
unpack
is being used as a
matrix function
column matrix multiplication
suppose that
C
=
[
c
1
c
2
⋮
c
k
]
is a column matrix and
M
∈
M
n
×
k
(
R
)
, then
M
C
=
∑
i
=
1
k
c
i
M
|
,
i
}
∈
M
n
×
1
(
R
)
By the definition of matrix multiplication the answer should be equal to
[
m
1
,
1
m
1
,
2
…
m
1
,
k
m
2
,
1
m
2
,
2
,
…
m
2
,
k
⋮
⋮
⋱
⋮
m
j
,
1
m
j
,
2
…
m
j
,
k
]
[
c
1
c
2
⋮
c
k
]
=
[
c
1
⋅
m
1
,
1
+
c
2
⋅
m
1
,
2
+
…
+
c
k
⋅
m
1
,
k
c
1
⋅
m
2
,
1
+
c
2
⋅
m
2
,
2
+
…
+
c
k
⋅
m
2
,
k
⋮
c
1
⋅
m
j
,
1
+
c
2
⋅
m
j
,
2
+
…
+
c
k
⋅
m
j
,
k
]
=
c
1
M
|
,
1
}
+
c
2
M
|
,
2
}
+
…
+
c
k
M
|
,
k
}
∈
M
n
×
1
(
R
)
unit column matrix
e
i
is a column matrix who's i-th row is
1
and the rest are
0
column extraction
suppose
M
∈
M
j
×
k
then the
n
-th column of
M
is given by
M
multiplied by
e
n
(where
1
≤
n
≤
k
)
Due to the way that column matrix multiplication works, we can see that
M
e
n
=
∑
i
=
0
k
(
e
n
)
i
M
|
,
i
}
=
M
|
,
n
}
this is clear since only the
n
-th component of
e
n
is
1
and the rest are
0
.