Quantum Computing Simulation and Visualization  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Simulating n Quantum Bits - Hadamard

// Hadamard on qubit k
//
// n qubits, N = 2n amplitudes
//
  unsigned long i = 0, j, k1 = 1LU << k; // k1 = 0...010...0, k'th bit = 1

  while( i < N) { // i will have k'th bit = 0, j will have k'th bit = 1

    j = i | k1; Complex t0 = a[i], t1 = a[j];

    a[i] = s2*(t0+t1); a[j] = s2*(t0-t1);

    ++i; i += (i & k1); // skip i values with k'th bit = 1

  }