pub struct Unitary2 { /* private fields */ }Expand description
An arbitrary 2×2 unitary operator.
This operator can be applied to a single qubit in a quantum state. It is represented by a 2×2 unitary matrix.
Implementations§
Source§impl Unitary2
impl Unitary2
Sourcepub fn new(matrix: [[Complex<f64>; 2]; 2]) -> Result<Self, Error>
pub fn new(matrix: [[Complex<f64>; 2]; 2]) -> Result<Self, Error>
Creates a new Unitary2 operator with the given 2×2 unitary matrix.
§Arguments:
matrix- A 2×2 unitary matrix represented as a 2D array of complex numbers.
§Returns:
Result<Self, Error>- A result containing the new Unitary2 operator or an error if the matrix is not unitary.
§Errors:
Error::NonUnitaryMatrix- If the provided matrix is not unitary.
Trait Implementations§
Source§impl Operator for Unitary2
impl Operator for Unitary2
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 Unitary2 operator to the given state’s target 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. If not empty, the operator will be applied conditionally based on the control qubits. Otherwise, it will be applied unconditionally.
§Returns:
- The new state after applying the Unitary2 operator.
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 Unitary2
Auto Trait Implementations§
impl Freeze for Unitary2
impl RefUnwindSafe for Unitary2
impl Send for Unitary2
impl Sync for Unitary2
impl Unpin for Unitary2
impl UnwindSafe for Unitary2
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