Class Scramble

java.lang.Object
org.apfloat.internal.Scramble

public class Scramble extends Object
Functions to perform bit-reverse ordering of data.
Version:
1.0
Author:
Mikko Tommila
  • Method Details

    • permute

      public static int permute(int n, int length)
      Permute the bits of a number to reverse order.

      For example, if n is 5 and the transform length is 256, the permutation is (in binary)

      00000101 → 10100000

      Parameters:
      n - The number whose bits to reverse.
      length - The FFT transform length for which the bit reversal to perform.
      Returns:
      The bits of n reversed.
    • createScrambleTable

      public static int[] createScrambleTable(int length)
      Create a table of indexes for scrambling an array for FFT.

      The returned table contains pairs of indexes that should be swapped to scramble an array. For example, for transform length 8 the returned table contains { 1, 4, 3, 6 } to indicate that the array elements [1] and [4] should be swapped, and the elements [3] and [6] should be swapped.

      Parameters:
      length - The FFT transform length for which the scrambling table is created.
      Returns:
      An array of pairs of indexes that indicate, which array elements should be swapped to scramble the array.