Multiplying large matrices entry by entry takes a lot of arithmetic, especially when large parts of the matrices are just zeros or identity matrices.
1
Multiplying blocks like single numbers
Suppose we want to multiply these two 4×4 matrices:
23101401001500211421211332100012
Instead of computing sixteen separate 4-number dot products, we can slice both matrices into 2×2 pieces and multiply the pieces together.
Why Block Multiplication Works
This works because each entry of a matrix product is just a sum of products. Grouping that sum into parts is the same as multiplying the blocks like single symbols and adding the results:
[ACBD][EGFH]=[AE+BGCE+DGAF+BHCF+DH]
Because matrix multiplication is not commutative (in general AE=EA), every block from the left matrix must stay on the left of its product, and every block from the right matrix must stay on the right.
2
Which cuts are allowed?
We don't have to slice matrices into even 2×2 squares. Let's see which horizontal and vertical cuts let all the smaller block multiplications work.
All the smaller block products work as long as the column widths of the left matrix match the row heights of the right matrix. Changing the outer cuts only changes how the final answer is divided into blocks, never its entries.
Block multiplication works whenever the left column cuts match the right row cuts, while the outer cuts only change the shapes of the blocks in the answer.
3
Multiplying with zero and identity blocks
Now let's return to our 4×4 product and use 2×2 blocks to compute it:
23101401001500211421211332100012
Multiplying with Zero and Identity Blocks
Text solution
1. Slice to isolate the zero and identity blocksCutting both matrices after row 2 and column 2 makes the top-right block of the left matrix 0 and the bottom-left block I, which eliminates G and H from the top row of the product.
When the matrices aren't 4×4, or when the identity blocks sit in different corners, our cuts can create rectangular blocks of several different shapes. Let's multiply these two 3×3 matrices:
100010234561102013
Multiplying Blocks of Different Sizes
Text solution
1. Slice to isolate I and 0 while matching the inner cutsCutting the left matrix into row heights 2,1 and column widths 2,1 isolates its I and 0 blocks, which forces the right matrix into row heights 2,1 while we cut its columns into widths 1,2 to isolate its top-right I.
2. Multiply and add the rectangular blocksThe outer cuts (heights 2,1 and widths 1,2) tell us that the four blocks in the answer have sizes 2×1,2×2,1×1, and 1×2.
Notice that in BH=[23][23], a 2×1 column multiplies a 1×2 row to produce a 2×2 matrix, which matches the 2×2 identity matrix I it gets added to.
5
Inverting block matrices
Block multiplication also lets us solve for unknown blocks to invert a large matrix in pieces.
First, suppose we want to invert a block-diagonal matrix, a matrix with invertible square blocks A and D on the main diagonal and 0 blocks off the diagonal:
[A00D]−1=?
Inverting a Block-Diagonal Matrix
[A00D]−1=?
Setting the matrix times four unknown blocks equal to the identity matrix,
[A00D][WYXZ]=[AWDYAXDZ]=[I00I]
shows that the off-diagonal blocks stay zero and each diagonal block is inverted in its own spot:
[A00D]−1=[A−100D−1]
Now suppose there is a non-zero block B in the top-right corner, forming a block upper-triangular matrix:
[A0BD]−1=?
Here A and D are invertible square blocks, so if they have different sizes, B is rectangular and B−1 does not even exist.
Inverting a Block Upper-Triangular Matrix
Setting up the same block equation and substituting Y=0,W=A−1, and Z=D−1 leaves the top-right equation for X:
AX+BD−1AXX=0=−BD−1=−A−1BD−1
Because A multiplies X on the left, we multiply by A−1 on the left, giving the block upper-triangular inverse formula:
[A0BD]−1=[A−10−A−1BD−1D−1]
When the diagonal blocks are already identity matrices (A=I and D=I), this simplifies right away to changing the sign of B:
[I0BI]−1=[I0−BI]
6
Column and row multiplication as extreme slicing
Other familiar ways of multiplying two matrices AB are really just extreme cases of block slicing.
Column and Row Multiplication as Block Slicing
Leaving A uncut (0 vertical cuts) and slicing B into columns (0 horizontal cuts) multiplies A by one column of B at a time:
A[b1b2b3]=[Ab1Ab2Ab3]
Slicing A into individual columns (widths 1,1,1) and B into individual rows (heights 1,1,1) writes AB as a sum of column-times-row matrices:
[c1c2c3]r1r2r3=c1r1+c2r2+c3r3
Key concepts
Block slicing is worth using whenever a matrix has visible 0 or I blocks, triangular structure, or column-row structure. (If a small matrix has no 0 or I blocks and no special pattern, standard row-by-column dot products are just as fast.)
Matching the cuts
The column widths of the left matrix must match the row heights of the right matrix, while the outer cuts set the block sizes of the answer. For example, if A has row heights 2,1 and column widths 2,1, then B must have row heights 2,1.
Isolating 0 and I blocks
Cut around blocks of zeros and identity blocks first, and keep left blocks on the left and right blocks on the right:
[AI0D][EGFH]=[AEE+DGAFF+DH]
Inverting block-triangular matrices
Invert the square diagonal blocks in their own spots and solve for the off-diagonal block without ever inverting B:
Slicing the left matrix into columns and the right matrix into rows turns AB into a sum of column-times-row matrices (also called outer products), c1r1+c2r2+⋯+cnrn, where each column-times-row term is a full matrix of the final product's size.
7
Practice
1
A 5×6 matrix A is sliced into blocks by cutting its rows into heights of 2 and 3, and its columns into widths of 4 and 2. It multiplies a 6×4 matrix B whose columns are cut into widths of 1 and 3. How must the rows of B be sliced for block multiplication to work, and what are the sizes of the four blocks in the product AB?
Be careful not to reverse them to 2 and 4, or try to match A's row heights 2 and 3.
Which cuts are the inner cuts that meet in the middle of AB, and which cuts are the outer cuts?
To match the column widths 4 and 2 of A, the rows of B must be sliced into heights of 4 and 2. (Be careful not to reverse them to 2 and 4, or try to match A's row heights 2 and 3.) The outer cuts (row heights 2,3 on A and column widths 1,3 on B) give the sizes of the four blocks in AB (watch out not to use the inner numbers 4 and 2, which would give 4×1 and 2×3): Top-left 2×1, top-right 2×3, bottom-left 3×1, and bottom-right 3×3.
2
Slice these two 4×4 matrices into 2×2 blocks and multiply them using the zero and identity blocks:
13002100102101132041131213002100
Label the 2×2 blocks and simplify the four block formulas using 0 and I before multiplying any numbers.
Slicing after row 2 and column 2 gives:
[A0ID][EGF0]=[AE+GDGAF0]
Keep the left blocks on the left when multiplying (reversing DG into GD gives [9477] instead of [9747]):
Choose uneven cuts on these two 3×3 matrices to isolate their identity and zero blocks, then multiply them in blocks:
312010001210101423
Where does the 2×2 identity block sit in each matrix, and what cut on the left columns sets the cut on the right rows?
Cut the left matrix after row 1 and column 1 into [AC0I], and cut the right matrix after row 1 (to match the left column widths 1,2) and after column 2 (to isolate its bottom-left 2×2 identity block) into [EIFH]:
In the bottom-left block CE+I, remember that I is the 2×2 identity matrix [1001] (adding 1 to every entry of CE instead of adding I only on the diagonal gives [3523]):
into four 2×2 blocks [A0BD] and find its inverse.
Look at the 1×1 blocks inside A and D: how does the rule [I0bI]−1=[I0−bI] give A−1 and D−1 right away?
Using [10b1]−1=[10−b1] on the 2×2 diagonal blocks gives:
A−1=[10−21],D−1=[10−31]
For the top-right block, compute −A−1BD−1 (don't just write −B=[−1−20−1], since A and D are not I, and don't drop the minus sign in front, which would give [−327−5]):
Putting the four 2×2 blocks together gives the inverse:
1000−21003−210−75−31
6
Suppose A is an invertible 3×3 block, D is an invertible 2×2 block, and C is a 2×3 block in the block lower-triangular matrix [AC0D]. Set up [AC0D][WYXZ]=[I00I] to find the four blocks of [AC0D]−1, and explain why the bottom-left block cannot be written in the order −A−1CD−1.
Multiply out the bottom-left block equation CW+DY=0 and look at which side of Y the matrix D sits on.
Multiplying out the left side gives:
[AWCW+DYAXCX+DZ]=[I00I]
From the top row, AW=I⟹W=A−1 and AX=0⟹X=0. In the bottom row, X=0 leaves DZ=I⟹Z=D−1, and substituting W=A−1 into CW+DY=0 gives:
CA−1+DY=0⟹DY=−CA−1
Because D multiplies Y on the left, we must multiply on the left by D−1 to get Y=−D−1CA−1 (writing −A−1CD−1 to copy the upper-triangular formula doesn't work because D sits on the left of Y, and the sizes 3×3,2×3, and 2×2 cannot even be multiplied in the order A−1CD−1):