How do you specify control and target qubit for CNOT?
Closed this issue · 4 comments
Hey, I'm a bit confused by CNOT API. in Microsoft Q# API of CNOT is really simple - you specify control
and target
qubits. How it can be implemented with this library?
Hi, You can use gate.ControlledNot(numberOfQubit, control, target int)
instead of gate.CNOT()
.
@itsubaki ah, thanks, missed it. Sorry for the lame question, but why control
and target
are ints? If I have c
and t
qubits, how to I apply ControlledNot
on them?
ok. qubits is vector
, gate is matrix
in this library. control
and target
is index of qubits. this library can not be considered separately qubits. because qubits is possible to take the quantum entanglement
state. and I don't know implementation for quantum entanglement
operation in Q#. I will check Q# later.
example
c := qubit.One()
t := qubit.Zero()
q := qubit.TensorProduct(c, t)
// q -> |1>|0>
// it means q[0] -> |1>, q[1] -> |0>
cnot := gate.ControlledNot(2, 0, 1)
q.Apply(cnot)
// q -> |1>|1>