Bit-reversal Permutation
   HOME

TheInfoList



OR:

In applied mathematics, a bit-reversal permutation is a
permutation In mathematics, a permutation of a set can mean one of two different things: * an arrangement of its members in a sequence or linear order, or * the act or process of changing the linear order of an ordered set. An example of the first mean ...
of a
sequence In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
of n items, where n=2^k is a
power of two A power of two is a number of the form where is an integer, that is, the result of exponentiation with number 2, two as the Base (exponentiation), base and integer  as the exponent. In the fast-growing hierarchy, is exactly equal to f_1^ ...
. It is defined by indexing the elements of the sequence by the numbers from 0 to n-1, representing each of these numbers by its
binary representation A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method for representing numbers that uses only two symbols for the natural numbers: typically "0" (zero) and "1" (one). A ''binary number'' may also ...
(padded to have length exactly k), and mapping each item to the item whose representation has the same bits in the reversed order. Repeating the same permutation twice returns to the original ordering on the items, so the bit reversal permutation is an
involution Involution may refer to: Mathematics * Involution (mathematics), a function that is its own inverse * Involution algebra, a *-algebra: a type of algebraic structure * Involute, a construction in the differential geometry of curves * Exponentiati ...
. This permutation can be applied to any sequence in
linear time In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations ...
while performing only simple index calculations. It has applications in the generation of
low-discrepancy sequence In mathematics, a low-discrepancy sequence is a sequence with the property that for all values of N, its subsequence x_1, \ldots, x_N has a low discrepancy of a sequence, discrepancy. Roughly speaking, the discrepancy of a sequence is low if the p ...
s and in the evaluation of
fast Fourier transform A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...
s.


Example

Consider the sequence of eight letters '. Their indexes are the binary numbers 000, 001, 010, 011, 100, 101, 110, and 111, which when reversed become 000, 100, 010, 110, 001, 101, 011, and 111. Thus, the letter ''a'' in position 000 is mapped to the same position (000), the letter ''b'' in position 001 is mapped to the fifth position (the one numbered 100), etc., giving the new sequence '. Repeating the same permutation on this new sequence returns to the starting sequence. Writing the index numbers in decimal (but, as above, starting with position 0 rather than the more conventional start of 1 for a permutation), the bit-reversal permutations on n=2^k items, for k=0,1,2, 3, \dots, are: Each permutation in this sequence can be generated by concatenating two sequences of numbers: the previous permutation, with its values doubled, and the same sequence with each value increased by one. Thus, for example doubling the length-4 permutation gives , adding one gives , and concatenating these two sequences gives the length-8 permutation .


Generalizations

The generalization to
radix In a positional numeral system, the radix (radices) or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal system (the most common system in use today) the radix is ten, becaus ...
b representations, for b > 2, and to n=b^k, is a digit-reversal permutation, in which the base-b digits of the index of each element are reversed to obtain the permuted index. The same idea can also been generalized to
mixed radix Mixed radix numeral systems are non-standard positional numeral systems in which the numerical base varies from position to position. Such numerical representation applies when a quantity is expressed using a sequence of units that are each a m ...
number systems. In such cases, the digit-reversal permutation should simultaneously reverse the digits of each item and the bases of the number system, so that each reversed digit remains within the range defined by its base. Permutations that generalize the bit-reversal permutation by reversing contiguous blocks of bits within the binary representations of their indices can be used to interleave two equal-length sequences of data in-place. There are two extensions of the bit-reversal permutation to sequences of arbitrary length. These extensions coincide with bit-reversal for sequences whose length is a power of 2, and their purpose is to separate adjacent items in a sequence for the efficient operation of the Kaczmarz algorithm. The first of these extensions, called ''efficient ordering'', operates on composite numbers, and it is based on decomposing the number into its prime components. The second extension, called EBR (extended bit-reversal), is similar in spirit to bit-reversal. Given an array of size n, EBR fills the array with a permutation of the numbers in the range 0\ldots n-1 in linear time. Successive numbers are separated in the permutation by at least \lfloor n/4\rfloor positions.


Applications

Bit reversal is most important for radix-2
Cooley–Tukey FFT algorithm The Cooley–Tukey algorithm, named after James Cooley, J. W. Cooley and John Tukey, is the most common fast Fourier transform (FFT) algorithm. It re-expresses the discrete Fourier transform (DFT) of an arbitrary composite number, composite size ...
s, where the recursive stages of the algorithm, operating
in-place In computer science, an in-place algorithm is an algorithm that operates directly on the input data structure without requiring extra space proportional to the input size. In other words, it modifies the input in place, without creating a separa ...
, imply a bit reversal of the inputs or outputs. Similarly, mixed-radix digit reversals arise in mixed-radix Cooley–Tukey FFTs. The bit reversal permutation has also been used to devise
lower bound In mathematics, particularly in order theory, an upper bound or majorant of a subset of some preordered set is an element of that is every element of . Dually, a lower bound or minorant of is defined to be an element of that is less th ...
s in distributed computation. The Van der Corput sequence, a
low-discrepancy sequence In mathematics, a low-discrepancy sequence is a sequence with the property that for all values of N, its subsequence x_1, \ldots, x_N has a low discrepancy of a sequence, discrepancy. Roughly speaking, the discrepancy of a sequence is low if the p ...
of numbers in the
unit interval In mathematics, the unit interval is the closed interval , that is, the set of all real numbers that are greater than or equal to 0 and less than or equal to 1. It is often denoted ' (capital letter ). In addition to its role in real analysi ...
, is formed by reinterpreting the indexes of the bit-reversal permutation as the fixed-point binary representations of dyadic rational numbers. Bit-reversal permutations are often used in finding lower bounds on dynamic
data structures In computer science, a data structure is a data organization and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, and the functi ...
. For example, subject to certain assumptions, the cost of looking up the integers between 0 and n-1, inclusive, in any
binary search tree In computer science, a binary search tree (BST), also called an ordered or sorted binary tree, is a Rooted tree, rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left ...
holding those values, is \Omega(n \log n) when those numbers are queried in bit-reversed order. This bound applies even to trees like splay trees that are allowed to rearrange their nodes between accesses.


Algorithms

Mainly because of the importance of
fast Fourier transform A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...
algorithms, numerous efficient algorithms for applying a bit-reversal permutation to a sequence have been devised.. Karp surveys and compares 30 different algorithms for bit reversal, developed between 1965 and the 1996 publication of his survey. Because the bit-reversal permutation is an involution, it may be performed easily in place (without copying the data into another array) by swapping pairs of elements. In the
random-access machine In computer science, random-access machine (RAM or RA-machine) is a model of computation that describes an abstract machine in the general class of register machines. The RA-machine is very similar to the counter machine but with the added capab ...
commonly used in algorithm analysis, a simple algorithm that scans the indexes in input order and swaps whenever the scan encounters an index whose reversal is a larger number would perform a linear number of data moves. However, computing the reversal of each index may take a non-constant number of steps. Alternative algorithms can perform a bit reversal permutation in linear time while using only simple index calculations. Because bit-reversal permutations may be repeated multiple times as part of a calculation, it may be helpful to separate out the steps of the algorithm that calculate index data used to represent the permutation (for instance, by using the doubling and concatenation method) from the steps that use the results of this calculation to permute the data (for instance, by scanning the data indexes in order and performing a swap whenever the swapped location is greater than the current index, or by using more sophisticated vector scatter–gather operations). Another consideration that is even more important for the performance of these algorithms is the effect of the
memory hierarchy In computer architecture, the memory hierarchy separates computer storage into a hierarchy based on response time. Since response time, complexity, and capacity are related, the levels may also be distinguished by their performance and contr ...
on running time. Because of this effect, more sophisticated algorithms that consider the block structure of memory can be faster than this naive scan.. An alternative to these techniques is special computer hardware that allows memory to be accessed both in normal and in bit-reversed order. Significant attention has been given to improving the performance of bit-reversal operations within the field of high-performance computing. Developing architecture-aware algorithms is crucial for enabling optimal use of hardware and system software resources such as caches, TLBs, and multicore processors.{{citation , last1 = Zhang , first1 = Zhao , last2 = Zhang , first2 = Xiaodong , doi = 10.1137/S1064827599359709 , issue = 6 , journal = SIAM Journal on Scientific Computing , mr = 1856305 , pages = 2113–2134 , title = Fast bit-reversals on uniprocessors and shared-memory multiprocessors , volume = 22 , year = 2000


References

Permutations FFT algorithms Combinatorial algorithms