Structured Block Matrices - Reducing Recursive Calls
In questa pagina 3
A matrix with a lot of repetition can be handled with algorithms that are sublinear in the number of entries. A matrix , , belongs to a recursive family if or it is made of blocks that are repeated or related and belong to the same family. Typical requests: (1) closure under sum, difference (and sometimes product), by induction; (2) algorithms for sum, difference, product (or matrix-vector product, or inverse) with scalar operations (hint: "only three" or "only two" recursive calls); (3) the recurrence and its order via the Master TheoremThe Master Theorem for T(n) = aT(n/b) + w(n) compares w(n) with the threshold n^(log_b a). Case 1 (w polynomially smaller): Theta(n^(log_b a)); case 2 (same order): Theta(n^(log_b a) log n); case 3 (polynomially larger and regular): Theta(w(n)). Full proof from the levels of the tree, extended version with floors and ceilings, a table of applications, and the misuse when no case applies (w = n log n).Master Theorem →. Prerequisites: Matrix Multiplication - Iterative and Recursive Block ProductCost model on n x n matrices (scalar operations, size n or N = n^2); sum in n^2 operations (optimal); iterative row-by-column product with exact cost 2n^3 - n^2; the fractal property of the block product proved on indices; recursive algorithm RMUL with T(n) = 8T(n/2) + n^2, Theta(n^3) and exact solution 2n^3 - n^2: it performs the same operations as the iterative one.Matrix Multiplication - Iterative and Recursive Block Product →, Strassen's AlgorithmStrassen computes the n x n product with 7 recursive calls instead of 8, using 10 matrix additions in Divide and 8 in Conquer: T(n) = 7T(n/2) + (9/2)n^2, Theta(n^(log2 7)) with exact solution 7n^(log2 7) - 6n^2. Its leading constant 7 is more than three times that of the iterative algorithm (2), so Strassen beats it only from n = 655 (from 1024 for powers of two).Strassen's Algorithm →. The supercirculant family is treated in full in Supercirculant and Circulant MatricesSupercirculant matrices (alternating recursive quadrants) have only n distinct values: sum in n operations, product in 4n log2 n + n with the trick (A1+A2)(B1+B2) and (A1-A2)(B1-B2) instead of 4 calls (Theta(n^2)); their eigenvalues are the Hadamard transform of the first row (FHT, n log2 n). Circulant matrices are polynomials in the rotation matrix R, their product is the cyclic convolution of the first rows, and the Fourier matrix diagonalizes them: product in O(n log n) with the FFT.Supercirculant and Circulant Matrices →.
The method in five steps
- Count the free parameters. A matrix of the family is determined by its independent blocks; recursively only scalars remain, not . E.g. SIR (blocks , two independent blocks): , , so . Sum and difference then cost : two calls on , no internal work, , . Repeated or opposite blocks cost nothing (already known).
- Write the block product with the row-by-column rule, substituting the structure.
- Closure. The blocks of the result are sums, differences and products of blocks of the family; the induction hypothesis (which must hold for all three operations) places them in the family. Base : every scalar belongs.
- Count the distinct block products in the result. If there are products of size and the border sums cost , then and the MT gives : is not enough (), gives , gives .
- Reduce with sums and differences (two models below), then write the exact recurrence, solve it with the general formula (Recurrence Relations - Recursion Tree and General FormulaThe recurrence tree has the shape of the call tree of the worst instance and T(n) is the sum of the works of its nodes. For the family T(n) = s(n) T(f(n)) + w(n) with base T0 for n <= n0, counting nodes per level with the iterates of f and the level f*(n,n0) gives the closed formula T(n) = sum over levels of [product of s] w + [product of s] T0, proved by induction and applied to merge sort, Hanoi and square-root recurrences.Recurrence Relations - Recursion Tree and General Formula →) and check with .
Two reduction models
Sum-and-difference model (SC, RCA). The result has blocks , (four products). Compute The mixed terms change sign in : , . Two products, four sums in Divide, two in Conquer and two products by : eight operations on size , so , exact . For the RCA matrix-vector product the same idea with , , , gives the same .
Gauss model (ARB). The block product of and is with , : four products. Compute instead , , (three products). Then , : the idea of multiplying complex numbers with three real products. Six operations on size (, , , , and the sign change for ), so , exact .
When no trick is needed (SIR). has three distinct products ( appears twice, computed once): already , , exact . For the inverse : one recursive call plus two products, , exact (sign changes not counted).
| family | blocks | operation | recursive products | recurrence | order |
|---|---|---|---|---|---|
| SC | product | ||||
| ARB | product | ||||
| SIR | product | (already) | |||
| SIR | as above | inverse | call products | ||
| RCA | matrix-vector | ||||
| any | sum or difference | (on independent blocks) |
When closure fails: the product of two RCA
For , the block product is the shape of a supercirculant, not of an RCA (which would need bottom-left). For : , give , not RCA (). So the hypothesis "the product of two RCA is RCA" is false, and a recursive product algorithm could not call itself on the blocks , , ... Hence one asks only for the product by a vector. Always check closure (step 3) before designing the algorithm.
Versione ripasso
- Typical requests: (1) closure by induction; (2) algorithms with operations; (3) recurrence and Master Theorem. Theory: Matrix Multiplication - Iterative and Recursive Block ProductCost model on n x n matrices (scalar operations, size n or N = n^2); sum in n^2 operations (optimal); iterative row-by-column product with exact cost 2n^3 - n^2; the fractal property of the block product proved on indices; recursive algorithm RMUL with T(n) = 8T(n/2) + n^2, Theta(n^3) and exact solution 2n^3 - n^2: it performs the same operations as the iterative one.Matrix Multiplication - Iterative and Recursive Block Product →, Strassen's AlgorithmStrassen computes the n x n product with 7 recursive calls instead of 8, using 10 matrix additions in Divide and 8 in Conquer: T(n) = 7T(n/2) + (9/2)n^2, Theta(n^(log2 7)) with exact solution 7n^(log2 7) - 6n^2. Its leading constant 7 is more than three times that of the iterative algorithm (2), so Strassen beats it only from n = 655 (from 1024 for powers of two).Strassen's Algorithm →, Master TheoremThe Master Theorem for T(n) = aT(n/b) + w(n) compares w(n) with the threshold n^(log_b a). Case 1 (w polynomially smaller): Theta(n^(log_b a)); case 2 (same order): Theta(n^(log_b a) log n); case 3 (polynomially larger and regular): Theta(w(n)). Full proof from the levels of the tree, extended version with floors and ceilings, a table of applications, and the misuse when no case applies (w = n log n).Master Theorem →.
- Five steps: free parameters (, not : sum and difference cost , ); block product; closure (base , hypothesis on sum, difference, product); count distinct products ( gives , gives , gives ); reduce .
- Sum and difference (SC, RCA): , , , ; eight operations on size : , exact . RCA by vector: , , , , same count.
- Gauss (ARB): product , , ; with , , : , . Six operations on size (including the sign of ): , exact .
- SIR: , three products ( once): , exact . Inverse : exact .
- False closure: , , , not RCA (example : ). So only the product by a vector is requested.
- Common mistakes: counting parameters; recursing on blocks without checking closure; forgetting appears twice; forgetting the divisions by or the sign change in the count; stopping at calls (not ); not checking the exact formula with .