pub struct CNOT;Expand description
Defines a CNOT operator.
A two-qubit operator that flips the target qubit if the control qubit is in the |1> state.
Trait Implementations§
Source§impl Operator for CNOT
impl Operator for CNOT
Source§fn apply(
&self,
state: &State,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn apply( &self, state: &State, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the CNOT operator to the given state’s target qubit, using the control qubit.
§Arguments:
-
state- The state to apply the operator to. -
target_qubits- The target qubits to apply the operator to. This should be a single qubit. -
control_qubits- The control qubits for the operator. This should be a single qubit.
§Returns:
- The new state after applying the CNOT operator.
§Errors:
-
Error::InvalidNumberOfQubits- If the target or control qubits is not 1. -
Error::InvalidQubitIndex- If the target or control qubit index is invalid for the number of qubits in the state. -
Error::OverlappingControlAndTargetQubits- If the control qubit and target qubit indices overlap.
Source§fn base_qubits(&self) -> usize
fn base_qubits(&self) -> usize
Returns the number of qubits that the operator acts on. Read more
impl Copy for CNOT
Auto Trait Implementations§
impl Freeze for CNOT
impl RefUnwindSafe for CNOT
impl Send for CNOT
impl Sync for CNOT
impl Unpin for CNOT
impl UnwindSafe for CNOT
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more