Quantum Computing Simulation and Visualization  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Simulating One Quantum Bit

//     q0
// a0  0
// a1  1
//
typedef double complex Complex;

// swap a[i] and a[j]
void swap( Complex a[], int i, int j) { Complex t = a[i]; a[i] = a[j]; a[j] = t; }

void X( Complex a[]) { swap( a, 0, 1); } // NOT

void Z( Complex a[]) { a[1] = -a[1]; } // phase flip

void S( Complex a[]) { a[1] = CMPLX(0,1)*a[1]; } // sqrt(Z)

void H( Complex a[]) // Hadamard
{
   double s2 = 1/sqrt(2);

   Complex t0 = a[0], t1 = a[1]; a[0] = s2*(t0+t1); a[1] = s2*(t0-t1);
}
...
int main( void) { Complex a[2] = { 3.0/5.0, CMPLX(0,4.0/5.0) }; // constraint: sum |a[i]|2 = 1
...