This week I focused on speeding up computations over GF(3). We have a number of matrices over GF(3) for which we want to compute the invariant factors. Fortunately, Bryan Youse has written a very efficient representation of these matrices called Sliced3. It uses 2 bits to represent each matrix element and operates over n/2 elements in parallel when computing a matrix-matrix multiplication where n is the word size. The code has been developed in parallel with the mainline Linbox source so the interface has diverged a bit from the rest of the Linbox matrix classes. Also, in order to speed up the critical applyLeft() method I had to specialize for this representation so that I use iterators directly rather than constructing temporary submatrices.
I further improved what I'm now calling my Pascal blackbox class which represents matrices of the form A_{i,j}=c_{i+j}{i+j\choose{}j} with elements in GF(3). It turns out it's not necessary to be fast when computing {n\choose{}k}, instead you can take advantage of the fractal structure of this matrix. A 3^{n}\times{}3^{n} matrix B_{i,j}={i+j\choose{}j} consists of 9 3^{n-1}\times{}3^{n-1} submatrices, B_{i,j} where B_{1,1}=B_{1,2}=B_{1,3}=B_{2,1}=B_{3,1}, B_{2,2}=-A_{1,1} and A_{2,3}=A_{3,3}=A_{3,2}=0. This gives rise to a natural recursive implementation of applyLeft() which proves to be about 10 times fast when used with the Sliced3 package than my old generic sparse matrix implementation. It also only uses O(n) memory instead of O(n^{\frac{4}{3}})
No comments:
Post a Comment