Quantum Computing Simulation and Visualization  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Simulating Two Quantum Bits - Hadamard

//    q1 q0
// a0  0 0
// a1  0 1
// a2  1 0
// a3  1 1
//
void h( Complex a[], int i, int j) // half Hadamard
{
   Complex t0 = a[i], t1 = a[j]; a[i] = s2*(t0+t1); a[j] = s2*(t0-t1);
}
void H( Complex a[], int k) // Hadamard on qubit k
{
   if( k == 0) { h( a, 0, 1); h( a, 2, 3); }

   else        { h( a, 0, 2); h( a, 1, 3); }
}