pub struct Toffoli;Expand description
Defines a Toffoli operator.
A three-qubit operator that flips the target qubit if both control qubits are in the |1> state. Also known as CCNOT (Controlled-Controlled-NOT).
Trait Implementations§
Source§impl Operator for Toffoli
impl Operator for Toffoli
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 Toffoli operator to the given state’s target qubit, using the control qubits.
§Arguments:
-
state- The state to apply the operator to. -
target_qubits- The target qubit to apply the operator to. This should be a single qubit. -
control_qubits- The control qubits for the operator. This should be two qubits.
§Returns:
- The new state after applying the Toffoli operator.
§Errors:
-
Error::InvalidNumberOfQubits- If the target or control qubits are not 1 and 2 respectively, or if the control qubits are not different. -
Error::InvalidQubitIndex- If the target or control qubit indices are 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
Source§fn to_compilable(&self) -> Option<&dyn Compilable>
fn to_compilable(&self) -> Option<&dyn Compilable>
impl Copy for Toffoli
Auto Trait Implementations§
impl Freeze for Toffoli
impl RefUnwindSafe for Toffoli
impl Send for Toffoli
impl Sync for Toffoli
impl Unpin for Toffoli
impl UnwindSafe for Toffoli
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
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>
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>
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