Partition (Block) Matrices
Draw a few lines through a big matrix and treat the rectangles inside as single objects. Blocks largely behave like scalars — you add and multiply them block-wise — and for block-diagonal or block-triangular layouts the determinant is just the product of the diagonal blocks' determinants.
What you'll learn
- Partitioning a matrix into blocks and multiplying block-wise (respecting order)
- Block-diagonal / block-triangular determinant = product of the diagonal blocks' determinants
- The inverse of a block-diagonal matrix is the block-wise inverse
Before you start
The last lesson tamed a big matrix by factoring it. Here is a different handle: just draw a few lines through it and treat the rectangles inside as single objects. That is a partitioned matrix — the same numbers, merely regrouped into blocks. The convenient surprise is that those blocks largely behave like scalars: you add and multiply them block by block, as if each block were one number — as long as the sizes line up so the inner products make sense. (It is not just exam bookkeeping: the covariance of two feature groups, a graph’s adjacency matrix, and a neural network’s weight layout all carry natural block structure this arithmetic exploits.)
Blocks behave like scalars
Multiplying two block matrices follows the ordinary row-times-column rule, with blocks in
place of numbers. For the 2×2 block layout above,
[ A B ] [ E F ] [ AE + BG AF + BH ]
[ C D ] [ G H ] = [ CE + DG CF + DH ]
— identical in shape to scalar 2×2 multiplication, except each product like AE is a
matrix product: A’s column count must match E’s row count, and the order AE must
be kept, never EA.
The payoff GATE leans on: when the blocks land in a block-triangular (one off-diagonal block zero) or block-diagonal (both zero) pattern, two normally-painful operations turn trivial. The determinant collapses to the product of the diagonal blocks:
det [ A B ] = det(A) · det(D) (block-triangular: lower-left = 0)
[ 0 D ]
det diag(A, B, C, …) = det(A) · det(B) · det(C) · … (block-diagonal)
And a block-diagonal matrix inverts block by block: diag(A, B)⁻¹ = diag(A⁻¹, B⁻¹),
provided each diagonal block is itself invertible.
A worked example
Take M = diag(A, B) with A = [[2, 0], [0, 2]] (det = 4) and B = [[1, 1], [0, 3]]
(det = 3). Written out, M is the 4×4
M = [ 2 0 | 0 0 ]
[ 0 2 | 0 0 ]
[ ---------- ] det(M) = det(A) · det(B) = 4 · 3 = 12
[ 0 0 | 1 1 ]
[ 0 0 | 0 3 ]
No 4×4 cofactor expansion needed — the block structure does the work, turning 4 × 3 = 12 into the whole answer.
A question to carry forward
We have now broken matrices apart in several ways — into eigen-pieces QΛQᵀ, into
triangular LU factors, into blocks. But every one of those needed the matrix to be
square. Here is the thread onward: is there a single decomposition that works for any
matrix at all — rectangular, rank-deficient, anything — and reveals its true “stretch
directions” the way eigenvalues do for a square one?
In one breath
- A partitioned (block) matrix regroups the same numbers into rectangular blocks; blocks add and multiply block-wise like scalars — when sizes are conformable.
- Block multiplication is row-times-column with matrix blocks: each
AEis a matrix product, order kept (AE ≠ EA). - Block-triangular / block-diagonal determinant = product of the diagonal blocks’ determinants (
det diag(A,B) = det(A)·det(B)). - Block-diagonal inverse is block-wise:
diag(A,B)⁻¹ = diag(A⁻¹, B⁻¹)(each block invertible). - The determinant shortcut needs a zero off-diagonal block — a full block matrix does not give
det(A)·det(D).
Practice
Quick check
Practice this in an interview
All questionsA transformer block has a multi-head self-attention sublayer and a position-wise feed-forward sublayer, each wrapped in a residual connection and normalization. Post-norm (the original transformer) applies normalization after the residual add, while pre-norm applies it inside the residual branch before the sublayer; pre-norm gives more stable gradients and is standard in modern deep LLMs.
Make two passes: a left pass where each position accumulates the product of everything to its left, then a right pass (using a rolling variable) that multiplies in everything to its right. The two passes together give the complete product-of-all-others in O(n) time and O(1) extra space (excluding output).