Matrix definition: Matrices, Tensors, and their applications
Zero Matrix
Identity Matrix
2. Operations
Transpose
Inverse
Matrix Arithmetics
Matrix-Tensor products
Introduction
A matrix, A∈Rn×m is a two-dimensional array of scalars: ⎣⎢⎢⎢⎢⎡a1,1a2,1⋮an,1a1,2a2,2⋮an,2……⋮…a1,ma2,m⋮an,m⎦⎥⎥⎥⎥⎤
Diagonals
DONE
Every matrix has 2 diagonals:
Main diagonal (or principal diagonal, primary diagonal, leading diagonal, major diagonal) is the list of entries Ai,j(i=j) while the other entries are zeroes.
⎣⎢⎢⎢⎢⎡10⋮001⋱………1…00⋮1⎦⎥⎥⎥⎥⎤
Antidiagonal (or Harrison diagonal, secondary diagonal, trailing diagonal), of a square matrixB∈RN×N, is a collection of entries Bi,j:i+j=N+1,∀1≤i,j≤N
⎣⎢⎢⎢⎢⎡00⋮10…1……1⋱…10⋮0⎦⎥⎥⎥⎥⎤
Traces
WIP
The trace of a square matrix A∈Rn×n, denoted as tr(A) (or trA), is the sum of diagonal elements:
tr(A)=i=1∑nai,i
Norms
WIP
Similar to Vectors, Matrices can also possess Norms, such as Frobenius norm.
∥A∥F=i=1∑mj=1∑nAi,j2=tr(ATA)
Orthogonal
WIP
Just like Vectors, a square matrix A∈Rn×n is orthogonal if all of its columns are orthogonal to each other and are normalized.
As a result,
ATA=I=AAT
note: The columns of A are referred to as being orthonormal (different from orthogonal)
In other words, the inverse of an orthogonal matrix is its transpose.
Question: Why A must be a square matrix Answer: Even if the columns of A∈Rn×m,n=m are orthonormal, I=ATA=AAT Hence the term orthogonal is only used when A is square.
Operating on a vector with an orthogonal matrix will not change its Euclidean norm: ∥Ax∥2=∥x∥2
Ranks
WIP
Column and Row Ranks
Suppose there is a matrix A∈Rm×n:
Column rank
Let C be the largest set of linearly independent column vectors of A
column rank=∥C∥
Row rank
Let R be the largest set of linearly independent row vectors of A
Hence, both ranks are collectively referred as the Rank of A, denoted as rank(A)
Properties of A’s rank are:
rank(A)≤min(m,n)
Ais full rank⟺rank(A)=min(m,n)
rank(A)=rank(AT)
rank(AB)≤min(rank(A),rank(B)∀B∈Rm×p
rank(A+B)≤rank(A+B)∀B∈Rn×m
Tensors
Both of Vector and Matrix could be generalized as a Tensor, which is an algebraic object possessing an order or rank (the dimension of the array) (Linear Algebra for Deep Learning, 2021):
Tensor object
Order (Rank)
Sets
Represent of
Scalars
0th order
N,Z,Q,R,etc.
Magnitude
Vectors
1st order
Rn,n∈N
Direction and Magnitude
Matrices
2nd order
Rn×m,n,m∈N
Linear map
Matrix intuition
WIP
Matrices are used as an encoder for geometric operations (e.g. rotations, reflections, and transformations, etc.)
Special matrices
WIP
Identity Matrix: denoted as I, of size n×n has only ‘1’ in the main diagonal. Ii,j={1i=j0i=j
Zero Matrix: denoted as O, has all of its matrix elements equal to ‘0’.
Symmetric Matrix: a square matrix which is A=AT
Matrix operations
Transpose
Todo
The transpose of a matrix, written AT∈Rn×m, has entries given by:
Ai,jT=Aj,i
Properties of the transposes are:
(AT)T=A
(AB)T=BTAT
(A+B)T=AT+BT
Matrix-Tensor addition
Matrix-Scalar addition
Todo
Matrix-Matrix addition
WIP
Suppose A∈Rn×m,x∈R, the addition between A and x is another matrix B∈Rn×m:
B=A+xwithbi,j=ai,j+x
Although A and x doesn’t share the same size, the addition is possible by the broadcasting mechanism.
Properties of the Matrix-Matrix addition includes:
Commutative
Associative
Matrix-Tensor product
Matrix-Scalar product
Todo
Matrix-Vector product
WIP
Suppose A∈Rn×m,x∈Rm, the product of Ax is a vectory - a same result by which could be described two different views:
In the column form metioned above, the matrix y is a linear combination of the columns of A
Matrix-Matrix product
WIP
Suppose A∈Rn×m,B∈Rm×p:
C=AB,withci,j=k=1∑mai,kbk,j
Properties of Matrix-Matrix product:
Non-commutative: AB=BA
Associative: (AB)C=A(BC)
Distributive: (A+B)C=AB+AC
Question: Why Matrix-Matrix multiplication is not commutative? Answer:
As aforementioned, Matrices represent linear map functions between two vector spaces. The idea is similar to the composition between functions, which is also not commutative:
Linear Algebra for Deep Learning. (2021). https://www.quantstart.com/articles/scalars-vectors-matrices-and-tensors-linear-algebra-for-deep-learning-part-1/