Basic Linear Algebra

Linear algebra is the working language of SLAM: points, poses, residuals, and observations are all vectors and matrices, and every solver ultimately reduces to matrix computations.

Vectors and Matrices

A vector vRn\mathbf{v} \in \mathbb{R}^n is a column of nn real numbers. In SLAM, vectors represent points, translations, velocities, and residuals. A matrix ARm×nA \in \mathbb{R}^{m \times n} represents a linear map from Rn\mathbb{R}^n to Rm\mathbb{R}^m. The central object in SLAM geometry is the matrix-vector product Ax=bA\mathbf{x} = \mathbf{b}.

Determinant

The determinant det(A)\det(A) of a square matrix measures the signed volume scaling factor of the linear map AA. Key facts:

Dot Product and Cross Product

The dot product of u,vR3\mathbf{u}, \mathbf{v} \in \mathbb{R}^3 is uv=uTv=uvcosθ\mathbf{u} \cdot \mathbf{v} = \mathbf{u}^T\mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta; it is used for projections and checking orthogonality. The cross product u×v\mathbf{u} \times \mathbf{v} produces a vector perpendicular to both, with magnitude uvsinθ\|\mathbf{u}\|\|\mathbf{v}\|\sin\theta. It appears in the skew-symmetric matrix formulation of the essential matrix and in computing surface normals.

The cross product can be written as a matrix-vector product using the skew-symmetric matrix:

u×v=[u]×v,[u]×=[0u3u2u30u1u2u10]\mathbf{u} \times \mathbf{v} = [\mathbf{u}]_\times \mathbf{v}, \qquad [\mathbf{u}]_\times = \begin{bmatrix} 0 & -u_3 & u_2 \\ u_3 & 0 & -u_1 \\ -u_2 & u_1 & 0 \end{bmatrix}

This little identity is everywhere in SLAM: the essential matrix is E=[t]×RE = [\mathbf{t}]_\times R, and Lie algebra elements of so(3)\mathfrak{so}(3) are skew-symmetric matrices.

Rank, Inverse, and Transpose

The rank of AA is the dimension of its column space. In SLAM, the fundamental matrix has rank 2 by construction, and a point cloud matrix is rank-deficient when all points are coplanar (a degenerate configuration for SLAM initialization). The inverse A1A^{-1} satisfies AA1=IAA^{-1} = I and exists iff det(A)0\det(A) \neq 0. For rotation matrices, R1=RTR^{-1} = R^T (orthogonality) — exploited constantly to avoid computing a full inverse.

A quick NumPy check that a matrix is a valid rotation:

import numpy as np

theta = np.pi / 4
R = np.array([[np.cos(theta), -np.sin(theta), 0],
              [np.sin(theta),  np.cos(theta), 0],
              [0,              0,             1]])

print(np.allclose(R.T @ R, np.eye(3)))  # True: orthogonal
print(np.linalg.det(R))                 # 1.0: proper rotation

Solving linear systems

SLAM back-ends never invert matrices explicitly; they factorize and solve:

Singular Value Decomposition (SVD)

SVD is the most important matrix factorization in SLAM. Any matrix ARm×nA \in \mathbb{R}^{m \times n} decomposes as

A=UΣVTA = U \Sigma V^T

where UU and VV are orthogonal and Σ\Sigma is diagonal with non-negative singular values σ1σ20\sigma_1 \geq \sigma_2 \geq \cdots \geq 0. Geometrically, any linear map is a rotation/reflection, followed by a coordinate-wise scaling, followed by another rotation/reflection. Uses in SLAM:

The ratio σ1/σn\sigma_1/\sigma_n is the condition number: it measures how much a linear solve amplifies input noise. Ill-conditioned systems (huge condition numbers) are why coordinate normalization matters in the 8-point algorithm and DLT.

Eigenvalues and Eigenvectors

A non-zero vector v\mathbf{v} and scalar λ\lambda satisfying Av=λvA\mathbf{v} = \lambda\mathbf{v} are an eigenvector and eigenvalue of AA. The Harris corner detector classifies image patches from the eigenvalues of the structure tensor, and PCA of a point cloud uses eigenvectors of the covariance matrix to find principal directions (e.g., fitting a plane). For symmetric matrices (covariances, structure tensors, JTJJ^TJ) the eigenvalues are real and the eigenvectors orthogonal — and eigendecomposition coincides with SVD.

Common pitfalls

Why it matters for SLAM

Every stage of a SLAM pipeline is linear algebra in disguise: projecting points uses matrix products, minimal solvers (8-point, DLT, ICP) reduce to SVD, and the normal equations of bundle adjustment are a large sparse linear system. Fluency here — especially with SVD, orthogonal matrices, and rank — is what lets you read SLAM papers and debug geometry code.