Quantum Computing Simulation and Visualization  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Quantum Fourier Transform

high-level simulation
  // quantum FFT
  //
  void qfft( int inv = 0) {

    fft<Complex,Real>( a, N, inv); // classical FFT, without scaling and bit reversal

   // scale values and bit-reverse the indices
   //
    Real s = 1/std::sqrt((Real)N);

    for( unsigned long i = 0, j = 0; i < N; ++i) {

      j = bitrev( i, n);

      if( i < j) { swap( i, j); a[i] *= s; a[j] *= s; }

      else if( i == j) a[i] *= s;
    }
  }

fft.h