Post · 3 min read· pp. 256–257
tl;dr: We cover a few basic linear algebra concepts: vectors, matrices, matrix-vector products, vector dot products, Haddamard products, etc.
$
$
We typically assume all vector and matrix elements are from a finite field \F \F \F , but these definitions can be generalized.
(For example, in this blogpost , we multiply a matrix made of field elements with a vector made up of indeterminate variables X 0 , X , X 2 , … , X m X^0, X, X^2, \ldots, X^m X 0 , X , X 2 , … , X m .)
Row vectors vs. column vectors
A size-m m m row vector x ⃗ \vec{x} x is denoted by:
x ⃗ ∈ \F 1 × m \bydef ( x i ) i ∈ [ m ] = [ x 1 , x 2 , … , x m ] \begin{align}
\vec{x} \in \F^{1\times m}
&\bydef (x_i)_{i\in[m]} = [x_1, x_2, \ldots, x_m]
\end{align} x ∈ \F 1 × m \bydef ( x i ) i ∈ [ m ] = [ x 1 , x 2 , … , x m ]
A size-
n n n column vector x ⃗ \vec{x} x is denoted by:
x ⃗ ∈ \F n × 1 \bydef [ x 1 x 2 ⋮ x n ] \bydef [ x 1 , x 2 , … , x n ] ⊤ = ( x i ) i ∈ [ n ] ⊤ \begin{align}
\vec{x} \in \F^{n\times 1}
&\bydef \begin{bmatrix} x_1\\\ x_2\\\ \vdots\\\ x_n\end{bmatrix}
\bydef [x_1, x_2, \ldots, x_n]^\top
= (x_i)_{i\in[n]}^\top
\end{align} x ∈ \F n × 1 \bydef x 1 x 2 ⋮ x n \bydef [ x 1 , x 2 , … , x n ] ⊤ = ( x i ) i ∈ [ n ] ⊤
Notes:
We most often work with column vectors. Thus, for simplicity, we let \F n \bydef \F n × 1 \F^n \bydef \F^{n\times 1} \F n \bydef \F n × 1 .
We use the transpose operator ⊤ \top ⊤ to convert a row vector to a column vector (and viceversa).
i.e., ( x ⃗ ⊤ ) ⊤ = x ⃗ (\vec{x}^\top)^\top = \vec{x} ( x ⊤ ) ⊤ = x
Dot products of vectors
Given two vectors x ⃗ , y ⃗ \vec{x}, \vec{y} x , y both of size m m m , their dot product is defined as:
x ⃗ ⋅ y ⃗ \bydef ∑ i ∈ [ m ] x i y i ∈ \F \vec{x}\cdot\vec{y} \bydef \sum_{i\in[m]} x_i y_i\in \F x ⋅ y \bydef i ∈ [ m ] ∑ x i y i ∈ \F
We only use this definition of (dot) product whenever:
both vectors are row
both vectors are column
x ⃗ \vec{x} x is row and y ⃗ \vec{y} y is column
In contrast, when x ⃗ ∈ \F n \vec{x}\in\F^n x ∈ \F n (i.e., a column vector) and y ⃗ ∈ \F 1 × n \vec{y}\in\F^{1\times n} y ∈ \F 1 × n (i.e., a row vector), x ⃗ ⋅ y ⃗ \vec{x}\cdot\vec{y} x ⋅ y yields an outer product or tensor product in \F n × n \F^{n\times n} \F n × n .
(We may talk about this in a later version of this blog.)
Matrices
An n n n -row by m m m -column matrix \mat A \mat{A} \mat A is denoted by:
\mat A ∈ \F n × m \bydef ( A i , j ) i ∈ [ n ] , j ∈ [ m ] = [ A 1 , 1 A 1 , 2 … A 1 , m A 2 , 1 A 2 , 2 … A 2 , m ⋮ ⋮ ⋱ ⋮ A n , 1 A n , 2 … A n , m ] \begin{align}
\mat{A} \in \F^{n\times m} &\bydef (A_{i,j})_{i\in[n],j\in[m]} =
\begin{bmatrix}
A_{1,1} & A_{1,2} & \ldots & A_{1,m}\\
A_{2,1} & A_{2,2} & \ldots & A_{2,m}\\
\vdots & \vdots & \ddots & \vdots \\
A_{n,1} & A_{n,2} & \ldots & A_{n,m}
\end{bmatrix}
\end{align} \mat A ∈ \F n × m \bydef ( A i , j ) i ∈ [ n ] , j ∈ [ m ] = A 1 , 1 A 2 , 1 ⋮ A n , 1 A 1 , 2 A 2 , 2 ⋮ A n , 2 … … ⋱ … A 1 , m A 2 , m ⋮ A n , m
We often use \mat A i \mat{A}_i \mat A i as convenient notation for the i i i th row of the matrix \mat A \mat{A} \mat A .
So:
\mat A = ( \mat A i ) i ∈ [ n ] , where \mat A i ∈ \F 1 × m \begin{align}
\mat{A} = (\mat{A}_i)_{i\in[n]},\ \text{where}\ \mat{A}_i \in \F^{1\times m}
\end{align} \mat A = ( \mat A i ) i ∈ [ n ] , where \mat A i ∈ \F 1 × m
Matrix-vector multiplication
We can multiply a matrix \mat A ∈ \F n × m \mat{A}\in \F^{n\times m} \mat A ∈ \F n × m by a size-m m m column vector x ⃗ ∈ \F m \vec{x}\in\F^m x ∈ \F m as follows:
\mat A x ⃗ = [ A 1 , 1 A 1 , 2 … A 1 , m A 2 , 1 A 2 , 2 … A 2 , m ⋮ ⋮ ⋱ ⋮ A n , 1 A n , 2 … A n , m ] [ x 1 x 2 ⋮ x m ] \bydef [ A 1 , 1 x 1 + A 1 , 2 x 2 + … + A 1 , m x m A 2 , 1 x 1 + A 2 , 2 x 2 + … + A 2 , m x m ⋮ A n , 1 x 1 + A n , 2 x 2 + … + A n , m x m ] \bydef [ a ⃗ 1 ⋅ x ⃗ a ⃗ 2 ⋅ x ⃗ ⋮ a ⃗ n ⋅ x ⃗ ] \begin{align}
\mat{A}\vec{x} =
\begin{bmatrix}
A_{1,1} & A_{1,2} & \ldots & A_{1,m}\\
A_{2,1} & A_{2,2} & \ldots & A_{2,m}\\
\vdots & \vdots & \ddots & \vdots \\
A_{n,1} & A_{n,2} & \ldots & A_{n,m}
\end{bmatrix}
\begin{bmatrix} x_1\\\ x_2\\\ \vdots\\\ x_m\end{bmatrix}
\bydef
\begin{bmatrix}
A_{1,1}x_1 + A_{1,2}x_2 + \ldots + A_{1,m}x_m\\
A_{2,1}x_1 + A_{2,2}x_2 + \ldots + A_{2,m}x_m\\
\vdots\\
A_{n,1}x_1 + A_{n,2}x_2 + \ldots + A_{n,m}x_m\\
\end{bmatrix}
\bydef
\begin{bmatrix}
\vec{a}_1 \cdot \vec{x}\\
\vec{a}_2 \cdot \vec{x}\\
\vdots\\
\vec{a}_n \cdot \vec{x}\\
\end{bmatrix}
\end{align} \mat A x = A 1 , 1 A 2 , 1 ⋮ A n , 1 A 1 , 2 A 2 , 2 ⋮ A n , 2 … … ⋱ … A 1 , m A 2 , m ⋮ A n , m x 1 x 2 ⋮ x m \bydef A 1 , 1 x 1 + A 1 , 2 x 2 + … + A 1 , m x m A 2 , 1 x 1 + A 2 , 2 x 2 + … + A 2 , m x m ⋮ A n , 1 x 1 + A n , 2 x 2 + … + A n , m x m \bydef a 1 ⋅ x a 2 ⋅ x ⋮ a n ⋅ x
Hadamard products
The Hadamard product of two size-n n n column vectors x ⃗ , y ⃗ \vec{x},\vec{y} x , y is defined as:
x ⃗ ∘ y ⃗ \bydef [ x 1 y 1 x 2 y 2 ⋮ x n y n ] \begin{align}
\vec{x}\circ\vec{y} \bydef \begin{bmatrix}
x_1 y_1\\
x_2 y_2\\
\vdots\\
x_n y_n
\end{bmatrix}
\end{align} x ∘ y \bydef x 1 y 1 x 2 y 2 ⋮ x n y n