oreilly-qc / oreilly-qc.github.io

Code samples for Programming Quantum Computers, from O'Reilly Media
135 stars 62 forks source link

Documentation has CNOT arguments in the wrong order #8

Closed a-poor closed 4 years ago

a-poor commented 4 years ago

The cheatsheet page of the documentation for CNOT says the following

qc.cnot(condition_qubit, target_qubit) Applies the CNOT operation between two qubits. Takes two arguments condition_qubit and target_qubit. The first argument (condition_qubit) specifies the qubit whose value will determine whether or not a NOT operation is applied to the target_qubit specified in the second argument. Example: qc.cnot(0x4, 0x2)

but the following code produces the opposite result

qc.reset(2);
var a = qint.new(1, 'a');
var b = qint.new(1, 'b');
qc.write(0);
a.had();
qc.cnot(a,b);

Here's the resulting circuit diagram:

QC Circuit

Which shows b as the condition_qubit and a as the target_qubit.

machinelevel commented 4 years ago

Yep! you're totally correct. Thank you! Fixed in f9f38f1