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 is a column of real numbers. In SLAM, vectors represent points, translations, velocities, and residuals. A matrix represents a linear map from to . The central object in SLAM geometry is the matrix-vector product .
Determinant
The determinant of a square matrix measures the signed volume scaling factor of the linear map . Key facts:
- is invertible.
- For a rotation matrix : .
- .
Dot Product and Cross Product
The dot product of is ; it is used for projections and checking orthogonality. The cross product produces a vector perpendicular to both, with magnitude . 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:
This little identity is everywhere in SLAM: the essential matrix is , and Lie algebra elements of are skew-symmetric matrices.
Rank, Inverse, and Transpose
The rank of 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 satisfies and exists iff . For rotation matrices, (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:
- Cholesky factorization () for symmetric positive-definite systems — the normal equations of bundle adjustment are solved this way (sparse Cholesky in practice).
- QR factorization is the numerically safer alternative for least squares, working on directly without forming (which squares the condition number).
- SVD is the most robust (and most expensive) option, and the only one that cleanly handles rank-deficient, homogeneous systems .
Singular Value Decomposition (SVD)
SVD is the most important matrix factorization in SLAM. Any matrix decomposes as
where and are orthogonal and is diagonal with non-negative singular values . Geometrically, any linear map is a rotation/reflection, followed by a coordinate-wise scaling, followed by another rotation/reflection. Uses in SLAM:
- Essential matrix decomposition: SVD of yields the four candidate relative poses .
- DLT triangulation: the solution is the right singular vector of with the smallest singular value.
- ICP alignment: SVD of the cross-covariance matrix gives the optimal rotation.
The ratio 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 and scalar satisfying are an eigenvector and eigenvalue of . 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, ) the eigenvalues are real and the eigenvectors orthogonal — and eigendecomposition coincides with SVD.
Common pitfalls
- Explicitly inverting matrices (
inv(A) @ b) instead of solving (np.linalg.solve, Cholesky): slower and less accurate. - Forgetting normalization before solving homogeneous systems — DLT and the 8-point algorithm degrade badly on raw pixel coordinates.
- Sign/reflection ambiguity in SVD-based rotation recovery: always check and correct with a sign flip if you got a reflection.
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.