Post · 3 min read· pp. 256–257

Basics of linear algebra

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, 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 X0,X,X2,…,XmX^0, X, X^2, \ldots, X^m.)

Row vectors vs. column vectors

A size-mm row vector x⃗\vec{x} is denoted by:

x⃗∈\F1×m\bydef(xi)i∈[m]=[x1,x2,…,xm]\begin{align} \vec{x} \in \F^{1\times m} &\bydef (x_i)_{i\in[m]} = [x_1, x_2, \ldots, x_m] \end{align}
A size-nn column vector x⃗\vec{x} is denoted by:
x⃗∈\Fn×1\bydef[x1 x2 ⋮ xn]\bydef[x1,x2,…,xn]⊤=(xi)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}

Notes:

  • We most often work with column vectors. Thus, for simplicity, we let \Fn\bydef\Fn×1\F^n \bydef \F^{n\times 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}

Dot products of vectors

Given two vectors x⃗,y⃗\vec{x}, \vec{y} both of size mm, their dot product is defined as:

x⃗⋅y⃗\bydef∑i∈[m]xiyi∈\F\vec{x}\cdot\vec{y} \bydef \sum_{i\in[m]} x_i y_i\in \F

We only use this definition of (dot) product whenever:

  • both vectors are row
  • both vectors are column
  • x⃗\vec{x} is row and y⃗\vec{y} is column

In contrast, when x⃗∈\Fn\vec{x}\in\F^n (i.e., a column vector) and y⃗∈\F1×n\vec{y}\in\F^{1\times n} (i.e., a row vector), x⃗⋅y⃗\vec{x}\cdot\vec{y} yields an outer product or tensor product in \Fn×n\F^{n\times n}. (We may talk about this in a later version of this blog.)

Matrices

An nn-row by mm-column matrix \matA\mat{A} is denoted by:

\matA∈\Fn×m\bydef(Ai,j)i∈[n],j∈[m]=[A1,1A1,2…A1,mA2,1A2,2…A2,m⋮⋮⋱⋮An,1An,2…An,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}

We often use \matAi\mat{A}_i as convenient notation for the iith row of the matrix \matA\mat{A}. So:

\matA=(\matAi)i∈[n], where \matAi∈\F1×m\begin{align} \mat{A} = (\mat{A}_i)_{i\in[n]},\ \text{where}\ \mat{A}_i \in \F^{1\times m} \end{align}

Matrix-vector multiplication

We can multiply a matrix \matA∈\Fn×m\mat{A}\in \F^{n\times m} by a size-mm column vector x⃗∈\Fm\vec{x}\in\F^m as follows:

\matAx⃗=[A1,1A1,2…A1,mA2,1A2,2…A2,m⋮⋮⋱⋮An,1An,2…An,m][x1 x2 ⋮ xm]\bydef[A1,1x1+A1,2x2+…+A1,mxmA2,1x1+A2,2x2+…+A2,mxm⋮An,1x1+An,2x2+…+An,mxm]\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}

Hadamard products

The Hadamard product of two size-nn column vectors x⃗,y⃗\vec{x},\vec{y} is defined as:

x⃗∘y⃗\bydef[x1y1x2y2⋮xnyn]\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}