Quantum Computing Simulation  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Simulating Measurements

Two Qubits - measure one
void M1( Complex a[]) { // measure qubit 1

   int k = Mk( a); if( k == 0 || k == 1) { // qubit 1 is 0

     printf( "M1 = 0\n"); a[2] = a[3] = 0; // normalize remaining states

     double s = sqrt( abs2(a[0]) + abs2(a[1])); a[0] /= s; a[1] /= s; }

   else { // qubit 1 is 1

     printf( "M1 = 1\n"); a[0] = a[1] = 0;

     double s = sqrt( abs2(a[2]) + abs2(a[3])); a[2] /= s; a[3] /= s; }
}