Faster all-pairs shortest paths via circuit complexity
Ryan Williams
Introduction
Since the 1970s [Mun71, FM71, AHU74] it has been known that the search for faster algorithms for APSP is equivalent to the search for faster algorithms for the min-plus (or max-plus) matrix product (a.k.a. distance product or tropical matrix multiplication), defined as:
That is, plays the role of addition, and plays the role of multiplication. A -time algorithm exists for this product if and only if there is an -time algorithm for APSP.Technically speaking, to reconstruct the shortest paths, we also need to compute the product , which returns (for all ) some witnessing the minimum . However, all known distance product algorithms (including ours) have this property.
Perhaps inspired by the surprising matrix multiplication algorithm of Strassen [Str69] over rings,As and do not have additive inverses, min-plus algebra and max-plus algebra are not rings, so fast matrix multiplication algorithms do not directly apply to them. Fredman [Fre75] initiated the development of time algorithms for APSP. He discovered a non-uniform decision tree computing the min-plus product with depth (but with size ). Combining the decision tree with a lookup table technique, he obtained a uniform APSP algorithm running in about time. Since 1975, many subsequent improvements on Fredman’s algorithm have been reported (see Table 1).There have also been parallel developments in APSP algorithms on sparse graphs [Joh77, FT87, PR05, Pet04, Cha06] and graphs with small integer weights [Rom80, Pan81, Sei95, Tak95, AGM97, SZ99, Zwi02, GS13]. The small-weight algorithms are pseudopolynomial, running in time for various and various greater than the (ring) matrix multiplication exponent. However, all these improvements have only saved factors over Floyd-Warshall: most recently, Chan [Cha07] and Han and Takaoka [HT12] give time bounds of roughly .
The consensus appears to be that the known approaches to general APSP may never save more than small factors in the running time. The methods (including Fredman’s) use substantial preprocessing, lookup tables, and (sometimes) bit tricks, offloading progressively more complex operations into tables such that these operations can then be executed in constant time, speeding up the algorithm. It is open whether such techniques could even lead to an time Boolean matrix multiplication (with logical OR as addition), a special case of max-plus product. V. Vassilevska Williams and the author [VW10] proved that a large collection of fundamental graph and matrix problems are subcubic equivalent to APSP: Either all these problems are solvable in time for some (a.k.a. “truly subcubic time”), or none of them are. This theory of APSP-hardness has nurtured some pessimism that truly subcubic APSP is possible.
We counter these doubts with a new algorithm for APSP running faster than time, for every .
A similar time factor would necessarily appear in a complete running time description of all previous algorithms when implemented on a machine that takes bit complexity into account, such as the word RAM—note the input itself requires bits to describe in the worst case. In the real RAM model, where additions and comparisons of real numbers given in the input are unit cost, but all other operations have typical cost, the algorithm runs in the “strongly polynomial” bound of time. Most prior algorithms for the general case of APSP also have implementations in the real RAM. (For an extended discussion, see Section 2 of Zwick [Zwi04].)
The new algorithm avoids an exponential blowup by exploiting the fact that and addition are simple operations from the point of view of Boolean circuit complexity. Namely, these operations are both in , i.e., they have circuits of constant-depth and polynomial-size over AND/OR/NOT gates of unbounded fan-in. It follows that min-plus inner products can be computed in , and the new algorithm manipulates such circuits at the bit-level. (This also means the approach is highly non-black-box, and not subject to lower bounds based on additions and comparisons alone; this is necessary, due to Kerr’s lower bound.) operations are very structured and have many known limitations (starting with [Ajt83, FSS81]). Circuit lower bound techniques often translate algorithmically into nice methods for manipulating circuits.
Minimum weight triangle: Given an -node graph with real edge weights, compute such that are edges and the sum of edge weights is minimized.
Minimum cycle: Given an -node graph with real positive edge weights, find a cycle of minimum total edge weight.
Second shortest paths: Given an -node directed graph with real positive edge weights and two nodes and , determine the second shortest simple path from to .
Replacement paths: Given an -node directed graph with real positive edge weights and a shortest path from node to node , determine for each edge the shortest path from to in the graph with removed.
Faster algorithms for some sparse graph problems also follow from Theorem 1.1. An example is that of finding a minimum weight triangle in a sparse graph:
In other words, this is the usual discrete convolution of two vectors in algebra.
Is it possible that the approach of this paper can be extended to give a “truly subcubic” APSP algorithm, running in time for some ? If so, we might require an even more efficient way of representing min-plus inner products as inner products over the integers. Very recently, the author discovered a way to efficiently evaluate large depth-two linear threshold circuits [Wil13] on many inputs. The method is general enough that, if min-plus inner product can be efficiently implemented with depth-two threshold circuits, then truly subcubic APSP follows. For instance:
To phrase it another way, the hypothesis that APSP is not in truly subcubic time implies interesting circuit lower bounds.
In Section 2, we try to provide a relatively succinct exposition of how to solve APSP in less than time for all , in the case where the edge weights are not too large (e.g., at most ). In Section 3 we prove Theorem 1.1 in full, by expanding considerably on the arguments in Section 2. In Section 4 we illustrate one of the many applications, and consider the possibility of extending our approach to a truly subcubic algorithm for APSP. We conclude in Section 5.
A relatively short argument for faster APSP
We begin with a succinct exposition of a good algorithm for all-pairs shortest paths, at least in the case of reasonable-sized weights. This will illustrate most of the main ideas in the full algorithm.
There is a deterministic algorithm for APSP which, for some , runs in time
To simplify the presentation, we will not be explicit in our choice of here; that lovely torture will be postponed to the next section. Another mildly undesirable property of Theorem 2.1 is that the bound is only meaningful for for sufficiently small . So this is not the most general bound one could hope for, but it is effective when the edge weights are in the range , which is already a difficult case for present algorithms. The factor will be eliminated in the next section.
A min-plus matrix multiplication simply represents a collection of all-pairs min-plus inner products over a set of vectors.
Given encoded as -bit strings, is computable with constant-depth AND/OR/NOT circuits of size . That is, the min-plus inner product function is computable in for every and .
The proof is relatively straightforward; it is given in Appendix A for completeness. Next, we show that a small circuit can be quickly evaluated on all pairs of inputs of one’s choice. The first step is to deterministically reduce circuits to depth-two circuits with a symmetric function (a multivariate Boolean function whose value only depends on the sum of the variables) computing the output gate and AND gates of inputs (or their negations) on the second layer. Such circuits are typically called circuits [BT94]. It is known that constant-depth circuits with AND, OR, NOT, and MOD gates of size (a.k.a. circuits) can be efficiently translated into circuits of size for some constant depending on the depth of the circuit and the modulus :A MOD gate outputs if and only if the sum of its input bits is divisible by .
Moreover, given the number of ANDs in the circuit evaluating to , the symmetric function itself can be evaluated in time.
The second step is to quickly evaluate these polynomials on many chosen inputs, using rectangular matrix multiplication. Specifically, we require the following:
For all sufficiently large , multiplication of an matrix with an matrix can be done in arithmetic operations.See Appendix C for a detailed exposition of this algorithm.
Let be a -variate polynomial over the integers (in its monomial representation) with monomials, along with such that . The polynomial can be evaluated over all points in arithmetic operations.
Note that the obvious polynomial evaluation algorithm would require arithmetic operations.
Putting the pieces together, we obtain our “warm-up” APSP algorithm:
But precisely when , i.e.,
Proof of The Main Theorem
First, we can assume without loss of generality that for all , there is a unique achieving the minimum . One way to enforce this is to change all initial entries at the beginning to , and all entries to , prior to sorting. These changes can be made with only additions per entry; e.g., by adding to itself for times. Then, becomes
where is the minimum integer achieving .
Next, we encode a trick of Fredman [Fre75] in the computation; his trick is simply that
This subtle trick has been applied in most prior work on faster APSP. It allows us to “prepare” and by taking many differences of entries, before making explicit comparisons between entries. Namely, we construct matrices and which are and . The columns of and rows of are indexed by pairs from . We define:
Observe that if and only if .
For each column of and corresponding row of , sort the numbers in the set
and replace each and by their rank in the sorted order on , breaking ties arbitrarily (giving entries precedence over entries). Call these new matrices and . The key properties of this replacement are:
All entries of and are from the set .
if and only if . That is, the outcomes of all comparisons have been preserved.
For every , there is a unique such that for all ; this follows from the fact that there is a unique achieving the minimum .
Here we are using the notation that, for a logical expression , the expression [] is either or , and it is if and only if is true.
In the expression , there are different ANDs over comparisons. In order to get a “short” polynomial, we need to reduce the fan-in of the ANDs. Razborov and Smolensky proposed the following construction: for an AND over variables , let be an integer, choose independently and uniformly at random bits , and consider the expression
where corresponds to addition modulo . Note that when the are fixed constants, is an AND of XORs of at most variables along with possibly the constant .
For every fixed ,
For completeness, we give the simple proof. For a given point , first consider the expression . If , then is modulo for all , and hence with probability . If , then there is a subset of ’s which are , and hence a subset of ’s that are . The probability we choose for an odd number of the ’s in is at exactly . Hence the probability that in this case is exactly .
Since , it follows that if , then with probability . Since the are independent, if , then the probability is only that for all we have for an odd number of . Hence the probability is that some , completing the proof.
Now set , so that fails on a point with probability at most . Suppose we replace each of the ANDs in expression by the expression , yielding:
By the union bound, the probability that the (randomly generated) expression differs from on a given row and column is at most .
Next, we open up the comparisons in and simulate them with low-depth circuits. Think of the entries of and as bit strings, each of length . To check whether for two -bit strings and construed as positive integers in , we can compute (from Lemma 2.1)
where again stands for addition modulo . (We can replace the outer with a , because at most one of the expressions inside of the can be true for any and .)
The circuit is an XOR of ANDs of fan-in of XORs of fan-in at most 3. Applying Claim 1, we replace the ANDs with a randomly chosen expression , which is an AND of fan-in (for some parameter to be determined) of XORs of fan-in. The new expression now has the form
that is, we have an XOR of fan-in, of ANDs of fan-in , of XORs of fan-in, of XORs of fan-in at most 3.
In fact, an anonymous STOC referee pointed out that, by performing additional preprocessing on the matrices and , we can reduce the expression further, to have the form
Recall in the expression , there are comparisons, and hence copies of the circuit are needed. Setting
we ensure that, for a given row , column , and for , copies of the circuit give the same output as with probability at least .
Further simplifying, this quantity is at most
Let denote the quantity in (2). Provided , we will be able to apply a rectangular matrix multiplication in the final step. This is equivalent to
Recall , and note that expands to a sum of various powers of logs. For , the dominant term in is . Choosing
for sufficiently small , inequality (3) will be satisfied, and the number will be less than .
Recall that if we have independent random variables that are - valued with , the random variable satisfies the tail bound
(e.g., in Motwani and Raghavan [MR95], this is Theorem 4.2). Applying this bound,
Therefore for , the algorithm outputs the min-plus product of an and matrix in time, with probability at least .
Applying this algorithm to different and min-plus products, the min-plus product of two matrices is computable in time on the real RAM with probability at least , by the union bound. (On the word RAM, there is an extra additive factor of , for the initial application of Fredman’s trick.)
The APSP algorithm can be made deterministic with some loss in the running time, but still asymptotically better than for every . See Appendix B for the proof.
There is a and a deterministic algorithm for APSP running in time on the real RAM.
Some Applications
All applications referred to the introduction follow straightforwardly from the literature, except for possibly:
We follow the high-degree/low-degree trick of Alon, Yuster, Zwick [AYZ97]. To find a minimum edge-weight triangle with edges, let be a parameter and consider two possible scenarios:
The min-weight triangle contains a node of degree at most . Here, time suffices to search for the triangle: try all possible edges with , and check if there is a neighbor of which forms a triangle with , recording the triangle encountered of smallest weight.
To minimize the overall running time, we want
It seems likely that the basic approach taken in this paper can be extended to discover even faster APSP algorithms. Here we outline one concrete direction to pursue.
It is an open frontier in circuit complexity to exhibit explicit functions which are not computable efficiently with circuits. As far as we know, it could be that huge complexity classes like have circuits with only gates. (Allowing exponential weights is crucial: there are lower bounds for depth-two threshold circuits with small weights [HMP+93].)
That is, efficient depth-two circuits for inner product would imply a truly subcubic time algorithm for APSP. The proof applies a recent algorithm of the author:
Given a circuit with inputs and at most gates with threshold weights of absolute value at most , and given two sets where , we can evaluate on all points in using time.
A similar theorem also holds for depth-two threshold circuits (). Note the obvious algorithm for the above evaluation problem would take at least time.
To compute the -multiplication of two matrices, we reduce it into multiplies of and (as in Theorems 2.1 and 1.1), resulting in an algorithm running in time .
Discussion
1. Subquadratic 3SUM. Along with APSP, the 3SUM problem is another notorious polynomial-time solvable problem: given a list of integers, are there three which sum to zero? For lists of numbers, an time algorithm is well-known, and the conjecture that no time algorithm exists is significant in computational geometry and data structures, with many intriguing consequences [GO95, BHP01, SEO03, Pat10, VW13]. Baran, Demaine, and Patrascu [BDP05] showed that 3SUM is in about time (omitting factors). Can this be extended to time for some ? It is natural to start with solving Convolution-3SUM, defined by Patrascu [Pat10] as: given an array of integers, are there and such that ? Although this problem looks superficially easier than 3SUM, Patrascu showed that if Convolution-3SUM is in time then 3SUM is in time. That is, minor improvements for Convolution-3SUM would yield similar improvements for 3SUM.
2. Subquadratic String Matching. There are many problems involving string matching and alignment which are solvable using dynamic programming in time, on strings of length . A prominent example is computing the edit distance [MP80]. Can edit distance be computed in time?
3. Practicality? There are two potential impediments to making the approach of this paper work in practice: (1) the translation from circuits to polynomials, and (2) Coppersmith’s matrix multiplication algorithm. For case (1), there are no large hidden constants inherent in the Razborov-Smolensky translation, however the expansion of the polynomial as an XOR of ANDs yields a quasi-polynomial blowup. A careful study of alternative translations into polynomials would likely improve this step for practice. For case (2), Coppersmith’s algorithm as described in Appendix C consists of a series of multiplications with Vandermonde and inverse Vandermonde matrices (which are very efficient), along with a recursive step on and matrices, analogous to Strassen’s famous algorithm. We see no theoretical reason why this algorithm (implemented properly) would perform poorly in practice, given that Strassen’s algorithm can be tuned for practical gains [GG96, CLPT02, DN09, BDLS12, BDH+12]. Nevertheless, it would likely be a substantial engineering challenge to turn the algorithms of this paper into high-performance software.
5. Truly Subcubic APSP? What other circuit classes can compute inner product and also permit a fast evaluation algorithm on many inputs? This question now appears to be central to the pursuit of truly subcubic ( time) APSP. Although we observe in the paper that inner product is efficiently computable in , the usual algebraic inner product is in fact not in . (Multiplication is not in , by a reduction from Parity [CSV84].) This raises the intriguing possibility that matrix product (and hence APSP) is not only in truly subcubic time, but could be easier than integer matrix multiplication. A prerequisite to this possibility would be to find new Boolean matrix multiplication algorithms which do not follow the Strassenesque approaches of the last 40+ years. Only minor progress on such algorithms has been recently made [BW09].
Many thanks to Virginia Vassilevska Williams; without her as a sounding board, I would have stopped thinking about APSP a long time ago. I’m also grateful to Uri Zwick, Farah Charab, and the STOC referees for helpful comments. Thanks also to Eric Allender for a discussion on references.
References
Appendix A Proof of Lemma 2.1
Before giving the circuit, let us briefly discuss the encoding of . In principle, all we need is that encodes an integer greater than , and that addition of with any number equals again. With that in mind, we use the following convention: bits are allocated to encode each number in (with two leading zeroes), and is defined as the all-ones string of bits.
The addition of two -bit strings and is computable in size and constant depth, using a “carry-lookahead” adder [SV84] (with an improved size bound in [CFL85]). Recall that a carry-lookahead adder determines in advance:
which bits of and will “generate” a when added, by taking the AND of each matching pair of bits from and , and
which bits of and will “propagate” a if given a from the summation of lower bits, by taking the XOR of each matching pair of bits.
The “generate” and “propagate” bits can be generated in constant depth. Given them, in parallel we can determine (for all ) which bits of the addition will generate a carry in constant depth, and hence determine the sum in constant depth. (To handle the case of , we simply add a side circuit which computes in parallel if one of the inputs is all-s, in which case all output bits are forced to be .)
Chandra, Stockmeyer, and Vishkin [CSV84] show how to compute the minimum of a collection of numbers (given as bit strings) in . For completeness, we give a construction here. First, the comparison of two -bit strings and (construed as non-negative integers) is computable in . Define
where stands for addition modulo . The first disjunct is true if and only if . For the second disjunct and given , the inner expression is true if and only if the first bits of and are equal, the th bit of is , and the th bit of is 1. Replacing each with , we obtain an circuit.
Appendix B Appendix: Derandomizing the APSP algorithm
Reminder of Theorem 3.1 There is a and a deterministic algorithm for APSP running in time on the real RAM.
The proof combines the use of Fredman’s trick in Theorem 1.1 with the deterministic reduction from circuits to polynomials in Theorem 2.1.
Therefore we can reduce an and min-plus matrix product to a matrix product over the integers, by replacing each row of the first matrix by a corresponding of length
We derive an upper bound on as follows:
hence suffices for sufficiently large .
Examining the proof of Theorem 2.2 shows that we can estimate , where is the depth of the original circuit. However, as Beigel and Tarui’s proof also works for the much more expressive class (and not just ), we are confident that better estimates on are possible with a different argument, and hence refrain from calculating an explicit bound here.
Appendix C Appendix: An exposition of Coppersmith’s algorithm
In 1982, Don Coppersmith proved that the rank (that is, the number of essential multiplications) of and matrix multiplication is at most . Prior work has observed that his algorithm can also be used to show that the total number of arithmetic operations for the same matrix multiply is . However, the implication is not immediate, and uses specific properties of Coppersmith’s algorithm. Because this result is so essential to this work and another recent circuit lower bound [Wil13], we give a self-contained exposition here.
For all sufficiently large , the rank of matrix multiplication is at most .
We wish to derive the following consequence of Coppersmith’s construction, which has been mentioned in the literature before [SM83, ACPS09, Wil11]:
For all sufficiently large , and , multiplication of an matrix with an matrix can be done in arithmetic operations, over any field with elements.
Note Lemma C.1 has been “improved” in the sense that the upper bound on has been increased mildly over the years [Cop97, HP98, KZHP08, Gal12]. However, these later developments only run in time, not time (which we require). Our exposition will expand on the informal description given in recent work [Wil11].
First, observe that the implication from Theorem C.1 to Lemma C.1 is not immediate. For example, it could be that Coppersmith’s algorithm is non-uniform, making it difficult to apply. As far as we know, one cannot simply take “constant size” arithmetic circuits implementing the algorithm of Theorem C.1 and recursively apply them. In that case, the factor in the running time would then become for some constant (depending on the size of the constant-size circuit). To keep the overhead polylogarithmic, we have to unpack the algorithm and analyze it directly.
Coppersmith’s algorithm builds on many other tools from prior matrix multiplication algorithms, many of which can be found in the highly readable book of Pan [Pan84]. Here we will give a very brief tutorial of some of the aspects.
Essentially all methods for matrix multiplication are bilinear (and if not, they can be converted into such algorithms), meaning that they can be expressed in the so-called trilinear form
where , , and are constant-degree polynomials in over the field, and is a polynomial with constant coefficient . Such an algorithm can be converted into one with no polynomials and minimal extra overhead (as described in Coppersmith’s paper). Typically one thinks of and as entries in the input matrices, and as indeterminates, so the LHS of (4) corresponds to a polynomial whose coefficient is the entry of the matrix product. Note the transpose of the third matrix corresponds to the final matrix product.
To give an explicit example, we assume the reader is familiar with Strassen’s famous method for matrix multiply. Strassen’s algorithm can be expressed in the form of (4) as follows:
The LHS of (4) and (C.1) represents the trace of the product of three matrices , , and (where the entry of matrix is ). It is well known that every bilinear algorithm naturally expresses multiple algorithms through this trace representation. Since
if we think of as a symbolic matrix and consider (4), we obtain a new algorithm for computing a matrix when given and . Similarly, we get an algorithm for computing a when given and , and analogous statements hold for computing , , and . So the aforementioned algorithm for multiplying a sparse and sparse yields several other algorithms.
Schönhage’s decomposition paradigm.
Coppersmith’s algorithm follows a specific paradigm introduced by Schönhage [Sch81] which reduces arbitrary matrix products to slightly larger matrix products with “structured nonzeroes.” The general paradigm has the following form. Suppose we wish to multiply two matrices and .
First we preprocess and in some efficient way, decomposing and into structured matrices so that . (Note, the dimensions of may differ from , and similarly for and .) The matrices and are sparse “partial” matrices directly based on and , but they have larger dimensions, and only contain nonzeroes in certain structured parts. The matrices and are very simple and explicit matrices of scalar constants, chosen independently of and . (In particular, and are Vandermonde-style matrices.)
Next, we apply a specialized constant-sized matrix multiplication algorithm in a recursive manner, to multiply the structured and essentially optimally. Recall that Strassen’s famous matrix multiplication algorithm has an analogous form: it starts with a seven-multiplication product for matrix multiplication, and recursively applies this to obtain a general algorithm for matrix multiplication. Here, we will use an optimal algorithm for multiplying constant-sized matrices with zeroes in some of the entries; when this algorithm is recursively applied, it can multiply sparse and with nonzeroes in certain structured locations.
Finally, we postprocess the resulting product to obtain our desired product , by computing . Using the simple structure of and , the matrix products and can be performed very efficiently. Our aim is to verify that each step of this process can be efficiently computed, for Coppersmith’s full matrix multiplication algorithm.
C.2 The algorithm
The construction of Coppersmith begins by taking input matrices of dimensions and of dimensions where , and obtains an algorithm for their multiplication. Later, he symmetrizes the construction to get an matrix multiply. We will give this starting construction and show how standard techniques can be used to obtain an matrix multiply from his basic construction.
The multiplication of and will be derived from an algorithm which computes the product of and matrices with zeroes in some entries. In particular the matrices have the form:
and the algorithm is given by the trilinear form
When the algorithm given by (6) is applied recursively to and matrices (analogously to how Strassen’s algorithm is applied to do matrix multiply), we obtain an algorithm that can multiply matrices and with dimensions and , respectively, where has nonzeroes, has nonzeroes, and these nonzeroes appear in a highly regular pattern (which can be easily deduced). This recursive application of (6) will result in polynomials in of degree , and additions and multiplications on such polynomials increase the overall time by an factor. Therefore we can multiply these and with structured nonzeroes in field operations.
The decomposition of and is performed as follows. We choose and to have dimensions and , respectively, and such that all submatrices of and submatrices of are non-singular. Following Schönhage, we pick and to be rectangular Vandermonde matrices: the entry of is , where are distinct elements of the field; is defined analogously. Such matrices have three major advantages: (1) they can be succinctly described (with field elements), (2) multiplying these matrices with arbitrary vectors can be done extremely efficiently, and (3) inverting an arbitrary square submatrix can be done extremely efficiently. More precisely, Vandermonde matrices can be multiplied with arbitrary -vectors in operations, and computing the inverse of an Vandermonde matrix can be done in operations (for references, see [CKY89, BP94]). In general, operations on Vandermonde matrices, their transposes, their inverses, and the transposes of inverses can be reduced to fast multipoint computations on univariate polynomials. For example, multiplying an Vandermonde matrix with a vector is equivalent to evaluating a polynomial (with coefficients given by the vector) on the elements that comprise the Vandermonde matrix, which takes operations. This translates to arithmetic operations.
The matrices and have dimensions and , respectively, where has only nonzeroes, has only nonzeroes, and there is an optimal algorithm for multiplying (with 5 nonzeroes) and matrices (with 4 nonzeroes) that can be recursively applied to multiply and optimally, in operations. Matrices and are constructed as follows: take any one-to-one mapping between the columns of the input and columns of the sparse with exactly nonzeroes. For these columns of with nonzeroes, we compute the inverse of the minor of with rows corresponding to the nonzeroes in the column, and multiply with column (in time). After these columns are processed, the rest of is zeroed out. Then, there is a one-to-one correspondence between columns of and nonzero columns of . Performing a symmetric procedure for (with the same mapping on rows instead of columns), we can decompose it into and such that there is a one-to-one correspondence between rows of and nonzero rows of . It follows that this decomposition takes only time. Since (within factors), this quantity is upper bounded by .
After and are constructed, the constant-sized algorithm for and mentioned above can be applied in the usual recursive way to multiply the sparse and in operations; call this matrix . Because and are Vandermonde, the product can be computed in operations. Hence we have an algorithm for multiplying matrices of dimensions and that is explicit and takes operations.
Call the above algorithm Algorithm 1. Observe Algorithm 1 also works when the entries of and are themselves matrices over the field. (The running time will surely increase in proportion to the sizes of the underlying matrices, but the bound on the number of operations on the entries remains the same.)
Up to this point, we have simulated Coppersmith’s construction completely, and have simply highlighted its efficiency. By exploiting the symmetries of matrix multiplication algorithms in a standard way, we can extract more algorithms from the construction. The trace identity tells us that
implying that the expression (6) can also be used to partially multiply a matrix with at most structured nonzeroes and “full” matrix in operations, obtaining a matrix with at most nonzeroes. In our Algorithm 1, we have a decomposition of and ; in terms of the trace, we can derive:
This can be applied to obtain an algorithm for matrix multiplication, as follows. Given input matrices and of the respective dimensions, we decompose into a with nonzeroes and Vandermonde , as described above. Letting be a Vandermonde matrix, we compute the matrix in at most operations. Noting that is , we can then multiply and in operations. This results in a matrix with at most nonzeroes. The final output is obtained by using the one-to-one mapping to extract the appropriate rows from , and multiplying each such row by the appropriate inverse minor of (corresponding to the nonzeroes of that row). This takes at most operations. Call this Algorithm 2.
From Algorithm 2 we immediately obtain an algorithm for matrix multiplication as well: given input matrices and of te respective dimensions, simply compute using Algorithm 2, and output the transpose of the answer. Call this Algorithm 3.
Finally, by “tensoring” Algorithm 2 with Algorithm 3, we derive an algorithm for matrix multiplication with dimensions
That is, we divide the two input matrices of large dimensions into blocks of and dimensions, respectively. We execute Algorithm 2 on the blocks, and call Algorithm 3 when the product of two blocks is needed.
As both Algorithm 2 and Algorithm 3 are explicit and efficient, their “tensorization” inherits these properties. Algorithm 2 uses operations, and each operation can take up to time (due to calls to Algorithm 3). Therefore, we can perform a matrix multiply over fields with elements, in time. Setting , the algorithm runs in time for fields with elements.