BULLETIN OF THE POLISH ACADEMY OF SCIENCES CONTROL AND ROBOTICS TECHNICAL SCIENCES, Vol. 67, No. 6, 2019 DOI: 10.24425/bpasts.2019.130874

Discrete and permutations

S. HUI1 and S.H. ŻAK2* 1 Department of Mathematical Sciences, San Diego State University, San Diego, CA 92182, USA 2 School of Electrical and Computer Engineering, Purdue University, West Lafayette, IN 47907, USA

Abstract. It is well known that the magnitudes of the coefficients of the discrete Fourier transform (DFT) are invariant under certain operations on the input data. In this paper, the effects of rearranging the elements of an input data on its DFT are studied. In the one-dimensional case, the effects of permuting the elements of a finite sequence of length N on its Discrete Fourier transform (DFT) coefficients are investigated. The permutations that leave the unordered collection of Fourier coefficients and their magnitudes invariant are completely characterized. Conditions under which two different permutations give the same DFT coefficient magnitudes are given. The characterizations are based on the automor- phism group of the additive group ZN of integers modulo N and the group of translations of ZN. As an application of the results presented, a generalization of the theorem characterizing all permutations that commute with the discrete Fourier transform is given. Numerical examples illustrate the obtained results. Possible generalizations and open problems are discussed. In higher dimensions, results on the effects of certain geometric transformations of an input data array on its DFT are given and illustrated with an example.

Key words: discrete Fourier transform (DFT), DFT invariants, Fourier coefficients, permutations, DFT coefficient magnitudes, circulant , pattern recognition.

1. Introduction of nonzero DFT coefficients, see for example [20]. This can be considered as the study of permutations of a spectrum with It is well known that the magnitudes of the coefficients of the nonzero entries at exactly the first k positions. discrete Fourier transform (DFT) are invariant under certain The rearrangement of a finite sequence is equivalent to operations on the input data. We are led to the study of how the composing it with a permutation. The technical definitions of rearrangement of a data set affects its discrete Fourier transform the terms that we use are reviewed in Section 2. This problem (DFT) coefficients by pattern recognition problems [11]. One has been studied by researchers in matrix theory and signal algorithm that was analyzed uses the unordered magnitudes processing, among other areas. For example, Chao [5] proved of the three-dimensional DFT coefficients to extract features that a permutation commutes with the DFT if and only if the from patterns. It is the invariance of the magnitudes of the DFT permutation is in the automorphism group of integers modulo coefficients under certain geometric transformations that makes N and is equal to its own inverse. This theorem is useful in them useful. the computation of eigenvalues for certain circulant matrices, Permutation of data occur naturally in many application see [2, 5]. In this paper, we use our results to generalize this areas. For example, the problem of recognition of permuted data theorem. Other results related to the DFT-permutation commu- is important in the study of mutation of DNA sequences; see tation problem can be found in [8, 25]. for example [7]. Pairwise relations such as similarities between A related problem is that of rearranging the DFT coeffi- data points and pattern classification play an important role in cients which is dual to the problem of rearranging the input via many areas of machine learning [10, 13, 22]. Frequency hop- the DFT IDFT (inverse DFT) duality. The rearrangements $ ping can be considered as the permutation in the frequency of DFT coefficients have been studied in relation to speech domain. An example where this is studied along with signal signal encryption (see for example [4] and [17]), energy com- recognition is in [15]. An application of permutations and the paction [23], as well as pattern classification [11]. A closely Fourier transform to image encryption can be found in [14]. related topic is the use of circulant matrices to encrypt speech Our analysis depends heavily on the fact that the DFT com- signals [16], which is equivalent to multiplying the DFT coef- mutes with certain subgroups of permutations. The study of ficients by a unimodular sequence, that is, a sequence with operators that commute with the DFT is important in the study modulus 1. of DFT eigenvectors, see for example [21]. A somewhat related The paper’s contributions are: problem is the study of data sequences with a small number k 1. Using the structures of subgroups to analyze the effects of permutations on DFT. 2. We prove that the unordered collection of the DFT coef- *e-mail: [email protected] ficients is invariant under a permutation if and only if the Manuscript submitted 2018-09-13, revised 2019-03-11 and 2019-04-02, permutation is in the group of automorphisms of the integers initially accepted for publication 2019-04-20, published in December 2019 modulo N. Furthermore, the DFT coefficients are permuted

Bull. Pol. Ac.: Tech. 67(6) 2019 995 S. Hui and S.H. Żak

by the inverse of the permutation. This is in Theorem 3 and obtained by rearranging the elements of x(1) , are the same, generalizes the theorem in [5] mentioned above. that is, A x(1) = A x(2) . On the other hand, the magnitudes of 3. We show that the unordered collection of the magnitudes of the coefficients of the DFT of the DFT coefficients is invariant under a permutation if and ¡ ¢ ¡ ¢ only if the permutation is in the product of the translation x(3) = 5 3 4 1 2 >, group and the automorphisms of the integers modulo N. This is Theorem 1. also obtained by rearranging the elements of x(1) , are 4. We demonstrate that two permutations of a sequence have the same DFT coefficients’ magnitudes if and only they are A x(3) = { 15.0000 3.6903 3.3737 3.3737 3.6903 }, in the same left coset of the product group. This result is the content of Theorem 2. This result fails for right cosets. which¡ differ¢ from the previously computed magnitudes. If we 5. We show that the unordered collection of the magnitudes now take of the multidimensional DFT coefficients is invariant when the data array is permuted by elements of a group that in- x(4) = 5 3 4 2 1 >, cludes reflection, rotation, and other common geometric operations. then we obtain The paper is organized as follows. In Section 2, we intro- duce the notation and review the basic concepts. The results on A x(4) = { 15.0000 3.3737 3.6903 3.6903 3.3737 }, permutations and the amplitudes of the DFT coefficients are presented in Section 3. In Section 4, we characterize the per- We ¡say ¢that the sets A x(3) and A x(4) are equivalent because mutations that commute with the DFT. Examples are presented they have the same elements even though the ordering of these in Section 5. Generalizations for the one-dimensional case are elements is different. We¡ refer¢ to ¡the sets¢ A x(i) as the sets of given in Section 6. In Section 7, we present our results on higher the (unordered) magnitudes of the DFT coefficients. dimensional data arrays. Section 8 contains the conclusions. The objective of this paper to characterize¡ the¢ transforma- tions that leave the unordered collection of Fourier coefficients and their magnitudes invariant. 2. Mathematical preliminaries 2.2. Permutations. We first define some basic notation and In this section, we introduce the background material needed review certain fundamental notions from abstract algebra. Let N, for further analysis. We give the necessary notation and, for Z, R, C denote the natural numbers (positive integers), the inte- the convenience of the reader, a few basic concepts to motivate gers, the real numbers, and the complex numbers, respectively. the development. We refer the reader to [1, 12, 19, 26, 27] for Let N N be fixed. For a, b Z, we say that a is con- 2 2 complete details. gruent to b modulo N if N divides a b and denote this by ¡ a = b mod N. Note that by simple arithmetic, we have that for 2.1. Motivation. The discrete Fourier transform (DFT) trans- every integer a Z, there is a unique integer b {0, …, N 1} 2 2 ¡ forms a sequence of N complex numbers, x(0), x(1), …, such that a = b mod N. For each N N, let ZN denote the col- 2 x(N 1) into another sequence of complex numbers, x(0), x(1), lection of integers {0, …, N 1}. Let m, n ZN. Then by the ¡ ¡ 2 …, x(N 1), where above, there are unique elements u, v ZN such that ¡ b b 2 b N 1 ¡ –2π j kn m + n = u mod N and mn = v mod N. x(n) = ∑ x(k)e N (1) k = 0 b We follow the convention (and an abuse of notation) of using We will use [x] to denote the column vector of the values of m + n and mn to denote u and v in ZN, respectively. Thus x(k), and, [x] is the column vector of the values of x(k). Let defined, ZN has an addition operation and a multiplication oper- ation, which is commonly referred to as modular arithmetic. b b x(1) = 1 2 3 4 5 >. The usual properties of arithmetic on Z carry over to modular arithmetic on ZN with two key exceptions: Applying (1) and then computing the magnitudes of the coef- 1. If N is not a prime number, then there are nonzero elements (1) ficients of the DFT of x , we obtain the set of the DFT m, n of ZN whose product is zero in ZN, which is equivalent coefficient magnitudes to the fact that mn is an integer multiple of N. 2. If p ZN is relatively prime to N, then it has a multiplica- (1) 2 A x = 15.0000 4.2533 2.6287 2.6287 4.2533 . tive inverse in ZN in the sense that for some q ZN, we { } 2 have pq = 1 in ZN. This follows from the fact the since p is One¡ can¢ easily check that the magnitudes of the coefficients relatively prime to N, then there are integers q, 0 < q < N, of the DFT of and s such that pq + sN = 1 (see [26]). It follows that if p ZN is relatively prime to N, then it has (2) > 2 x = 5 4 3 2 1 , a multiplicative inverse in ZN and the inverse is q as given above.

996 Bull. Pol. Ac.: Tech. 67(6) 2019 Discrete Fourier transform and permutations

The set of integers in ZN relatively prime to N is denoted ZN¤ . k = k(qp) = (kq)p mod N. It is easy to see that if m, n ZN¤ , then mn ZN¤ . 2 2 A group (G, ) is a nonempty set G along with a binary It follows that µ p(kq) = k and since k ZN is arbitrary, we con- ¢ 2 operation with the following properties: clude that µ p in onto. Since every onto function from a finite set 1. If a, b¢ G, then a b G. to itself is one-to-one, we conclude that µ is a bijection. Hence 2 ¢ 2 p 2. If a, b, c G, then (a b) c = a (b c). µ p is a permutation of ZN when p is in ZN¤ , which completes 2 3. There is a unique element¢ ¢e G such¢ ¢ that for every a G, the proof of the first part. 2 2 a e = e a = a. The element e is called the identity of the To see the second part, note that by definition, we have ¢ ¢ group G. µ q(k) = qk. We have shown above that µ p(qk) = k. Therefore –1 –1 4. For each element a G, there is an element a G such µp = µq = µp–1. □ 2 2 that a a–1 = e. The element a–1 is called the inverse of a. ¢ If we have in addition to the above that a b = b a for all An automorphism on the group ZN is a permutation ξ SN ¢ ¢ 2 a, b G, then (G, ) is called an abelian group. As an example, such that ξ(m + n) = ξ(m) + ξ(n) for all m, n ZN. We let 2 ¢ 2 we note that (ZN, +) is an abelian group. If the operation on Aut(ZN) denote the collection of all automorphisms on (ZN, +). ¢ a set G is clearly specified, it is common practice to use G to Then by definition Aut(ZN) SN and is a subgroup of SN: ½ denote the group (G, ). A subset F G forms a subgroup of ¢ ½ the group G if F along with the operation is itself a group. Lemma 3. (Aut(ZN), ) is a group and it is the collection of ¢ ± The following well known result is useful for showing that the functions µ p with p in ZN¤ . a subset is a subgroup: Proof. See [1]. □ Lemma 1. A subset F of a group G is a subgroup if and only if the following conditions hold: For each r ZN, let 2 1. If a, b F, then a b F. 2 2 2. For all a F, a–1 ¢ F. α (k) = k + r mod N. 2 2 r

Proof. See page 32 of [12]. □ Then αr is a permutation on ZN and the collection

If F is a subgroup of G and a G, then the subset T = αr : r ZN 2 { 2 } a F = a f : f F is a subgroup of S . To see that T is a subgroup of S , we note { 2 } N N ¢ ¢ that α α = α T and α –1 = α T and apply Lemma 1. r ± s r + s 2 r – r 2 is called a left coset of G and We refer to T as the group of translations. It follows that for p ZN¤ and r ZN, the function σ p, r defined by 2 2 F a = { f a : f F} ¢ ¢ 2 σ p, r(k) = αr µ p(k) = pk + r in ZN ± is called a right coset of G. A subgroup F of G is said to be normal if a F = F a for all a G. is a permutation. ¢ ¢ 2 A permutation on ZN is a bijection (or equivalently, one-to- Let one and onto) function from ZN to ZN. Let SN denote the collec- tion of all permutations on ZN. We use to denote composition H = σ : p ¤ and r . (2) ± { p, r ZN ZN } on S . That is, if ρ, ξ S , then (ρ ξ)(n) = ρ(ξ(n)) for each 2 2 N 2 N ± n ZN. It follows that if ρ, ξ SN, then (ρ ξ) SN and thus A simple computation shows that 2 2 ± 2 defines a binary operation on S . It can be shown that (S , ) ± N N ± is a group, called the permutation group of ZN. We note that it σ p , r σ p , r = σ p p , p r + r H 1 1 ± 2 2 1 2 1 2 1 2 is not an abelian group in general. The identity element of this group is the identity map from ZN to ZN and the inverse of an and –1 element ρ of SN is the inverse function ρ . –1 Let p ZN¤ . We define a function µp : ZN ZN by σ p, r = σ p –1, –p –1r H. 2 ! 2

µ p(k) = pk mod N. Thus it follows from Lemma 1 that H is a subgroup of the group SN. The elements of H are often called affine permuta- We have the following. tions. Note that H = T Aut(ZN) is a product of the group of ± translations and the automorphism group of ZN. –1 Lemma 2. We have µ S and µ = µ –1. p 2 N p p 2.3. Discrete Fourier transform (DFT). In this subsection, we Proof. Let p ZN¤ and let q be its multiplicative inverse in ZN. introduce the notation and definitions related to the DFT that we 2 Then for each k ZN, use in the paper. Introductions to the DFT can be found in many 2

Bull. Pol. Ac.: Tech. 67(6) 2019 997 S. Hui and S.H. Żak

–1 books, including [3, 18, 24]. The book [24] contains a nice dis- x \ µp = x µ . ± ± p cussion of DFT on ZN and other abelian groups. The relation of b the DFT and circulant matrices can be found in [6, 9]. Furthermore, if p2 = 1 mod N, then For x : ZN C, the DFT of x is defined by ! x \ µp = x µ . ± ± p –2π j kn x(n) = x(k)e N . (3) b –1 ∑ Proof. Let x : ZN C and let σ p, r H. Let q = p in ZN. k ZN ! 2 2 Then for m, n ZN, we have (mp)(qn) = mn in ZN. It follows b 2 Let that

mn –2π j ( ) = ( ) : N F x {x n n ZN} x \ σ p, r(n) = x(mp + r)e 2 ± ∑ m ZN b 2 denote the collection of (unordered) DFT coefficients of x and rqn (mp + r)qn 2π j –2π j N N x \ σ p, r(n) = e x(mp + r)e ± ∑ A(x) = { x(n) : n ZN} m ZN j j 2 2 rqn kqn 2π j –2π j b N N denote the (unordered) collection of their magnitudes. x \ σ p, r(n) = e x(k)e ± ∑ k ZN Recall that the DFT matrix W is defined by 2 rqn mn 2π j –2π j N W = N x \ σ p, r(n) = e x(qn) n, m e ± rp–1n 2π j N b x \ σ p, r(n) = e x µ –1(n) for 0 m, n N 1 and gives x = W x , where x and x ̂ ± ± p ∙ ∙ ¡ rn are the column vectors of the values of x(k) and x(k), respec- 2π j £b¤ £ ¤ £ ¤ £ ¤ pN –1b tively. x \ σ p, r(n) = e x µ p (n). b ± ± A is a such that each row, b other than the first row, is a cyclic right shift of the previous In the above manipulations, we used the substitution k = mp + r row. It is well known (see for example [9]) that a matrix C is and the fact that pZN + r = ZN in ZN. □ circulant if and only if The following corollary is now immediate. C = W DW ¤, (4) Corollary 1. Let φ S be an arbitrary permutation. Then for 2 N where W ¤ denotes the conjugate transpose of W, and D is each permutation σ in the coset φ H, there exist complex ± a . In other words, the DFT diagonalizes all numbers ξ0, …, ξN 1 of absolute value 1 and q ZN¤ such that ¡ 2 circulant matrices. Furthermore, the first row of C is precisely for n ZN, 2 the DFT of the function formed by the diagonal elements of D. For a vector (or any ordered finite sequence of numbers) x \ σ (n) = ξ x \ φ µ (n). ± n ± ± q v, we use C(v) and D(v) to denote, respectively, the circulant matrix and the diagonal matrix obtained by using the entries In particular, A(x σ ) is independent of the choice of σ in the ± of v as the first row and the diagonal, respectively. With this coset. notation, equation (4) gives Proof. Let φ S be and let σ φ H. Then there is σ H 2 N 2 ± p, r 2 C(x) = WD(x)W ¤ such that σ φ σ . By Lemma 4, 2 ± p, r rn b 2π j pN \ –1 x \ σ (n) = e x φ µ p (n) 3. Permutations and magnitudes ± ± ± x \ σ (n) = ξ x \ φ µ (n). of the DFT coefficients ± n ± ± q rn 2π j pN –1 In this section, we present our results on permutations and the where ξn = e and q = p in ZN. □ magnitudes of the DFT coefficients. The following technical result is fundamental to the proofs of our other results. The next result characterizes the permutations that leave invariant the magnitudes of the DFT coefficients. Lemma 4. Let x : ZN C and let σ p, r H. Then for n ZN, ! 2 2 Theorem 1. Let σ be a permutation of ZN. Then A(x σ ) = A(x) π rn π rn 2 j pN 2 j pN –1 ± x \ σ p, r(n) = e x σ –1, 0(n) = e x µ (n), for all x : ZN C if and only if σ H. ± ± p ± p ! 2 –1 b b where p denotes the multiplicative inverse of p in ZN. In Proof. By letting φ be the identity in Corollary 1, we see that particular, if r = 0, then if σ H, then A(x σ ) = A(x) for all x : ZN C. 2 ± !

998 Bull. Pol. Ac.: Tech. 67(6) 2019 Discrete Fourier transform and permutations

Conversely, suppose A(x σ ) = A(x) for all x : ZN C. Theorem 2. Let σ 1 and σ 2 be permutations on ZN. Then ± ! We first consider the case of N = 2. The only possible rear- A(x σ 1) = A(x σ 2) for all x : ZN C if and only if σ 1 and ± ± ! rangements of a two element sequence x = {x(1), x(2)} are σ 2 are in the same left coset of H in SN . x = {x(1), x(2)} and y = {x(2), x(1)}. It is elementary that the DFT coefficients of the sequences x and y have the same mag- Proof. We have from Corollary 1 that if σ1 and σ 2 are in the same nitude. Thus A(x σ ) = A(x) holds for all σ in the group S . coset of H in S , then A(x σ ) = A(x σ ). To prove the con- ± 2 N ± 1 ± 2 Now observe that H = σ , σ = S . verse, we apply the assumption to the function x σ –1 to obtain { 1, 0 1, 1} 2 ± 1 We next consider the case when N 3. We first consider the A(x σ –1 σ ) = A(x). Then by Theorem 1, σ –1 σ H and ¸ ± 1 ± 2 1 ± 2 2 case when σ (0) = 0 and show that σ = µ for some p ZN¤ . it follows that both σ 1 and σ 2 are in σ 1 H. p 2 2 Let p = σ (1). Fix m ZN, m = = 0, 1. Define x : ZN C by 2 6 ! Remark 1. The above theorem fails for right cosets. See Sec- 2π jk/N e if k = 0, p, σ (m) tion 5 for an example. x(k) = 0 otherwise. Then it is clear that x(1) = 3. We have 4. Permutations that commute with the DFT

b kn –2π j x \ σ (n) = x σ (k)e N In this Section, we give conditions under which the collec- ± ∑ ± k ZN tion of DFT coefficients is invariant. Then we will use these 2 p n σ (m) mn to generalize a theorem (Theorem 1 in [5]) that characterizes 2π j –2π j 2π j –2π j x \ σ (n) = 1 + e N e N + e N e N permutation matrices that commute with the DFT matrix. Their ± p n σ (m) mn 2π j ¡ 2π j ¡ proofs use the following fact: x \ σ (n) = 1 + e N + e N . ± Lemma 5. Let σ1 and σ 2 be permutations on ZN. Then σ1 = σ 2 It follows that x \ σ (n) 3. Since A(x σ ) = A(x) by assump- if and only if y σ 1 = y σ 2 for all y : ZN C. ± ∙ ± ± ± ! tion and x(1) =j 3, we jmust have x \ σ (n) = 3 for some n, j ± j which is only possible if Proof. Clearly if σ1 = σ 2, then y σ1 = y σ 2 for all y : ZN b ± ± ! p n σ (m) mn C. Conversely, suppose y σ 1 = y σ 2 for all y : ZN 2π j ¡ 2π j ¡ N N ! ± ± ! e = 1 and e = 1 C. Fix m ZN. Define y be setting y(σ 1(m))) = 1 and y ! 2 equal to 0 at the other coordinates. If σ (m) = σ (m), then 2 6 1 simultaneously. The first equality gives n = p mod N and the y(σ 2(m))) = 0, which contradicts the assumption and so we second equality gives σ (m) = mn mod N. Therefore σ (m) = mp must have σ 2(m) = σ 1(m). □ mod N. Since m = 0, 1 is arbitrary, and σ (0) = 0 and σ (1) = p 6 by assumption, we conclude that σ (m) = mp for all m ZN¤ . Theorem 3. Let σ 1 and σ 2 be permutations on ZN. Then 2 Since σ is a permutation on ZN, we must have p ZN¤ because x \ σ 2 = x σ 1 for all x : ZN C if and only if σ 1 and σ 2 2 ± ± !–1 pZN = ZN otherwise. belong to Aut(ZN) and σ 1 = σ 2 . 6 b We next consider the general case. Suppose r = σ (0). Let –1 α(k) = k r in ZN. Then α is a permutation on ZN and thus Proof. Suppose σ1 and σ 2 belong to Aut(ZN) and σ 2 = σ1 . We ¡ –1 x α is a complex valued function on ZN. By assumption, have from Lemma 4 that if σ 2 Aut(ZN), then x \ σ 2 = x σ 2 ± 2 –1 ± ± A(x α σ) = A(x α). By Lemma 4, or by a simple compu- for all x : ZN C. Since σ 1 = σ 2 by assumption, we have ± ± ± ! b tation, we see that A(x α) = A(x). We have by definition that x σ = x \ σ . ± ± 1 ± 2 α σ (0) = r r = 0 and so the special case we proved above ± ¡ b applies to show that α σ = µ p for some p ZN in ZN¤ . It fol- Conversely, suppose x σ1 = x \ σ 2 for all x : ZN C. Then –1 ± 2 ± ± ! lows that σ (m) = α µ p(m) = mp + r for m ZN. The proof clearly A(x σ 2) = A(x) for all x : ZN C since x σ1 merely ± 2 ± b ! ± is complete. □ rearranges the values of x. Thus by Theorem 1, σ 2 = σp, r H. b 2 By the assumption and Lemma 4, b Note that each permutation σ can also be considered as π rn a sequence σ (0) σ (N 1) . Then the above theorem shows 2 j pN –1 ¢¢¢ ¡ x σ 1(n) = x \ σ p, r(n) = e x µ p (n). that for every σ H, ± ± ± £ 2 ¤ b b 2 3 A(σ) = A(σ ) = A(σ ) = , (5) By choosing x such that x(n) is real for all n ZN, we con- ¢¢¢ π rn 2 2 j pN clude that e = 1 for allb n ZN, which is only possible if where σ n denotes the permutation obtained by composing σ 2 r = 0 in ZN. Thus σ 2 = σp, 0 = µ p Aut(ZN) and by Lemma 5, with itself N times. However, the condition in equation (5) is 2 –1 in general not sufficient to guarantee that σ H. (See Conjec- σ 1 = µ . The proof is complete. □ 2 p ture 1 in Section 6.) The following theorem contains Theorem 1 as a special case (when σ 2 is the identity permutation) but its Corollary 2. Let σ be a permutation on ZN. Then F(x σ) = ± proof requires Theorem 1. = F(x) for all x : ZN C if and only σ Aut(ZN). ! 2

Bull. Pol. Ac.: Tech. 67(6) 2019 999 S. Hui and S.H. Żak Stefen Hui and Stanisław H. Zak˙

Proof. Note that F(x σ) = F(x) if and only if the set of DFT Example 1. In this example, we give an illustration of Corol- Table 1. The group H and its left cosets in S ± EXAMPLE 1. In this example, we give an illustration of 4 coefficients of x σ is a rearrangement of the DFT coefficients lary 2. Rather than giving sequences in C and their DFT, we ± Corollary 2. Rather than giving sequences in C and their DFT, of x, which is equivalent to the existence of a permutation α providewe provide a short a shortMatlab MATLAB script thatscript can that be used can by be the used interested by the Left Coset 1 = H Left Coset 2 Left Coset 3 such that x \ σ = x α. Then by Theorem 3, σ Aut(ZN). readerinterested to generate reader tonumerical generate examples. numerical The examples. script will The generate script 0123 1023 0312 ± ± 2 Conversely, if σ Aut(ZN), then by Lemma 4, F(x σ) = allwill possible generate rearrangements all possible rearrangements of the input sequence of the input by sequencethe auto- 1230 0231 3120 b 2 ± = F(x). □ morphismby the automorphism group Aut(Z groupN) as Aut(columnsZN) asof columnsa matrix. ofIn aaddition, matrix. 2301 2310 1203 weIn addition,give one werandom give onepermutation random permutationof the input ofsequence the input as se-the 3012 3102 2031 We now show that our results generalize the theorem in [5] lastquence column as the to lastillustrate column the to failure illustrate of thethe failureconclusion of the when conclu- the 0321 1320 0213 1032 0132 3021 that characterizes the permutation matrices that commute with permutationsion when the is permutationnot given by isAut not(Z givenN). To by keep Aut( theZN ).script To keepsim- the DFT matrix. We first introduce the required notation. Let ple,the scriptwe do simple,not check we that do the not randomly check that generated the randomly permutation gener- 2103 2013 1302 σ 3210 3201 2130 σ be a permutation on ZN. The P corre- isated not permutation in the Aut(Z isN) not. However, in the Aut( the ZprobabilityN). However, that thea random proba-- sponding to σ is defined entry-wise by lybility generated that a randomlypermutation generated is in Aut permutation(ZN) is at most is in 1 Aut(/(N 1)) is!. Z¡N Theat most script 1/ (usesN 1a )random!. The script complex-valued uses a random (column) complex-valued sequence σ − Table 2. The group H and its right cosets in S4 σ 1 if n = (m) of(column) length 8 sequence as input, of which length can 8 as be input, changed which to canan arbitrary be changed se- Pm, n = quence.to an arbitrary sequence. 0 otherwise, Right Coset 1 = H Right Coset 2 Right Coset 3 where 0 m, n N 1. It is clear from the definition of Pσ % Input sequence 0123 1023 0231 ∙ ∙ ¡ 1230 2130 1302 that x=randn ([8 1])+ j randn([8 1]); ∗ 2301 3201 2013 x σ = Pσ x . % Length of the sequence ± N=length (x); 3012 0312 3120 £ ¤ £ ¤ 0321 3021 0213 In matrix notation, we have y=[]; % Initialize the matrix of % rearrangements of x 1032 0132 1320 σ σ 2103 1203 2031 x σ = P W x and x \ σ = WP x . (6) % Generate all rearrangements ± ± % of x given by the automorphism group 3210 2310 3102 £ ¤ £ ¤ σ σ £ ¤ Observeb that by equation (6), P 1W = WP 2 is equivalent to for k=1:N if gcd (k ,N)==1 x σ 1 = x \ σ 2 for all x : ZN C. Thus Theorem 3 can be ond and the third columns of Table 1 are the cosets [1023] H ± ± ! y=[y x(mod(k [0:N 1],N)+1)]; ◦ restated as ∗ − and [0312] H, respectively. b end ◦ As an illustration, we compute the DFT of the function x on end Theorem 4. Let σ 1 and σ 2 be permutations on ZN. Then Z4 defined by x(k)=k + 1, or informally, x =[1,2,3,4]. Note σ1 σ 2 % P W = WP if and only if σ 1 and σ 2 belong to Aut(ZN) that x(3)=4. We obtain for each σ H that (to two decimal –1 % Append one random rearrangement of x ∈ and σ 1 = σ 2 . places) y=[y x( randperm (N))]; Theorem 4 generalizes the following theorem proved in [5] A(x σ)= 10.00,2.83,2.00,2.83 . that characterizes the permutation matrices that commute with Input_and_rearrang=y ◦ { } the DFT matrix. % Compute DFT For each σ in Left Coset 2, DFT_of_Rearrang= fft ( Input_and_rearrang ) A(x σ)= 10.00,3.16,0.00,3.16 , % Sort magnitudes ◦ { } Theorem 5. (Chao) Let σ be a non-identity permutation on ZN. Then Pσ W = WPσ if and only if σ belongs to the automor- Sorted_mags=sort ( abs ( DFT_of_Rearrang )) and for each σ in Left Coset 3, phism group, Aut(ZN), of the additive group of the integers A(x σ)= 10.00,1.41,4.00,1.41 . ◦ { } module N, and σ is of order two. ExampleEXAMPLE 2. In2. this In example, this example, we illustrate we illustrate Theorem Theorem 1. We use 1. This example illustrates the fact that each permutation in a left To see that Theorem 3 implies Theorem 5, suppose ZWe4 = use {0,Z 1,4 =2, 3}0, to1, keep2,3 theto keeplength the manageable. length manageable. The elements The 1 σ σ 2 σ –1 σ { } * coset gives the same DFT coefficient magnitudes and that the Aut(ZN) and is the identity. Then = and we can andelements 3 are relatively 1 and 3 areprime relatively to 4 and primeso Z4 = to { 40, and3}. It so followsZ4∗ = 2 σ σ DFT coefficient magnitudes are different for different cosets in apply Theorem 4 to conclude that P W = WP . Conversely, if that1,3 the. Itsubgroup follows thatH = the {σ subgroup1, 0, …, σ 1, 3H }= {σσ1,3, 00,...,, …, σ1σ,33, 3} σ σ –1 { } [{ }∪ general. P W = WP , then Theorem 4 gives σ Aut(ZN) and σ = σ, hasσ3 ,eight0,..., elements.σ3,3 has eightSince elements.the S4 has Since 24 elements the S4 has and 24 H ele-has 22 { } Note that σ =[1023] and σ =[0312] are both in Right which is equivalent to the fact that σ is the identity. eightments elements, and H has H eight has three elements, cosets,H hasone three of which cosets, being one ofH σ –1 σ –1 Coset 2 but σ =[1023] is in Left Coset 2 while σ =[0312] Since P = P , we have the following corollary of itselfwhich (see being [12,H pageitself 39]). (see [12,We pagegenerate 39]). the We left generate and right the is in Left Coset 3. Since the permutations in Left Coset 2 and Theorem 4: cosetsleft and of right H by cosets a simple of H computation,by a simple which computation, are shown which in £ ¤ Left Coset 3 give different DFT magnitudes as we have seen, Tableare shown 1 and in Table Table 2, 1 respectively. and Table 2, respectively.The elements The correspond elements- σ σ we conclude that permutations in the right cosets of H do not Corollary 3. For every σ Aut(ZN), P W P = W. Also, if ingcorresponding to {σ 1, 0, …, to σσ1, 31,}0,..., and σ{1σ,33, 0and, …, σ33, 3,0,...,} areσ separated3,3 are sep- by 2 { } { } necessarily give the same DFT magnitudes and this is an illus- P, Q are permutation matrices, then PW Q = W if and only if horizontalarated by horizontallines in the lines tables. in the The tables. permutations The permutations are listed are in tration that Theorem 2 fails for right cosets of H. P Aut(ZN) and Q = P. thelisted form in theσ ( form0)σ ([1σ)(σ0()2σ)(σ1()3σ)(2. )Forσ( 3example,)]. For example, the 4-number the 4- 2 σ ( ) = σ ( ) = groupnumber 0 2 3 1 group£ stands[0231 ]forstands the permutation for¤ the permutation 0 0,σ (01)= 2,0, σ ( ) = σ ( ) = 6. Generalizations σ(21)= £ 3,2, σ(3¤2)= 1.3, Byσ( 3inspection,)=1. By one inspection, can see onethat canthe seeleft 5. Examples and discussion cosetsthat the and left the cosets right and cosets the rightare distinct. cosets are(This distinct. implies (This that im-the In this section, we discuss the possibility of generalizing the groupplies thatH is the not group normal.)H is notThe normal.) two permutations The two permutations in small boxes in results of Section 3. More specifically, it would be useful to In this Section, we give examples to illustrate our results and insmall the boxesfirst column in the first of columnTable 1 ofform Table Aut 1( formZN). Aut(The ZpermutaN). The- know how x and y are related if x = y or A(x)=A(y). Is | | | | to show that Theorem 2 fails for right cosets of H. We discuss tionspermutations listed under listed each under of eachthese ofpermutations these permutations are the transla are the- there a subclass of functions on ZN such that x = y or A(x)= | | | | possible generalizations of the results in Section 6. tionstranslations of the permutations of the permutations in the small in the boxes. small boxes.The second The sec-and A(y) implies that x and y are permutations of each other? This 6 Bull. Pol. Ac.: Tech. XX(Y) 2016 1000 Bull. Pol. Ac.: Tech. 67(6) 2019 Discrete Fourier transform and permutations

Table 1 6. Generalizations The group H and its left cosets in S4 In this section, we discuss the possibility of generalizing the Left Coset 1 = H Left Coset 2 Left Coset 3 results of Section 3. More specifically, it would be useful 0 1 2 3 1 0 2 3 0 3 1 2 to know how x and y are related if x = y or A(x) = A(y). 1 2 3 0 0 2 3 1 3 1 2 0 j j j j Is there a subclass of functions on ZN such that x = y or b b j j j j 2 3 0 1 2 3 1 0 1 2 0 3 A(x) = A( y) implies that x and y are permutations of each b b 3 0 1 2 3 1 0 2 2 0 3 1 other? This has important implications if speech signals are 0 3 2 1 1 3 2 0 0 2 1 3 encrypted by transforming the signal with a unitary circulant 1 0 3 2 0 1 3 2 3 0 2 1 matrix. We have the following very general result: 2 1 0 3 2 0 1 3 1 3 0 2 Theorem 6. Let x, y : ZN C. Then x = y if and only if 3 2 1 0 3 2 0 1 2 1 3 0 ! j j j j there is a unitary circulant matrix Uc such that y = Uc x . b b £ ¤ £ ¤ Table 2 Proof. Suppose y = Uc x , where Uc is unitary and circulant. The group H and its right cosets in S = Λ 4 Then by equation£ ¤(4), U£c can¤ be expressed as Uc W W ¤, where Λ is a diagonal matrix with unimodular entries on the Right Coset 1 = H Right Coset 2 Right Coset 3 diagonal. Then y = Λ x and so x = y . j j j j 0 1 2 3 1 0 2 3 0 2 3 1 Now suppose x = y . Then y = Λ x , where Λ is a diag- £ bj¤ j j£ bj¤ b b 1 2 3 0 2 1 3 0 1 3 0 2 onal matrix with unimodular entries on the diagonal. It then b b £ b¤ £ b¤ 2 3 0 1 3 2 0 1 2 0 1 3 follows that y = (WΛW ¤) x . It is clear that WΛW ¤ is unitary and circulant. 3 0 1 2 0 3 1 2 3 1 2 0 £ ¤ £ ¤ □ 0 3 2 1 3 0 2 1 0 2 1 3 1 0 3 2 0 1 3 2 1 3 2 0 We see that transforming a signal with a unitary circulant matrix changes the phase but not the magnitude of the DFT 2 1 0 3 1 2 0 3 2 0 3 1 coefficients. Thus if additional information about the original 3 2 1 0 2 3 1 0 3 1 0 2 signal can be obtained from the encrypted signal by knowing the magnitudes of the DFT coefficients, the integrity of the encryption may be compromised. Since there are uncountably the third columns of Table 1 are the cosets 1 0 2 3 H and many unitary circulant transformations, Theorem 6 is of limited ± 0 3 1 2 H, respectively. use because without further assumptions the most one can say ± £ ¤ As an illustration, we compute the DFT of the function x is that when x = y , then y = U x , where U is unitary £ ¤ j j j j c c on Z4 defined by x(k) = k + 1, or informally, x = 1, 2, 3, 4 . and circulant (see Example 3). On the other hand, we have the b b £ ¤ £ ¤ Note that x(3) = 4. We obtain for each σ H that (to two dec- following very specialized result, which states that a nonnega- 2 £ ¤ imal places) tive sequence cannot have a flat amplitude spectrum unless it is a translation of a simple pulse. This hints at the possibility that A(x σ ) = {10.00, 2.83, 2.00, 2.83}. if the original comes from a known special class of functions, ± one may be able to say more. For each σ in Left Coset 2, For each n ZN, define en on ZN by setting en(n) = 1 and 2 en(m) = 0 for all other m ZN. 2 A(x σ ) = {10.00, 3.16, 0.00, 3.16}, ± Theorem 7. Let x : ZN C be nonnegative and let a 0. ! ¸ and for each σ in Left Coset 3, Then x(n) = a for all n ZN if and only if x = aen for some j j 2 n ZN. 2 b A(x σ ) = {10.00, 1.41, 4.00, 1.41}. ± Proof. Let x : ZN C be nonnegative and x(n) = a for all ! j j This example illustrates the fact that each permutation in a left n ZN. Without loss of generality, let a = 1. Then x = e 0 . 2 b j j j j coset gives the same DFT coefficient magnitudes and that the By Theorem 6, there is a unitary circulant matrix Uc such that b b DFT coefficient magnitudes are different for different cosets x = Uc e0 . Thus the first column of Uc is nonnegative. Since in general. £Uc¤ is circulant,£ ¤ all entries of Uc are nonnegative. Since Uc is Note that σ = 1 0 2 3 and σ = 0 3 1 2 are both in Right also unitary, the dot products of the distinct columns of Uc σ = σ = ( ) ( ) Coset 2 but 1 0 2 3£ is¤ in Left Coset£ 2 while¤ 0 3 1 2 are 0 and contain all possible combinations of x m x n for is in Left Coset 3. Since the permutations in Left Coset 2 and m = n. It follows that x(m)x(n) = 0 for m = n. Since x is non- £ ¤ £ ¤ 6 6 Left Coset 3 give different DFT magnitudes as we have seen, zero, there is at least one x(n) = 0, which implies that x(m) = 0 6 b we conclude that permutations in the right cosets of H do not for all m = n. Because x(n) 0 and x(m) = 1 for all m by 6 ¸ j j necessarily give the same DFT magnitudes and this is an illus- assumption, we must have x(n) = 1 and it follows that x = en. b tration that Theorem 2 fails for right cosets of H. The converse is obvious. □

Bull. Pol. Ac.: Tech. 67(6) 2019 1001 S. Hui and S.H. Żak

Remark 2. Note that Theorem 7 fails if x is not non-negative. Conjecture 2. Let x, y : ZN 0, 1 . Then ! { } It is easy to verify that 1. x = y if and only if there is σ T such that y = x σ; j j j j 2 ± 2. A(x) = A( y) if and only if there is σ p, r H such that b b 2 –1 –1 y = x σ . ± p, r 1 –1 –1 x = x = . 2 –1 , –1 £ ¤ £ b¤ 7. Permutations and magnitudes of the DFT –1 –1 coefficients in higher dimensions

The following result is contained in the proof of Theorem 7 Some of the results we obtained so far carry over to higher but is also a simple consequence of it. dimensional input data, that is, data arrays. To present the main ideas without the more complicated notation for the higher Corollary 4. A is unitary and circulant if and dimensions, we only state and prove the results on the mag- only if it is a permutation matrix corresponding to a translation. nitudes of a 2-dimensional DFT coefficients when the entries of a 2-dimensional data array are permuted. The same results Proof. Clearly, a permutation matrix that corresponds to a trans- hold for higher dimensions with similar proofs. The results lation is nonnegative, unitary, and circulant. For the converse, we have are not as complete as the one dimensional case but we only have to note the first column of a matrix U is given they are useful in image pattern classification problems. For by U e0 . If U is a nonnegative unitary circulant matrix, then example, we show later in this section that our results contain by Theorem 7, its first column is en for some n ZN. □ as special cases that the set of magnitudes of a 2-dimensional £ ¤ 2 £ ¤ DFT coefficients of an image are invariant when the image is The following example shows that there is no straightfor- reflected, rotated, or cyclically shifted. (a) Original Image (b) Flip ward generalization of Theorem 7 to the case of non-negative x, y such that x = y . Example 4. In Fig. 1 we show a sample image and the images j j j j transformed by a combination of the transformations cov- b b Example 3. Let ered under our results. The original color image contains 300 200 pixels, which we consider as a 300 200 3 data £ £ £ –1 –1 –1 –1 1 array. The transformed image is obtained by applying in –1 –1 –1 –1 1 sequence the following operations: 1 (e) Transpose Uc = and x = . 1. flip the image upside down; 2 –1 –1 –1 –1 0 £ ¤ 2. shift the image up cyclically by 110 pixels; –1 –1 –1 –1 (a) Original1 Image (b) Flip a) Original Image b) Flip (c)c) ShiftShift Up (d) Shift Left Then Uc is unitary and circulant and (a) Original(a) Original Image Image (b) Flip(b) Flip

1 (a) Original Image (b) Flip 1 y = Uc x = . 3 £ ¤ £ ¤ 1 (e) Transpose Thus x = y by Theorem 6 but obviously x and y are not (e) Transpose(e) Transpose j j j j related by a permutation or any simple geometric transforma- b b tion of the coordinates. One can also easily verify that (c) Shift Up (d)d) ShiftShift Left (e)e) TransposeTranspose –3 –3 (c) Shift(c) Up Shift Up (d) Shift(d) Left Shift Left –1 –1 x = and y = . –1 –1 (c) Shift Up (d) Shift Left £ b¤ £ b¤ –1 –1

Based on some experimentation results, we conjecture the following:

Conjecture 1. If N is prime, then σ H if and only if 2 Fig. 1. Illustration of image transformations of Example 4. Each of five images has different DFT but the same set of the DFT coefficient A σ = A σ 2 = A σ 3 = . magnitudes ¢¢¢ ¡ ¢ ¡ ¢ ¡ ¢ 1002 Bull. Pol. Ac.: Tech. 67(6) 2019 Stefen Hui and Stanisław H. Zak˙

hold for higher dimensions with similar proofs. The results Proof. We have

we have are not as complete as the one dimensional case but M 1 N 1 they are useful in image pattern classification problems. For − − 2π j (am/M+bn/N) xη1(a,b)= ∑ ∑ (x η1)(m,n)e− example, we show later in this section that our results contain ◦ m=0 n=0 ◦ as special cases that the set of magnitudes of a 2-dimensional M 1 N 1 − − 2π j (am/M+bn/N) DFT coefficients of an image are invariant when the image is = x(M m,n)e− ∑ ∑ − reflected, rotated, or cyclically shifted. m=0 n=0 1 N 1 − 2π j (a(M k)/M+bn/N) = x(k,n)e− − EXAMPLE 4. In Figure 1 we show a sample image and the ∑ ∑ k=M n=0 images transformed by a combination of the transformations M 1 N 1 covered under our results. The original color image contains − − 2π j (a( k)/M+bn/N) = ∑ ∑ x(k,n)e− − 300 200 pixels, which we consider as a 300 200 3 data k=0 n=0 × × × array. The transformed image is obtained by applying in se- = x( a,b) quence the following operations: Discrete Fourier transform and permutations − =(x η1)(a,b). ◦ 1. flip the image upside down 3. shift the image left by 63 pixels; Lemma 7. Let η2(m, n) = (m, N n) for m ZM and n ZN. 2. shift the image up cyclically by 110 pixels ¡ 2 2 4. transpose the image. Then for each x : ZM ZN C, 3. shift the image left by 63 pixels Analogously, we have£ ! 4. transposeWe note that the imageeach of five images has the same set of the EMMA DFT coefficient magnitudes. □ L 7. Let η2(mx \ ,n η)=(2 = mx ,N η2. n) for m ZM and n ± ± − ∈ ∈ ZN. Then for each x : ZM ZN C, We note that each of five images has the same set of the DFT × →b Let a 2-dimensional input data array be represented by In particular, A(x η2) = A(x). Note that N n is the additive coefficient magnitudes. ± xη2 = x η2. ¡ a complex-valued M N matrix x. We consider the matrix x as inverse of N in ZN. ◦ ◦ £ a function x : ZM ZN C, where x(m, n) is the entry located In particular, A(x η2)=A(x). Note that N n is the additive £ ! ◦ − in row m + 1 and column n + 1. The 2-dimensional DFT (2d- Lemmainverse of8. nLetin ZθN1(.m, n) = (m + 1, n) for m ZM and n ZN. Let a 2-dimensional input data array be represented by a 2 2 DFT) of x is defined by Then for each x : ZM ZN C, complex-valued M N matrix x. We consider the matrix x LEMMA 8. Let θ 1£(m,n!)=(m + 1,n) for m ZM and n × ∈ ∈ as a function x :MZ M 1 N Z 1 N C, where x(m,n) is the entry lo- ZN. Then for each x : ZM ZN 2π jaC/M, ¡ ס → –2π j(am/M + bn/N) x \ θ 1(a, b×) = e→ x(a, b). catedx in(a row, b) m= + 1 and columnx(m, nn)e+ 1. The 2-dimensional, DFT(7) ± ∑ ∑ xθ (a,b)=e2π ja/Mx(a,b). (2d-DFT) of x ism defined= 0 n = 0 by ◦ 1 b b In particular, A(x θ 1) = A(x). Note that M = 0 mod M and that In particular, A(x± θ )=A(x). Note that M = 0 mod M and where a ZM and bM 1 ZNN .1 Let SM, N denote the collection of x θ cyclically shifts◦ 1 the rows of x up by one row. 2 2− − 2π j (am/M+bn/N) that± x θ cyclically shifts the rows of x up by one row. all bijectionsx(a,b)= ∑ ∑ x(m,n)e− , (7) ◦ m=0 n=0 Proof. We have Proof. We have ρ : ZM ZN ZM ZN . where a ZM and b Z£N. Let!SM,N£denote the collection of ∈ ∈ M 1 N 1 all bijections − − 2π j (am/M+bn/N) Note that S is a group when it is equipped with the com- xθ 1(a,b)= (x θ 1)(m,n)e− M, N ◦ ∑ ∑ ◦ position operator asρ in: ZtheM 1-dimensionalZN ZM Zcase.N. As before, let m=0 n=0 × → × M 1 N 1 − − 2π j (am/M+bn/N) Note that S is a group when it is equipped with the com- = x(m + 1,n)e− AM(x,N) = { x(a, b) : a ZM , b ZN } ∑ ∑ position operator as inj the 1-dimensionalj 2 case.2 As before, let m=0 n=0 b M N 1 − 2π j (a(k 1)/M+bn/N) denote the set of values of the DFT coefficient magnitudes = x(k,n)e− − A(x)= x(a,b) : a ZM,b ZN ∑ ∑ of x, that is, the amplitude{| |spectrum∈ of∈ x. We} show that k=1 n=0 A(x) = A(x γ ) for γ in a subgroup of SM, N . M 1 N 1 denote the± set of values of the DFT coefficient magnitudes of 2π ja/M − − 2π j (ak/M+bn/N) We use the following lemmas to introduce the permutations = e x(k,n)e− x, that is, the amplitude spectrum of x. We show that A(x)= ∑ ∑ that are used to generate the subgroup and prove the invariance k=0 n=0 A(x γ) for γ in a subgroup of S . of the◦ set of the 2d-DFT coefficientM,N magnitudes when an input = e2π ja/Mx(a,b). □ dataWe array use is the permuted following by lemmasone of these to introduce permutations. the permutations that are used to generate the subgroup and prove the invariance Analogously, we have. of the set of the 2d-DFT coefficient magnitudes when an input Lemma 6. Let η1(m, n) = (M m, n) for m ZM and n ZN. data array is permuted by one¡ of these permutations.2 2 Analogously, we have Then for each x : ZM ZN C, Lemma 9. Let θ 2(m, n) = (m, n + 1) for m ZM and n ZN. £ ! 2 2 ThenLEMMA for each9. x Let : ZθM2(mZ,Nn )=( C,m,n + 1) for m ZM and n LEMMA 6. Let η1(m,n)=(M m,n) for m ZM and n £ ! ∈ ∈ x \ η1 = x −η1. ∈ ∈ ZN. Then for each x : ZM ZN C, ZN. Then for each x : ZM± ZN ± C, × →2π jb/N × → x \ θ 2(a, b) = e x(a, b). b x± θ (a,b)=e2π jb/Nx(a,b). It follows that A(x η1) = A(x). Note that M m is the additive 2 ± xη1 = x η1. ¡ ◦ b inverse of m in Zm. ◦ ◦ It follows that A(x θ 2) = A(x). Note that N = 0 mod N and It follows that A(x ±θ 2)=A(x). Note that N = 0 mod N and Stefen Hui and Stanisław H. Zak˙ that x θ cyclically◦ shifts the columns of x to the left by one It follows that A(x η1)=A(x). Note that M m is the additive that x± θ22 cyclically shifts the columns of x to the left by one Proof. We have ◦ − column.◦ hold for higher dimensions with similar proofs. The results Proof.inverseWe of m havein Zm. column. we have are not as complete as the one dimensional case but M 1 N 1 We now define the subgroup of permutations that we use. Let 8 − − 2π j (am/M+bn/N) Bull. Pol. Ac.: Tech. XX(Y) 2016 they are useful in image pattern classification problems. For x η (a,b)= (x η )(m,n)e− 1 ∑ ∑ 1 ι be the identity function on ZM ZN. Let G = {ι, v1, v2, θ 1, θ 2} example, we show later in this section that our results contain ◦ m=0 n=0 ◦ £ and let Γ be the subgroup of SM, N generated by G. That is, Γ is as special cases that the set of magnitudes of a 2-dimensional M 1 N 1 − − 2π j (am/M+bn/N) the collection of all possible finite compositions of the func- DFT coefficients of an image are invariant when the image is = x(M m,n)e− ∑ ∑ − tions in Γ. The main result of this section now follows imme- reflected, rotated, or cyclically shifted. m=0 n=0 1 N 1 diately from the above lemmas. − 2π j (a(M k)/M+bn/N) = x(k,n)e− − EXAMPLE 4. In Figure 1 we show a sample image and the ∑ ∑ k=M n=0 Theorem 8. For all γ Γ, A(x γ ) = A(x). images transformed by a combination of the transformations M 1 N 1 2 ± covered under our results. The original color image contains − − 2π j (a( k)/M+bn/N) = ∑ ∑ x(k,n)e− − We next note that some common geometric operations on 2-d 300 200 pixels, which we consider as a 300 200 3 data k=0 n=0 × × × images can be considered as elements of the group Γ. For exam- array. The transformed image is obtained by applying in se- = x( a,b) ple, let an M N matrix x be the digitization of an image. Then quence the following operations: − £ =(x η )(a,b). 1. θ η = reflection of the image across the horizontal me- ◦ 1 □1 ± 1 dian; 1. flip the image upside down Analogously, we have. 2. θ η = reflection of the image across the vertical median; 2. shift the image up cyclically by 110 pixels 2 ± 2 3. shift the image left by 63 pixels Analogously, we have 4. transpose the image Bull.L EMMAPol. Ac.:7. Tech. Let 67(6)η ( m 2019,n)=(m,N n) for m ZM and n 1003 2 − ∈ ∈ ZN. Then for each x : ZM ZN C, We note that each of five images has the same set of the DFT × → coefficient magnitudes. xη = x η . ◦ 2 ◦ 2 In particular, A(x η2)=A(x). Note that N n is the additive ◦ − inverse of n in ZN. Let a 2-dimensional input data array be represented by a complex-valued M N matrix x. We consider the matrix x LEMMA 8. Let θ 1(m,n)=(m + 1,n) for m ZM and n × ∈ ∈ as a function x : ZM ZN C, where x(m,n) is the entry lo- ZN. Then for each x : ZM ZN C, × → × → cated in row m + 1 and column n + 1. The 2-dimensional DFT xθ (a,b)=e2π ja/Mx(a,b). (2d-DFT) of x is defined by ◦ 1 In particular, A(x θ )=A(x). Note that M = 0 mod M and M 1 N 1 ◦ 1 − − 2π j (am/M+bn/N) that x θ cyclically shifts the rows of x up by one row. x(a,b)= ∑ ∑ x(m,n)e− , (7) ◦ m=0 n=0 Proof. We have where a ZM and b ZN. Let SM,N denote the collection of ∈ ∈ M 1 N 1 all bijections − − 2π j (am/M+bn/N) xθ (a,b)= (x θ )(m,n)e− ◦ 1 ∑ ∑ ◦ 1 ρ : ZM ZN ZM ZN. m=0 n=0 × → × M 1 N 1 = − − ( + , ) 2π j (am/M+bn/N) Note that SM,N is a group when it is equipped with the com- ∑ ∑ x m 1 n e− position operator as in the 1-dimensional case. As before, let m=0 n=0 M N 1 − 2π j (a(k 1)/M+bn/N) = x(k,n)e− − A(x)= x(a,b) : a ZM,b ZN ∑ ∑ {| | ∈ ∈ } k=1 n=0 M 1 N 1 denote the set of values of the DFT coefficient magnitudes of 2π ja/M − − 2π j (ak/M+bn/N) = e ∑ ∑ x(k,n)e− x, that is, the amplitude spectrum of x. We show that A(x)= k=0 n=0 A(x γ) for γ in a subgroup of S . ◦ M,N = e2π ja/Mx(a,b). We use the following lemmas to introduce the permutations that are used to generate the subgroup and prove the invariance of the set of the 2d-DFT coefficient magnitudes when an input data array is permuted by one of these permutations. Analogously, we have

LEMMA 9. Let θ 2(m,n)=(m,n + 1) for m ZM and n LEMMA 6. Let η1(m,n)=(M m,n) for m ZM and n ∈ ∈ − ∈ ∈ ZN. Then for each x : ZM ZN C, ZN. Then for each x : ZM ZN C, × → × → 2π jb/N xθ 2(a,b)=e x(a,b). xη1 = x η1. ◦ ◦ ◦ It follows that A(x θ )=A(x). Note that N = 0 mod N and ◦ 2 It follows that A(x η )=A(x). Note that M m is the additive that x θ cyclically shifts the columns of x to the left by one ◦ 1 − ◦ 2 inverse of m in Zm. column.

8 Bull. Pol. Ac.: Tech. XX(Y) 2016 Stefen Hui and Stanisław H. Zak˙

We now define the subgroup of permutations that we Again, there are many more transformations of an image that use. Let ι be the identity function on ZM ZN. Let G = can be generated by the elements of Γ and τ. × ι,ν ,ν ,θ ,θ and let Γ be the subgroup of S generated Theorem 8 and Lemma 10 show that the set of the 2d-DFT { 1 2 1 2} M,N by G. That is, Γ is the collection of all possible finite composi- coefficient magnitudes of the 2d-DFT of a rectangular image tions of the functions in Γ. The main result of this section now is invariant under the operations in Γ and τ. This property follows immediately from the above lemmas. makes possible the use of the amplitudes of the 2d-DFT in the design of image recognition algorithms that are robust against THEOREM 8. For all γ Γ, A(x γ)=A(x). ∈ ◦ the operations in Γ and τ, including rotation, reflection, and We next note that some common geometric operations on many others. However, we cannot use the magnitude of the 2-d images can be considered as elements of the group Γ. For 2d-DFT directly as it is not invariant under the operations in Γ example, let an M N matrix x be the digitization of an image. and τ, only the unordered values are. × Then S. Hui and 8.S.H. Conclusions Żak 1. θ η = reflection of the image across the horizontal me- 1 ◦ 1 In this paper, we analyzed how rearrangements of a finite se- dian quence affect its DFT coefficients. In addition to its intrinsic 2.3.θ 2θ η η2 = reflectionθ η = ofθ the η image θ across η = rotation the vertical of the median image mathematical interest, this problem has applications in matrix ◦1 ± 1 ± 2 ± 2 2 ± 2 ± 1 ± 1 mathematical interest, this problem has applications in matrix 3. θby1 η180°.θ 2 η = θ 2 η θ 1 η = rotation of the image theory and signal processing. We completely characterized the ◦ 1 ◦ ◦ 2 ◦ 2 ◦ ◦ 1 theory and signal processing. We completely characterized the by 180 Of course,◦ many more transformations of an image can be gen- permutationspermutations thatthat leaveleave thethe collectioncollection of of the the DFT DFT coefficients coefficients erated using the group Γ. and their magnitudes invariant. We also gave a more general Of course, many more transformations of an image can be gen- and their magnitudes invariant. We also gave a more general Unless an image is represented by a square matrix, a 90° form of the theorem that gives conditions on a permutation erated using the group Γ. form of the theorem that gives conditions on a permutation un- rotation of the image will not be given by a permutation of under which it commutes with the DFT operation. We gave Unless an image is represented by a square matrix, a 90◦ der which it commutes with the DFT operation. We gave ex- ZM ZN . Instead, it will be a function from ZM ZN to ZN ZM . examples to illustrate the results obtained. For multidimensional rotation£ of the image will not be given by a£ permutation£ of amples to illustrate the results obtained. For multidimensional Let SM0 , N denote the collection of all bijections datadata arrays,arrays, wewe provedproved thatthat the the set set of of magnitudes magnitudes of of the the DFT DFT ZM ZN. Instead, it will be a function from ZM ZN to ZN × × × coefficientscoefficients are are invariant invariant under under a a subgroup subgroup of of the the permutation permutation ZM. Let SN ,M denote the collection of all bijections ρ 0 : ZN ZM ZM ZN . group that contains many of the usual geometric transforma- £ ! £ group that contains many of the usual geometric transforma- ρ : ZN ZM ZM ZN. tions.tions. We also discussed possiblepossible generalizationsgeneralizations and and open open × → × As in the case of SM, N, SM0 , N is a group when it is equipped with problems.problems. Asthe incomposition the case of operator.SM,N, SN ,NoteM is a that group if x when is an itM is equippedN matrix, with then £ thex ρ composition0 in an N M operator. matrix. Note that if x is an M N matrix, REFERENCES ± £ × then x ρ in an N M matrix. ◦ × References[1] W. A. Adkins and S. H. Weintraub, Algebra: An Approach via Lemma 10. Let τ 0(n, m) = (m, n) for m ZM and n ZN. Then Module Theory LEMMA 10. Let τ(n,m)=(m,n) for2m ZM and2 n ZN. [1] W.A. Adkins and, Springer-Verlag, S.H.Weintraub, New Algebra: York, An 1992. Approach via for each x : ZM ZN C, ∈ ∈ [2] C. Aitken, Two notes on matrices, Proceedings of the Glas- Then for each x£: ZM !ZN C, Module Theory, Springer-Verlag, New York, 1992. × → gow Mathematical Association, Vol. 5, Issue 03, pp. 109–113, [2] C. Aitken, Two notes on matrices, Proceedings of the Glasgow xx \ τ 0 == xx τ,0, January 1962. ±τ ±τ Mathematical Association 5(3), 109–113, January 1962. ◦ ◦ [3] E. Oran Brigham, The And Its Appli- that is, [3] E. Oran Brigham, The Fast Fourier Transform And Its Applica- that is, b cations, Prentice-Hall, New York, 1988. x \ τ 0(b, a) = ( x τ 0)(b, a) tions, Prentice-Hall, New York, 1988. [4] S. E. Borujeni, Speech encryption based on fast Fourier trans- x±τ(b,a)=(x ±τ)(b,a) [4] S. E. Borujeni, “Speech encryption based on fast Fourier trans- ◦ b◦ form permutation, Proceedings of the 7th IEEE International for a ZM and b ZN. Note that x τ 0 is the transpose of x and form permutation”, Proceedings of the 7th IEEE International for a 2ZM and b 2ZN. Note that x ±τ is the transpose of x and Conference on Electronics, Circuits and Systems, Vol. 1, thus the∈ 2d-DFT commutes∈ with transposition.◦ In particular, we Conference on Electronics, Circuits and Systems 1, 290–293, thus the 2d-DFT commutes with transposition. In particular, pp. 290–293, 2000. have A(x τ 0) = A(x). 2000. [5] C.-Y. Chao, On a type of circulants, Linear Algebra and its we have A±(x τ)=A(x). [5] C.-Y. Chao, “On a type of circulants”, Linear Algebra and its ◦ Applications, Vol. 6, pp 241–248, 1973. Applications 6, 241–248, 1973. Proof. Let a ZM and b ZN. Then we have [6] P. J. Davis, Circulant Matrices, Wiley, New York, 1979 Proof. Let a 2 ZM and b 2 ZN. Then we have [6] P. J. Davis, Circulant Matrices, Wiley, New York, 1979. ∈ ∈ [7] F. Farnoud (Hassanzadeh) and O. Milenkovic, Sorting of per- [7] F. Farnoud (Hassanzadeh) and O. Milenkovic, “Sorting of per- N 1 M 1 mutations by cost-constrained transpositions, IEEE Transac- − − 2π j (bn/N+am/M) mutations by cost-constrained transpositions”, IEEE Transac- xτ(b,a)= (x τ)(n,m)e− tions on Information Theory, Vol. 58, No. 1, pp. 3–23, January ◦ ∑ ∑ ◦ tions on Information Theory 58(1), 3–23, January 2012. n=0 m=0 2012. [8] P. Ferreira, “A group of permutations that commute with the N 1 M 1 [8] P. Ferreira, A group of permutations that commute with the − − 2π j (bn/N+am/M) discrete Fourier transform”, IEEE Transactions on Signal Pro- = ∑ ∑ x(m,n)e− discrete Fourier transform, IEEE Transactions on Signal Pro- cessing 42(2), 444–445, 1994. n=0 m=0 cessing, Vol. 42, No.2, pp. 444–445, 1994. [9] R.M. Gray, “Toeplitz and circulant matrices: A review”, Foun- = x(a,b) [9] R. M. Gray, Toeplitz and circulant matrices: A review, Foun- dations and Trends in Communications and Information Theory dations and Trends in Communications and Information The- =(x τ)(b,a) □2(3), 155–239, 2006. ◦ ory, Vol 2, Issue 3, pp. 155–239, 2006. [10] F. Horn and K.-R. Muller, “Predicting pairwise relations with neu- [10] F. Horn and K.-R. Muller, Predicting pairwise relations with ral similarity encoders”, Bull. Pol. Ac.: Tech. 66(6), 821–830, 2018. For example, we have neural similarity encoders, Bulletin Polish Academy of Sci- [11] S. Hui and S.H. Żak, “Discrete Fourier transform based pattern 1. τ 0 θ 1 η1 = rotation of the image 90° clockwise; ences, Technical Sciences, Vol 66, No. 6, pp. 821–830, 2018. For± example,± we have classifiers”, Bull. Pol. Ac.: Tech. 62(1), 15–22, 2014. 2. τ 0 θ η = rotation of the image 90° counterclockwise. [11] S. Hui and S. H. Zak,˙ Discrete Fourier transform based pat- ± 2 ± 2 [12] T.W. Hungerford, Algebra, Springer-Verlag, New York, 1974. 1. τAgain,θ 1 ηthere= rotation are many of themore image transformations 90◦ clockwise of an image tern classifiers, Bulletin Polish Academy of Sciences, Techni- ◦ ◦ 1 [13] J. Kurek, B. Swiderski, S. Osowski, M. Kruk, and W. Barhoumi, 2.thatτ canθ 2 beη generated= rotation byof the the elements image 90 of◦ Γcounterclockwise and τ 0. cal Sciences, Vol. 62, No. 1, pp. 15–22, 2014. ◦ ◦ 2 “Deep learning versus classical neural approach to mammogram Theorem 8 and Lemma 10 show that the set of the 2d-DFT recognition”, Bull. Pol. Ac.: Tech. 6(6), 831–840, 2018. 10coefficient magnitudes of the 2d-DFT of a rectangular image [14] J. Lang, “Color image encryptionBull. Pol.based Ac.: on Tech. color XX(Y) blend 2016 and is invariant under the operations in Γ and τ 0. This property chaos permutation in the reality-preserving multipleparameter makes possible the use of the amplitudes of the 2d-DFT in the fractional Fourier transform domain”, Optics Communications design of image recognition algorithms that are robust against 338, 181–192, 2015. the operations in Γ and τ 0, including rotation, reflection, and [15] S. Liu, Y. D. Zhang, and T. Shan, “Detection of weak astronom- many others. However, we cannot use the magnitude of the ical signals with frequency-hopping interference suppression”, 2d-DFT directly as it is not invariant under the operations in Γ Digital Signal Processing 72, 1–8, 2018. [16] G. Manjunath and G.V. Anand, “Speech encryption using cir- and τ 0, only the unordered values are. culant transformations”, Proceedings of the 2002 IEEE Inter- national Conference on Multimedia and Expo, ICME 2002, 1, 26–29, 2002. 8. Conclusions [17] A. Matsunaga, K. Koga, and M. Ohkawa, “An analog speech scrambling system using the FFT technique with high-level secu- In this paper, we analyzed how rearrangements of a finite rity”, IEEE Journal on Selected Areas in Communications 7(4), sequence affect its DFT coefficients. In addition to its intrinsic 540–547, 1989.

1004 Bull. Pol. Ac.: Tech. 67(6) 2019 Discrete Fourier transform and permutations

[18] A.V. Oppenheim and R.W. Schafer, Discrete-Time Signal Pro- [23] N.D. Sidiropoulos, M.S. Pattichis, A.C. Bovik, and J.W. Havlicek, cessing, Prentice-Hall, New York, 1989. “COPERM: Transform-domain energy compaction by optimal [19] D. Passman, Permutation Groups, Benjamin, New York, permutation”, IEEE Transactions on Signal Processing 47(6), 1968. 1679–1688, 1999. [20] S. Pawar and K. Ramchandran, “R-FFAST: A robust sub-linear [24] E.M. Stein and R. Shakarchi, Fourier Analysis, Princeton Uni- time algorithm for computing a sparse DFT”, IEEE Transactions versity Press, Princeton, 2003. on Information Theory 64(1), 451–466, January 2018. [25] R. Urbanke, Q. Li, and B. Rimoldi, “On the cardinality of the [21] S.-C. Pei, C.-C. Wen, and J.-J. Ding, “Closed-form orthogonal group of permutations that commute with the Discrete Fourier DFT eigenvectors generated by complete generalized Legendre Transform”, 32nd Allerton Conf. on Communication, Control, Sequence”, IEEE Transactions on Circuits and Systems— I: Reg- and Computing, Monticello, IL, Sept. 28‒30, 1994. ular Papers 55(11), 3469–3479, December 2008. [26] A.Weil, Number Theory for Beginners, Springer-Verlag, New [22] Y. Qiu, G. Zhou, Q. Zhao, and A. Cichocki, “Comparative study York, 1985. on the classification methods for breast cancer diagnosis”, Bull. [27] H. Wielandt, Finite Permutation Groups, Academic Press, New Pol. Ac.: Tech. 6(6), 841–848, 2018. York, 1964.

Bull. Pol. Ac.: Tech. 67(6) 2019 1005