pub enum Gate {
Operator(Box<dyn Operator>, Vec<usize>, Vec<usize>),
Measurement(MeasurementBasis, Vec<usize>),
}Expand description
Represents a quantum gate as part of a quantum circuit.
Variants§
Operator(Box<dyn Operator>, Vec<usize>, Vec<usize>)
Represents an operator gate.
§Fields
-
operator- A boxed dynamic operator trait object. -
target_indices- The indices of the qubits on which the operator acts. -
control_indices- Optional control qubit indices for controlled gates. If empty, the gate is applied unconditionally.
Measurement(MeasurementBasis, Vec<usize>)
Represents a measurement gate.
§Fields
MeasurementBasis- The basis of measurement (e.g., computational basis).indices- The indices of the measured qubits.
Implementations§
Source§impl Gate
impl Gate
Sourcepub fn new_measurement(
qubit_indices: Vec<usize>,
basis: MeasurementBasis,
) -> Self
pub fn new_measurement( qubit_indices: Vec<usize>, basis: MeasurementBasis, ) -> Self
Sourcepub fn new_operator(
operator: Box<dyn Operator>,
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Self
pub fn new_operator( operator: Box<dyn Operator>, target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Self
Creates a new operator gate for the specified qubit indices.
§Arguments
-
operator- A boxed dynamic operator trait object. -
target_indices- The indices of the qubits on which the operator acts. -
control_indices- Optional control qubit indices for controlled gates.
§Returns
Gate- A new instance of the Gate struct representing an operator gate.
Sourcepub fn get_target_qubits(&self) -> &Vec<usize>
pub fn get_target_qubits(&self) -> &Vec<usize>
Returns the indices of the qubits on which the gate acts.
§Returns
&Vec<usize>- A vector of indices of the qubits on which the gate acts.
Sourcepub fn get_control_qubits(&self) -> Option<&Vec<usize>>
pub fn get_control_qubits(&self) -> Option<&Vec<usize>>
Returns the control indices of the gate if it has any.
§Returns
Option<&Vec<usize>>- An optional vector of control indices.
Sourcepub fn h_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn h_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn h_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn h_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn x_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn x_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn x_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn x_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Creates new Pauli-X gates for the specified qubit indices with control qubits.
§Arguments
-
target_indices- The indices of the target qubits. -
control_indices- The indices of the control qubits.
§Returns
Gates- A vector of Gate structs representing controlled Pauli-X gates for each target qubit index.
Sourcepub fn y_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn y_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn y_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn y_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn z_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn z_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn z_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn z_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn i_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn i_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn i_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn i_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn s_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn s_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn s_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn s_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn s_dag_gate(qubit_index: usize) -> Self
pub fn s_dag_gate(qubit_index: usize) -> Self
Sourcepub fn s_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn s_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn s_dag_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn s_dag_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Creates new controlled Phase-S dagger gates for the specified qubit indices.
§Arguments
-
target_indices- The indices of the target qubits. -
control_indices- The indices of the control qubits.
§Returns
Gates- A vector of Gate structs representing controlled Phase-S dagger gates for each target qubit index.
Sourcepub fn t_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn t_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn t_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn t_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Sourcepub fn t_dag_gate(qubit_index: usize) -> Self
pub fn t_dag_gate(qubit_index: usize) -> Self
Sourcepub fn t_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
pub fn t_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>
Sourcepub fn t_dag_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Vec<Self>
pub fn t_dag_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>
Creates new controlled Phase-T dagger gates for the specified qubit indices.
§Arguments
-
target_indices- The indices of the target qubits. -
control_indices- The indices of the control qubits.
§Returns
Gates- A vector of Gate structs representing controlled Phase-T dagger gates for each target qubit index.
Sourcepub fn p_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
pub fn p_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
Creates new Phase Shift (P) gates for the specified qubit indices and angle.
§Arguments
qubit_indices- The indices of the qubits on which the Phase Shift gates act.angle- The phase shift angle in radians for all gates.
§Returns
Vec<Gate>- A vector of Gate structs representing Phase Shift gates for each qubit index.
Sourcepub fn p_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
angle: f64,
) -> Vec<Self>
pub fn p_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, angle: f64, ) -> Vec<Self>
Creates new controlled Phase Shift (P) gates for the specified qubit indices and angle.
§Arguments
target_indices- The indices of the target qubits.control_indices- The indices of the control qubits.angle- The phase shift angle in radians for all gates.
§Returns
Gates- A vector of Gate structs representing controlled Phase Shift gates for each target qubit index.
Sourcepub fn rx_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
pub fn rx_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
Creates new RotateX (RX) gates for the specified qubit indices and angle.
§Arguments
qubit_indices- The indices of the qubits on which the RotateX gates act.angle- The rotation angle in radians for all gates.
§Returns
Vec<Gate>- A vector of Gate structs representing RotateX gates for each qubit index.
Sourcepub fn rx_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
angle: f64,
) -> Vec<Self>
pub fn rx_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, angle: f64, ) -> Vec<Self>
Creates new controlled RotateX (RX) gates for the specified qubit indices and angle.
§Arguments
target_indices- The indices of the target qubits.control_indices- The indices of the control qubits.angle- The rotation angle in radians for all gates.
§Returns
Gates- A vector of Gate structs representing controlled RotateX gates for each target qubit index.
Sourcepub fn ry_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
pub fn ry_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
Creates new RotateY (RY) gates for the specified qubit indices and angle.
§Arguments
qubit_indices- The indices of the qubits on which the RotateY gates act.angle- The rotation angle in radians for all gates.
§Returns
Vec<Gate>- A vector of Gate structs representing RotateY gates for each qubit index.
Sourcepub fn ry_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
angle: f64,
) -> Vec<Self>
pub fn ry_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, angle: f64, ) -> Vec<Self>
Creates new controlled RotateY (RY) gates for the specified qubit indices and angle.
§Arguments
target_indices- The indices of the target qubits.control_indices- The indices of the control qubits.angle- The rotation angle in radians for all gates.
§Returns
Gates- A vector of Gate structs representing controlled RotateY gates for each target qubit index.
Sourcepub fn rz_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
pub fn rz_multi_gate(qubit_indices: Vec<usize>, angle: f64) -> Vec<Self>
Creates new RotateZ (RZ) gates for the specified qubit indices and angle.
§Arguments
qubit_indices- The indices of the qubits on which the RotateZ gates act.angle- The rotation angle in radians for all gates.
§Returns
Vec<Gate>- A vector of Gate structs representing RotateZ gates for each qubit index.
Sourcepub fn rz_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
angle: f64,
) -> Vec<Self>
pub fn rz_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, angle: f64, ) -> Vec<Self>
Creates new controlled RotateZ (RZ) gates for the specified qubit indices and angle.
§Arguments
target_indices- The indices of the target qubits.control_indices- The indices of the control qubits.angle- The rotation angle in radians for all gates.
§Returns
Gates- A vector of Gate structs representing controlled RotateZ gates for each target qubit index.
Sourcepub fn unitary2_multi_gate(
qubit_indices: Vec<usize>,
unitary: [[Complex<f64>; 2]; 2],
) -> Vec<Self>
pub fn unitary2_multi_gate( qubit_indices: Vec<usize>, unitary: [[Complex<f64>; 2]; 2], ) -> Vec<Self>
Creates new Unitary2 gates for the specified qubit indices and unitary matrix.
§Arguments
-
qubit_indices- The indices of the qubits on which the Unitary2 gates act. -
unitary- The unitary matrix to be applied.
§Returns
Vec<Gate>- A vector of Gate structs representing Unitary2 gates for each qubit index.
Sourcepub fn unitary2_controlled_gates(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
unitary: [[Complex<f64>; 2]; 2],
) -> Vec<Self>
pub fn unitary2_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, unitary: [[Complex<f64>; 2]; 2], ) -> Vec<Self>
Creates new controlled Unitary2 gates for the specified qubit indices and unitary matrix.
§Arguments
-
target_indices- The indices of the target qubits. -
control_indices- The indices of the control qubits. -
unitary- The unitary matrix to be applied.
§Returns
Gates- A vector of Gate structs representing controlled Unitary2 gates for each target qubit index.
Sourcepub fn swap_controlled_gate(
target_indices: Vec<usize>,
control_indices: Vec<usize>,
) -> Self
pub fn swap_controlled_gate( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Self
Sourcepub fn toffoli_gate(target_index: usize, control_indices: Vec<usize>) -> Self
pub fn toffoli_gate(target_index: usize, control_indices: Vec<usize>) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Gate
impl !RefUnwindSafe for Gate
impl Send for Gate
impl Sync for Gate
impl Unpin for Gate
impl !UnwindSafe for Gate
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