Snob : a C++ toolkit for fast Fourier transforms on the symmetric group Development version (unstable)
Risi Kondor Department of Computer Science Columbia University in the City of New York November 28, 2006
Contents 1 Introduction
2
2 Mathematical Background 2.1 The irreducible representations of the symmetric group . 2.2 Fast Fourier Transforms . . . . . . . . . . . . . . . . . . 2.3 Two forms of sparsity . . . . . . . . . . . . . . . . . . . 2.4 Two-sided cosets and twisted transforms . . . . . . . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
3 4 5 7 8
3 Using Sn ob 3.1 Operations on group elements . . . . . 3.2 The group Sn and its irreducibles . . . 3.3 Computing Fourier transforms . . . . 3.4 Partial and sparse Fourier transforms .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
10 10 12 17 20
4 Reference The header file Sn.h . . . . . The Sn classes . . . . . . . . Sn::Sn . . . . . . . . . . Sn::Element . . . . . . Sn::Irreducible . . . Sn::Function . . . . . . Sn::FourierTransform Sn::Ftree . . . . . . . . Helper classes . . . . . . . . . Cycles . . . . . . . . . . Partition . . . . . . . . StandardTableau . . . Matrix . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
23 23 24 24 25 26 28 29 30 32 32 33 34 35
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
1
Chapter 1
Introduction Sn ob is an object oriented C++ library for computing fast Fourier transforms (FFTs) and inverse fast Fourier transforms (iFFTs) on the symmetric group Sn . Sn ob supports partial Fourier transforms and Fourier transforms on sparse functions, making computations possible in the n = 10 ∼ 40 range, where enumerating all n! group elements is no longer feasible. Sn ob can also perform operations on individual group elements, compute characters, and compute representation matrices. Sn ob is optimized for speed and designed to provide a clean, easy to use application programming interface. Where this does not hinder performance, Sn ob uses the STL Standard Template Library. Sn ob does not use any general purpose numerical analysis or matrix libraries. The current release of Sn ob is a development version, subject to corrections and design changes. Sn ob comes with absolutely no guarantees regarding the accuracy of the results of its computations, the soundness of the code, or the documentation. Please reports errors and send suggestions to
[email protected]. Feedback is greatly appreciated. Sn ob is distributed in the form of a collection of source files, and has been tested on a Linux system with the GNU C++ compiler. Sn ob is open source software, released into the public domain under the GNU General Public License. Commercial use of Sn ob is prohibited. For details see http://www.gnu.org/copyleft/gpl.html or the file LICENSE, which is distributed along with the source code. The copyright to the present document is reserved by the author. Please cite Sn ob in all scientific publications reporting computations performed with S n ob, presenting extensions of Sn ob, or describing Sn ob itself. The appropriate bibtex entry is supplied with the package in the file SnOB.bib.
Risi Kondor, New York, August, 2006
2
Chapter 2
Mathematical Background Given n distinct objects x1 , x2 , . . . , xn , a permutation of these objects is a bijective map σ : {1, 2, . . . , n} → {1, 2, . . . , n}, where σ(i) expresses which position xi appears in in the permuted sequence. Thus, the permutation of x1 , x2 , . . . , xn induced by σ is xσ−1 (1) , xσ−1 (2) , . . . , xσ−1 (n) . The product of two permutations σ1 and σ2 is defined by composition, i.e, (σ2 σ1 )(i) = σ2 (σ1 (i)) for all i = 1, 2, . . . , n. The inverse of σ is the permutation σ −1 corresponding to the inverse mapping. Under these operations the n! different permutations of n objects form a group called the symmetric group of order n. We denote this group Sn . The identity element e of Sn is the identity permutation, e(i) = i. We use the letter ρ to denote complex valued matrix representations of Sn , and the dimensionality of ρ we denote by dρ . Thus, ρ is a map Sn → Cdρ ×dρ . A complete set of inequivalent irreducible representations of Sn we denote by Rn . The Fourier transform (FT) of a function f : Sn → C is defined as the set of matrices X fb(ρ) = f (σ) ρ(σ) ρ ∈ Rn . (2.1) σ∈Sn
The inverse transform is
f (σ) =
h i 1 X dρ tr fb(ρ) ρ(σ) n!
σ ∈ Sn .
(2.2)
ρ∈Rn
L dρ ×dρ The Fourier transform F : f 7→ fb is a linear transformation from Cn! to , sharing several ρ∈R C important properties with the classical Fourier transforms. In particular, F is a unitary map with respect to the inner products hf, gi =
1 X f (σ) g(σ) n! σ∈Sn
and
h fb, gb i =
1 X dρ h fb(ρ) , gb(ρ) iS , (n!)2
(2.3)
ρ∈Rn
where h·, ·iS is the usual inner product of matrices P tr AB . Another important property of F is that defining the convolution of f, g : Sn → C as (g ∗ f )(σ) = τ ∈Sn g(τ σ −1 ) f (σ), (g[ ∗ f )(ρ) = gb(ρ) · fb(ρ)
ρ ∈ Rn ,
(2.4)
where · denotes matrix multiplication. In fact, unitarity and the convolution theorem together uniquely define F, up to conjugacy of Fourier components. Much of the practical interest in Fourier transformation stems from these properties.
3
Sn ob manual
2.1
Mathematical Background
The irreducible representations of the symmetric group
Pk A partition of n is a sequence λ = (λ1 , λ2 , . . . , λk ) of weakly decreasing positive integers such that i=1 λi = n. We use the notation λ ` n to denote that λ is a partition of n. Graphically partitions are represented by Young diagrams, which consist of laying down λ1 , λ2 , . . . , λk boxes in consecutive rows. For example,
corresponds to λ = (4, 3, 1). There is a natural partial order induced on partitions by inclusion, whereby λ0 λ if and only if λ0i ≤ λi for i = 1, 2, . . . , k (if k 0 < k, we take λ0i = 0 for k 0 < i ≤ k). The partitions λ ` n index the irreducibles of Sn . The representation corresponding to λ we denote ρλ ; its dimensionality dλ ; the corresponding character χλ (σ) = tr [ρλ (σ)]; and the corresponding Fourier component fb(λ). Bijectively filling in the boxes of a Young diagram with the numbers 1, 2, . . . , n gives a Young tableau. A tableau such as 1 2 4 3 5 which satisfies the property that in each row the numbers increase from left to right and in each column they increase from top to bottom is called a standard tableau. A key result in the representation theory of the symmetric group asserts that the Young tableaux of shape λ are in bijection with the dimensions of ρλ . We use standard tableaux to index the rows and columns of the representation matrices. There are several alternatives for constructing the actual matrix entries. Because of its computational advantages, in Sn ob we exclusively use Young’s orthogonal representation (YOR). To present YOR we need a few more concepts. A transposition ( i, j ) is a permutation that exhanges i and j and leaves everything else invariant, i.e., ( i, j )(i) = j, ( i, j )(j) = i and ( i, j )(k) = k for all k 6∈ {i, j}. Adjacent transpositions are transpositions of the form τi = ( i, i+1 ). It is not difficult to see that any σ ∈ Sn can be expressed as a product of adjacent transpositions, in fact, one such factorization is given in the next section. We define YOR by explicitly constructing the matrix entries of ρλ (τk ). For general σ, the representation matrix ρλ (σ) is then computed by factoring σ into a product of adjacent transpositions and multiplying the corresponding ρλ (τk ). We define YOR through the action of permutations on tableaux: if t is a standard tableau, then τ k (t) is the tableau that we get by interchanging k and k + 1 in t. However, τk (t) might or might not be a standard tableau. Accordingly, there are two distinct cases to consider. If τk (t) is not a standard tableau, then the column of ρλ (τk ) labeled by t in YOR is all zero, except for the diagonal element [ρλ (τk )]t,t = 1/dt (k, k + 1).
(2.5)
If τk (t) is a standard tableau, then in addition to this diagonal element, we also have a non-zero off-diagonal element, namely p (2.6) [ρλ (τk )]τk (t),t = 1 − 1/dt (k, k + 1)2 . All other matrix entried of ρλ (τk ) are zero. In the above dt (k, k + 1) is a special signed distance defined on Young tableaux. If i is a numeral in t, then the content of i, denoted c(i), is the column index minus the row index of the cell where i is to be found. The distance dt (i, j) is then defined as c(j) − c(i). Part of the computational appeal of YOR is that the ρλ (τk ) matrices are very sparse, and hence can be mutliplied together efficiently. Another special property of YOR is that the representations matrices are real. This allows us to restrict the entire implementation of Sn ob to the real domain. In the following pages we consider the more general complex case, while in the code the user is free to choose the base field by setting a master variable at compile time.
4
Sn ob manual
2.2
Mathematical Background
Fast Fourier Transforms
The Fourier transform on Sn is a linear transformation between n!-dimensional spaces. Thus, a naive 2 implementation of Fourier transformation would run in O(| Sn | ) = O((n!)2 ) time. The recent development of fast Fourier transforms (FFTs) for non-commutative groups, starting with Clausen’s FFT for S n [Clausen, 1989] opened a new chapter in computational group theory by reducing this computational burden to O(| Sn | logk | Sn |) where k is a small integer. While Clausen’s result has since been improved [Maslen, 1998][Maslen and Rockmore, 2000], Sn ob is based on Clausen’s original algorithm, which is still the most accessible. For some excellent surveys see [Maslen and Rockmore, 1997b] and [Maslen and Rockmore, 1997a]. Clausen’s algorithm uses a specific type of decomposition of permutations into a product of contiguous cycles. The contiguous cycle Jp, qK ∈ Sn is the permutation i + 1 for p ≤ i ≤ q − 1 Jp, qK(i) = 1 ≤ p ≤ q ≤ n. p for i = q i otherwise In other words, Jp, qK cyclically permutes p, p+1, . . . , q and leaves everything else invariant. Jp, qK can easily be factored into a product of q − p − 1 adjacent transpositions: Jp, qK = ( p, p + 1 ) . . . ( q − 2, q − 1 )( q − 1, q ). Now observe that for any σ ∈ Sn , the product Jσ(n), nK−1 σ fixes n, i.e., σn−1 = Jσ(n), nK−1 σ ∈ Sn−1 ,
(2.7)
where (as in the following) for k < n, Sk is the subgroup of Sn permuting 1, 2, . . . , k, and leaving k + 1, k + 2, . . . , n fixed. Applying the same manoeuver to σn−1 , σn−2 = J σn−1 (n − 1) , n − 1 K−1 Jσ(n), nK−1 σ ∈ Sn−2 . Iterating down to S1 , we get Jp2 , 2K−1 Jp3 , 3K−1 . . . Jpn , nK−1 σ = e for some p2 , p3 , . . . , pn . Rather than the actual values of p2 , p3 , . . . , pn , what is important is that this procedure furnishes a unique factorization of σ, σ = Jpn , nK Jpn−1 , n − 1K . . . Jp2 , 2K, adapted to the chain of subgroups S1 < S2 < . . . < Sn in the sense that Jpk , kK ∈ Sk . We present the recursive step at the heart of Clausen’s algorithm in the form of a theorem. Theorem 1 Let f be a function Sn → C and let X fb(λ) = ρλ (σ) f (σ)
λ`n
(2.8)
σ∈Sn
be its Fourier transform with respect to Young’s orthogonal representation. Now for i = 1, 2, . . . , n define fi : Sn−1 → C as fi (σ 0 ) = f (Ji, nK σ 0 ) for σ 0 ∈ Sn−1 , and let X λ− ` n − 1 (2.9) ρλ−(σ 0 ) fi (σ 0 ) fbi (λ− ) = σ 0 ∈Sn−1
be the corresponding Fourier transforms, again with respect to Young’s orthogonal representation. Then up to reordering of rows and columns, fb(λ) =
n X
ρλ (Ji, nK)
i=1
M
λ− ∈R(λ)
where R(λ) = { λ− ` n − 1 | λ− λ }.
5
fbi (λ− ),
(2.10)
Sn ob manual
Mathematical Background
qqccccc J2, 3KJ1, 2K S1 J1, 3K S2 mm[[[[[ J2, 3KJ2, 2K S1 pp ppp p p pp pxxoo pp qqccccc J2, 3KJ1, 2K S1 J2, 3K S2 mm[[[[[ S3 Nff N NNN J2, 3KJ2, 2K S1 NNN NNN N qqccccc J3, 3KJ1, 2K S1 J3, 3K S2 mm[[[[[ J3, 3KJ2, 2K S1
function FFT(k, f ) { for i ← 1 to k { fbi ← FFT(k − 1, fi ) ;} for each λ ` k do { fb(λ) ← 0dλ ×dλ ; for i ← 1 to k { L fb(λ) ← fb(λ) + ρλ (Ji, kK) λ− ∈R(λ) fbi (λ− ) ; } } return fb; }
Figure 2.1: Clausen’s FFT splits the Fourier transform into a combination of smaller Fourier tranforms over left cosets of Sn , here illustrated for the case of S3 . The pseudocode of the FFT is on the right. Proof. Factoring σ as Ji, nK σ 0 as in (2.7) allows us to write (2.8) in the form fb(λ) =
n X
ρλ (Ji, nK)
i=1
X
ρλ (σ 0 ) fi (σ 0 ) .
(2.11)
σ 0 ∈Sn−1
The inner summation is similar to (2.9), but the two are not the same, since ρ λ is in general not an irreducible of the smaller group Sn−1 . Rather, by standard results from representation theory, on restriction to S n−1 , it splits into irreducibles of Sn−1 in the form M T −1 ρλ (σ 0 ) T = ρ− (σ 0 ) σ 0 ∈ Sn−1 (2.12) ρ−
for some invertible square matrix T . The sum extends over some subset of R n−1 , and in general may contain repeats. For computational purposes it is highly desirable to have T = I. Representations R n and Rn−1 achieving this are called adapted representations. To prove that Young’s orthogonal representations are adapted in this sense, consider the standard tableaux {t} labeling the dimensions of ρλ . The number n is always at an outer corner in these tableaux (Figure (2.2)). The critical observation is that the way we defined the action of transpositions (in general, the action of permutations) on tableaux, if σ 0 is restricted to Sn , then it leaves n in the same box. Hence, ρλ (σ 0 ) splits into blocks corresponding to which outer corner n is located at in the corresponding standard tableaux. Careful examination of the definition of YOR reveals that each such block is, in fact, identical to ρλ− (σ 0 ), where λ− ` n − 1 is the partition that we get by removing the box containing n from λ. This proves that YOR is an adapted representation; that for the symmetric group the multiplicity of each ρ − in (2.12) is just 1; and that ρ− runs over all irreducibles of Sn corresponding to those partitions that we get by removing one of the outer corners from λ. The latter are just {ρλ− }λ− ∈R(λ) . L Substituting ρλ (σ 0 ) = λ− ∈R(λ) ρλ− (σ 0 ) in (2.11) and comparing with (2.9) gives exactly (2.11). Clausen’s FFT proceeds by recursively applying Theorem 1 down to S1 . On S1 Fourier transformation is trivial, since R1 consists of the single irreducible ρ(1) = ρtriv , and hence fb((1)) = f (e). In effect, the FFT employs a “divide and conquer” type strategy, dividing Sn into the n cosets Ji1 , nK Sn−1 , which are in turn each divided into n−1 cosets Ji1 , nKJi2 , n−1K Sn−2 , etc.. (Figure 2.1, left). The pseudocode of the algorithm is presented in the same figure, on the right. 9 9 9 Figure 2.2: The possible positions of n = 9 in standard tableaux of shape λ = (4, 2, 2, 1). 6
Sn ob manual
Mathematical Background
While the algorithmic implementation of the FFT is depth first, for purposes of analysis we can also look at it as a sequence of transformations from a collection of FTs over Sk−1 cosets to Sk cosets. Given that each of these transformations is a linear map Fk : Cn! → Cn! , it is remarkable that the total number of scalar n!. The algorithm owes its efficiency to the following operations required by the FFT is just (n+1)n(n−1) 3 factors: 1. As k decreases, the various fb(λ) matrices rapidly decrease in size.
2. Thanks to the special properties of YOR, multiplying by ρλ (Ji, kK) can be accomplished very fast.
3. There is considerable overlap between R(λ) for different partitions, so we don’t have to recompute a different set of {fb(λ− )}λ− ∈Rk−1 for each λ ∈ Rk .
As explained in the proof of Theorem 1, R(λ) are those partitions that we get by removing an outer corner from λ. This splitting behavior is represented by a so-called Bratelli diagram (Figure 2.3, left). A schematic of the entire FFT on Sn is presented in the same figure on the right. Such diagrams will be important for understanding the partial Fourier transforms of the next section. The ideas behind Clausen’s FFT are easily adapted to computing the inverse Fourier transform as well. The key observation is that each Fi is itself a unitary transformation, hence the FFT can be reversed simply by applying the conjugate transpose transformation in each stage, and reversing the order of the stages. The pseudocode for the inverse FFT is the following. function iFFT(k, fb, σ){ if k = 1 { f (σ) ← fb; } else { for i ← 1 to k { for each λ− ` k − 1 do { fbi (λ− ) = 0; } for each λ ` k do { M ← ρλ (Ji, kK−1 ) · fb(λ); c ← 1; for each λ− ∈ R(λ) do { fbi (λ− ) ← fbi (λ− ) + k ddλ− M (c : c + dλ− − 1, c : c + dλ− − 1); λ c ← c + dλ ; }} iFFT(k − 1, fbi , σ · Ji, kK); }}} The inverse FFT appears to be more complicated than the forward FFT, but that is mostly due to the fact that decomposing M into blocks of specified sizes is more difficult to notate than it is to notate assembling it from similar blocks. The notation M (a : b, c : d) stands for the block of elements in M from row a to row b and from column c to column d (inclusive). The factor k ddλ− is required to compensate for λ
the dλ /n! multipliers in the inner products in (2.3). Note that in YOR ρλ (Ji, kK−1 ) = [ρλ (Ji, kK)]> .
2.3
Two forms of sparsity
While the O(n!n3 ) run time of the FFT is much less than the run time of a naive Fourier Transform, for n greater than about 12 it is still forbiddingly expensive. Considering that 12! is close to 500 million, even storing f in memory becomes problematic in this range. One way to exploit the theory of harmonic analysis on Sn is to appeal to smoothness properties of f and only maintain the first few components of fb. As in the classical case, this will correspond to band-limited functions on S n [Kueh et al., 1999]. Since now the components are not conveninetly labeled by real numbers, which of them are “low-frequency” components is a somewhat delicate question that we cannot discuss here in detail. We content ourselves by stating that in general, the smoothest components are (n), (n − 1, 1), (n − 2, 2), (n − 2, 1, 1), etc.. 7
Sn ob manual
Mathematical Background
ff fffff fffff fffff s ffff f U,Y3,3I d I ,,33 IIII u ,, 33 III uu uu II u ,, 33 II uu ,, 33 II uu ,, 333 uuIuIuII u I ,, 33 uu II II I , u3uu , uu 333 II
uuu,, 3 I zuu ,, aa33aaaaaaaaaa
a a pk aaaaa,,aa 33 a X W.X1.1;] aD;DXXXXXX,,XXXX 33
,, XX3X3X XX
X .1.1;;DDD XXX 3 .1.1 ;;;DDD ,, 3
XX ..11 ;; DDD,, 3 3 nnn 3 ..11;;; DD,,
3n3nnn D n 1 .. 11 ;;; ,,DDn
Dnnn 33 .. 1 nn;n;n, , DD 33 n.n1n1 n ; ;, D DD 33 vn nnnn ... 111
;,,;,; DDD 3z3zz DzDz 33 ,,;; ..
11 z h[6PPP D ; z 3 66 PPPP
.. 11 ,, z;;zz DD3 66 P PP.P. 11 z,z, ;;; 66
.P. P1Pz1 Pzz ,, ;; 6 6 z.z.z 11 PPP,P, ;;
66 zzz .. 11 ,P, PPP ;;
z6z6z6 .. 111 ,, PP
z 6 .. 1 f,ffff zzz 66 ff. ff1f , }z zz fff ff6f6 ff .. 111 ,,, 66 .. 1 , sn ]f]f]f]f]] f ] 1 6 dI ]]]]]]6]6]]].]. ]]]11],,], ] _I ? ??III 66 .. 11 , u ?? II 66 . uu1u,, ?? II 66 uu..u 11, ??IIII 1,1, u . uu66 . ?? I ?? IuIuIuIu 666 .. . ??u II u II 666.. uu ??? II 6 . uu ?? II 66.. uuu II ?? uuuu ?? ?? u z u ?? X k XXXX ?? XXXXX XXXXX XXXXX ??? XXXXX
ffMMM MM oo Vjj VVV ffMMM M Mff MM htt hhh ooMff MM Mff MM MqMqMq xxqq M oo MM tthhhhh Vjj VVVV jjVVVV Mff MMqq V tthhhhhh qq qxxoo qqMM xxqqq qq Vjj VVV qqq q q x x V q h qxxoo qq tthhhhh qqq qxx qq
dd q dddddd x d h PP xxxx ^==P == PPxPxP nn =xx nPnP xx==nnn P {vxxndndndnd=d=dddd n qZ md = hP F c FPZPZPZZZZ=Z=Z=ZZ FFPPP =n=n F PnPn = nFFnFn PP v nnnn FFF mn Z ZZZZZZZ FF ZZZ
ojUU UUUUiiiiii iii UUUUU i ot ii
dd q dddddd x d h PP xxxx =^ =P == PPxPxP nn =x=xx nnnPnPP xnxnnn==nd=dddd {x d n vd d d d mqZ = hP F c FPZPZPZZZZ=Z=Z=ZZ FFPPP =n=n F PnPn = nFFnFn PP v nnnn FFF n mZ ZZZZZZZ FF ZZZ
ojUU UUUUiiiiii ii UUUUU t iii oi
dd d q dddddd x h PP xxxx =^ =P == PPxPxP nn =x=xx nnnPnPP xxnn=n {x n v ndnddd=d==dddd d qmZ hcPPZPZZZZZ=Z=ZZZ F FFPPP == FF PPnPnn=n= nFFnFn PP v nnnn FFF n mZ ZZZZZZZ FF ZZZ
ojUU UUUUiiiiii ii UUUUU t iii oi
dd d q dddddd x h PP xxxx =^ =P == PPxPxP nn =x=xx nnnPnPP xxnn=n {x n v ndnddd=d==dddd d qmZ hP F c FPZPZPZZZZ=Z=Z=ZZ FFPPP =n=n FFFnPnPnPP= nnnnFFF F n vnZn mZ ZZZZZZZ FF ZZ
ojUU UUUUiiiiii ii UUUUU t iii oi
ojUU UUUUiiiiii ii UUUUU t iii oi ojUU UUUUiiiiii ii UUUUU t iii oi
ojUU UUUUiiiiii ii UUUUU t iii oi ojUU UUUUiiiiii ii UUUUU t iii oi
ojUU UUUUiiiiii ii UUUUU t iii oi ojUU UUUUiiiiii ii UUUUU t iii oi
ojUU UUUUiiiiii ii UUUUU t iii oi ojUU UUUUiiiiii ii UUUUU t iii oi
Figure 2.3: The Bratelli diagram for S5 and the information flow in the FFT on S4 . One of the ways in which Sn ob extends Clausen’s FFT is by implementing fast partial Fourier transforms, which compute fb only at a subset P of the partitions {λ ` n}. This makes non-trivial computations possible on a regular desktop machine with n well into the twenties. Fast partial Fourier transforms are computed by restricting Clausen’s algorithm to those paths in the Bratelli diagram that lead to the desired components (Figure 2.4, left). More explicitly, if f is a P -bandlimited function on Sn , then at each level k only { fλ− | λ− ` k, λ− λ for some λ ∈ P } components are non-zero, so only these need to be computed. Otherwise, the FFT and its inverse are much the same as described in the previous section. In practical applications sparsity in fb is likely to co-occur with sparsity in f . While the former restricts the algorithm to a subset of the paths in the Bratelli diagram, the latter restricts it to a subset of the paths connecting the various cosets (Figure (2.4), right). Sn ob contains a special recursive data structure, Sn::Ftree to handle both types of sparsity. In general, the philosophy behind Sn ob is to regard the graph shown in Figure (2.3) as a network on which computations pass messages from one node to another. The Sn::Ftree data structure is used to construct the active subnetwork for a given combination of sparsity and band limits. Fourier transforms and other operations are then carried out on this structure, as opposed to the original network. Computations starting and finishing at internal nodes are also possible.
2.4
Two-sided cosets and twisted transforms
Clausen’s algorithm, as described in Section 2.2, hinges on splitting S n into a union of cosets J1, nK Sn−1 , J2, nK Sn−1 , . . . , Jn, nK Sn−1 , but this is not the only possible Sn−1 -coset partition of Sn . We could equally
ffMMM MM oo ffMMM M Mooff MM MM ffxx
qq
ooxx
xxjj xxoo tt
oo
mm
jjVVVV htt hhh ffMMM MM
Mff MM MM Vjj VVV h h V tthVjj h h VVVV hhhhh htt
xx ( 2, 3 ) S2 S3 Nffoo N NNN NNN NNN N ( 3, 3 ) S2
xx
qqccccc ( 2, 3 )( 2, 2 ) S1 mm qqccccc ( 3, 3 )( 2, 2 ) S1 mm[[[[[ ( 3, 3 )( 2, 2 ) S1
xx Figure 2.4: Two forms of sparsity: partial Fourier transforms restrict us to a subtree of the Bratelli diagram, while sparse functions restrict us to a subtree of the coset tree.
8
Sn ob manual
Mathematical Background
well use the right cosets Sn−1 J1, nK, Sn−1 J2, nK, . . . , Sn−1 Jn, nK, or, at a slight computational penalty, for fixed j, we could use the two-sided cosets J1, nK Sn−1 Jj, nK, J2, nK Sn−1 Jj, nK, . . . , Jn, nK Sn−1 Jj, nK. Theorem 2 Let f be a function Sn → C and let X ρλ (σ) f (σ) fb(λ) =
λ`n
(2.13)
σ∈Sn
be its Fourier transform with respect to Young’s orthogonal representation. Let j be a fixed integer 1 ≤ j ≤ n. Now for i = 1, 2, . . . , n define fiL , fiR : Sn−1 → C as fiL (σ) = f (Ji, nK σ Jj, nK) and fiR (σ) = f (Jj, nK σ Ji, nK). Let X X fbiL (λ− ) = ρλ− (σ 0 ) fiL (σ 0 ) and fbiR (λ− ) = ρλ− (σ 0 ) fiR (σ 0 ) λ ` n−1 σ 0 ∈Sn−1
σ 0 ∈Sn−1
be the corresponding Fourier transforms, again with respect to Young’s orthogonal representation. Then up to reordering of rows and columns, # " n i h M X L · ρλ (Jj, nK), (2.14) fbi (ρλ− ) ρλ (Ji, nK) fb(λ) = i=1
λ− ∈R(λ)
and
fb(λ) = ρλ (Jj, nK) ·
"
n h M X
i=1 λ− ∈R(λ)
where R(λ) = { λ− ` n − 1 | λ− λ }.
fbiR (ρλ− )
i
#
ρ(Ji, nK) ,
(2.15)
The proof of this theorem is very similar to the proof of Theorem 1. Just as before, (2.14) and (2.15) can be applied recursively down to S1 to yield a fast Fourier transform. To distinguish the various cases, FFTs based on (2.14) and (2.15) we respectively call left-hand and right-hand FFTs. When j = n (i.e., when ρ(Jj, nK) disappears), we say that the FFT is straight, otherwise we say that it is twisted. When forming the full FFT, right-hand and left-hand steps may in priciple be mixed, and j can be different at each level. Sn ob supports all of these variations. The purpose of these generalizations is to be able to compute Fourier transforms at various combinations of double cosets. In general, given k ≤ n, and two permutations σL , σR ∈ Sn with the property σL (i) = i and σR (i) = i for 1 ≤ i ≤ k, and a (partial) Fourier transform fb: Sn → C, we compute the Fourier transform at σ L Sk σ R , X ρλ (τ ) f (σL τ σR ) λ ` k, fbσσLR (λ) = τ ∈Sk
by factoring σL and σR as
σL = Jpn , nK Jpn−1 , n − 1K . . . Jpk+1 , k + 1K σR = Jqk+1 , k + 1K Jqk+2 , k + 2K . . . Jqn , nK and descending from fb through a succession of double cosets Sn ,
Jpn , nK Sn−1 Jqn , nK, Jpn , nK Jpn−1 , n − 1K Sn−2 Jqn−1 , n − 1KJqn , nK, .. .. .. .. . . . . Jpn , nK Jpn−1 , n − 1K . . . Jpk+1 , k + 1K Sk Jqk+1 , k + 1K . . . Jqn−1 , n − 1KJqn , nK.
9
Chapter 3
Using Snob The source code of all the examples in this chapter may be found in the examples directory of the S n ob package. Wherever possible we show both the complete source and the output of the examples in the text.
3.1
Operations on group elements
In Sn ob , permutations σ ∈ Sn are represented by objects of class Sn::Element. The constructor Sn::Element(n) returns the unit element of Sn , while Sn::Element(p1,p2,...,pn,NULL) constructs σ ∈ S n which would permute (1, 2, . . . , n) to (p1 , p2 , . . . , pn ), i.e., σ −1 (i) = pi . The degree n is determined automatically from the number of arguments to the constructor. Whenever a function takes a variable number of arguments in Sn ob , the argument list must be terminated with NULL. Our first example demonstrates multiplying permutations together and taking their inverses: # include " SnElement . hpp " # include < iostream > main (){ Sn :: Element p1 (1,2,4,3,5, NULL ); Sn :: Element p2 (2,3,1,4,5, NULL ); Sn :: Element * a = p2 * p1 ; Sn :: Element * b = p2 . inverse (); Sn :: Element * c =(* b )* p1 ; cout