Gate

Enum Gate 

Source
pub enum Gate {
    Operator(Box<dyn Operator>, Vec<usize>, Vec<usize>),
    Measurement(MeasurementBasis, Vec<usize>),
    Parametric(Box<dyn ParametricGate>, Vec<usize>, Vec<usize>),
    PauliString(PauliString),
    PauliTimeEvolution(PauliString, f64),
}
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.
§

Parametric(Box<dyn ParametricGate>, Vec<usize>, Vec<usize>)

Represents a parametric gate.

§

PauliString(PauliString)

Represents a Pauli String gate.

§Fields

  • PauliString - The Pauli String operator.
§

PauliTimeEvolution(PauliString, f64)

Represents a Pauli time evolution gate. WARNING: This gate is not yet supported in the compiler and cannot be used in circuits that need to be compiled. The compiler will panic if this gate is encountered during compilation.

§Fields

  • PauliString - The Pauli String operator.
  • time - The time parameter for the evolution.

Implementations§

Source§

impl Gate

Source

pub fn new_measurement( qubit_indices: Vec<usize>, basis: MeasurementBasis, ) -> Self

Creates a new measurement gate for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits to be measured.
  • basis - The basis of measurement (e.g., computational basis).
§Returns
  • Gate - A new instance of the Gate struct representing a measurement gate.
Source

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.
Source

pub fn apply(&self, state: &State) -> Result<State, Error>

Applies the gate to the given state and returns the new state.

§Arguments
  • state - The quantum state to which the gate will be applied.
§Returns
  • State - The new quantum state after applying the gate.
Source

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.
Source

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.
Source

pub fn h_gate(qubit_index: usize) -> Self

Creates a new Hadamard gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Hadamard gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Hadamard gate.
Source

pub fn h_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Hadamard gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Hadamard gate acts.
§Returns
  • Gates - A vector of Gate structs representing Hadamard gates for each qubit index.
Source

pub fn h_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Hadamard 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 Hadamard gates for each target qubit index.
Source

pub fn x_gate(qubit_index: usize) -> Self

Creates a new Pauli-X gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Pauli-X gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Pauli-X gate.
Source

pub fn x_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new controlled Pauli-X gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Pauli-X gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Pauli-X gates for each qubit index.
Source

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.
Source

pub fn y_gate(qubit_index: usize) -> Self

Creates a new Pauli-Y gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Pauli-Y gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Pauli-Y gate.
Source

pub fn y_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Pauli-Y gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Pauli-Y gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Pauli-Y gates for each qubit index.
Source

pub fn y_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Pauli-Y 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 Pauli-Y gates for each target qubit index.
Source

pub fn z_gate(qubit_index: usize) -> Self

Creates a new Pauli-Z gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Pauli-Z gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Pauli-Z gate.
Source

pub fn z_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Pauli-Z gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Pauli-Z gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Pauli-Z gates for each qubit index.
Source

pub fn z_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Pauli-Z 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 Pauli-Z gates for each target qubit index.
Source

pub fn i_gate(qubit_index: usize) -> Self

Creates a new Identity gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Identity gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing an Identity gate.
Source

pub fn i_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Identity gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Identity gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Identity gates for each qubit index.
Source

pub fn i_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Identity 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 Identity gates for each target qubit index.
Source

pub fn s_gate(qubit_index: usize) -> Self

Creates a new Phase-S gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Phase-S gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Phase-S gate.
Source

pub fn s_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Phase-S gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Phase-S gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Phase-S gates for each qubit index.
Source

pub fn s_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Phase-S 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 gates for each target qubit index.
Source

pub fn s_dag_gate(qubit_index: usize) -> Self

Creates a new Phase-S dagger gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Phase-S dagger gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Phase-S dagger gate.
Source

pub fn s_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Phase-S dagger gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Phase-S dagger gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Phase-S dagger gates for each qubit index.
Source

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.
Source

pub fn t_gate(qubit_index: usize) -> Self

Creates a new Phase-T gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Phase-T gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Phase-T gate.
Source

pub fn t_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Phase-T gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Phase-T gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Phase-T gates for each qubit index.
Source

pub fn t_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Vec<Self>

Creates new controlled Phase-T 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 gates for each target qubit index.
Source

pub fn t_dag_gate(qubit_index: usize) -> Self

Creates a new Phase-T dagger gate for the specified qubit index.

§Arguments
  • qubit_index - The index of the qubit on which the Phase-T dagger gate acts.
§Returns
  • Gate - A new instance of the Gate struct representing a Phase-T dagger gate.
Source

pub fn t_dag_multi_gate(qubit_indices: Vec<usize>) -> Vec<Self>

Creates new Phase-T dagger gates for the specified qubit indices.

§Arguments
  • qubit_indices - The indices of the qubits on which the Phase-T dagger gates act.
§Returns
  • Vec<Gate> - A vector of Gate structs representing Phase-T dagger gates for each qubit index.
Source

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.
Source

pub fn p_gate(qubit_index: usize, angle: f64) -> Self

Creates a new Phase Shift (P) gate for the specified qubit index and angle.

§Arguments
  • qubit_index - The index of the qubit on which the Phase Shift gate acts.
  • angle - The phase shift angle in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a Phase Shift gate.
Source

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.
Source

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.
Source

pub fn rx_gate(qubit_index: usize, angle: f64) -> Self

Creates a new RotateX (RX) gate for the specified qubit index and angle.

§Arguments
  • qubit_index - The index of the qubit on which the RotateX gate acts.
  • angle - The rotation angle in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a RotateX gate.
Source

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.
Source

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.
Source

pub fn ry_gate(qubit_index: usize, angle: f64) -> Self

Creates a new RotateY (RY) gate for the specified qubit index and angle.

§Arguments
  • qubit_index - The index of the qubit on which the RotateY gate acts.
  • angle - The rotation angle in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a RotateY gate.
Source

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.
Source

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.
Source

pub fn rz_gate(qubit_index: usize, angle: f64) -> Self

Creates a new RotateZ (RZ) gate for the specified qubit index and angle.

§Arguments
  • qubit_index - The index of the qubit on which the RotateZ gate acts.
  • angle - The rotation angle in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a RotateZ gate.
Source

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.
Source

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.
Source

pub fn unitary2_gate( qubit_index: usize, unitary: [[Complex<f64>; 2]; 2], ) -> Result<Self, Error>

Creates a new Unitary2 gate for the specified qubit index and unitary matrix.

§Arguments
  • qubit_index - The index of the qubit on which the Unitary2 gate acts.
  • unitary - The unitary matrix to be applied.
§Returns
  • Result<Gate, Error> - A Gate struct representing a Unitary2 gate if the unitary is valid, else an error.
Source

pub fn unitary2_multi_gate( qubit_indices: Vec<usize>, unitary: [[Complex<f64>; 2]; 2], ) -> Result<Vec<Self>, Error>

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
  • Result<Vec<Gate>, Error> - A vector of Gate structs representing Unitary2 gates for each qubit index if the unitary is valid,, else an error.
Source

pub fn unitary2_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, unitary: [[Complex<f64>; 2]; 2], ) -> Result<Vec<Self>, Error>

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
  • Result<Vec<Gate>, Error> - A vector of Gate structs representing controlled Unitary2 gates for each target qubit index if the unitary is valid, else an error.
Source

pub fn ry_phase_gate(qubit_index: usize, theta: f64, phi: f64) -> Self

Creates a new Unitary2 gate for the specified qubit index and unitary matrix using a rotation angle and phase shift. Unlike custom Unitary2 gates, the generated unitary matrix is guaranteed to be valid. Therefore, this method does not return an error.

§Arguments
  • qubit_index - The index of the qubit on which the Unitary2 gate acts.

  • theta - The rotation angle in radians.

  • phi - The phase shift in radians.

§Returns
  • Gate - A new instance of the Gate struct representing a Unitary2 gate.
Source

pub fn ry_phase_multi_gate( qubit_indices: Vec<usize>, theta: f64, phi: f64, ) -> Vec<Self>

Creates new Unitary2 gates for the specified qubit indices and unitary matrix using a rotation angle and phase shift. Unlike custom Unitary2 gates, the generated unitary matrix is guaranteed to be valid. Therefore, this method does not return an error.

§Arguments
  • qubit_indices - The indices of the qubits on which the Unitary2 gates act.

  • theta - The rotation angle in radians for all gates.

  • phi - The phase shift in radians for all gates.

§Returns
  • Vec<Gate> - A vector of Gate structs representing Unitary2 gates for each qubit index.
Source

pub fn ry_phase_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, theta: f64, phi: f64, ) -> Vec<Self>

Creates new controlled Unitary2 gates for the specified qubit indices and unitary matrix using a rotation angle and phase shift.

§Arguments
  • target_indices - The indices of the target qubits.

  • control_indices - The indices of the control qubits.

  • theta - The rotation angle in radians for all gates.

  • phi - The phase shift in radians for all gates.

§Returns
  • Vec<Gate> - A vector of Gate structs representing controlled Unitary2 gates for each target qubit index.
Source

pub fn ry_phase_dag_gate(qubit_index: usize, theta: f64, phi: f64) -> Self

Creates a new Unitary2 gate from a rotation angle theta and phase shift angle phi.

§Arguments
  • qubit_index - The index of the qubit on which the Unitary2 gate acts.
  • theta - The rotation angle in radians.
  • phi - The phase shift angle in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a Unitary2 gate.
Source

pub fn ry_phase_dag_multi_gate( qubit_indices: Vec<usize>, theta: f64, phi: f64, ) -> Vec<Self>

Creates new Unitary2 gates from a rotation angle theta and phase shift angle phi.

§Arguments
  • qubit_indices - The indices of the qubits on which the Unitary2 gates act.

  • theta - The rotation angle in radians.

  • phi - The phase shift angle in radians.

  • Vec<Gate> - A vector of Gate structs representing Unitary2 gates for each qubit index.

Source

pub fn ry_phase_dag_controlled_gates( target_indices: Vec<usize>, control_indices: Vec<usize>, theta: f64, phi: f64, ) -> Vec<Self>

Creates new controlled Unitary2 gates from a rotation angle theta and phase shift angle phi.

§Arguments
  • target_indices - The indices of the target qubits.
  • control_indices - The indices of the control qubits.
  • theta - The rotation angle in radians.
  • phi - The phase shift angle in radians.
§Returns
  • Vec<Gate> - A vector of Gate structs representing controlled Unitary2 gates for each target qubit index.
Source

pub fn cnot_gate(target_index: usize, control_index: usize) -> Self

Creates a CNOT gate for the specified target and control qubit indices.

§Arguments
  • target_index - The index of the target qubit.

  • control_index - The index of the control qubit.

§Returns
  • Gate - A new instance of the Gate struct representing a CNOT gate.
Source

pub fn swap_gate(qubit1_index: usize, qubit2_index: usize) -> Self

Creates a new SWAP gate for the specified qubit index.

§Arguments
  • qubit1 - The index of the first qubit.
  • qubit2 - The index of the second qubit.
§Returns
  • Gate - A new instance of the Gate struct representing a SWAP gate.
Source

pub fn swap_controlled_gate( target_indices: Vec<usize>, control_indices: Vec<usize>, ) -> Self

Creates a new controlled SWAP gate for the specified target and control qubit indices.

§Arguments
  • target_indices - The indices of the target qubits.
  • control_indices - The indices of the control qubits.
§Returns
  • Gate - A new instance of the Gate struct representing a controlled SWAP gate.
Source

pub fn toffoli_gate(target_index: usize, control_indices: Vec<usize>) -> Self

Creates a new Toffoli gate for the specified target and control qubit indices.

§Arguments
  • target_index - The index of the target qubit.
  • control_indices - The indices of the control qubits.
§Returns
  • Gate - A new instance of the Gate struct representing a Toffoli gate.
Source

pub fn pauli_string_gate(pauli_string: PauliString) -> Self

Creates a new PauliString gate with the specified Pauli String.

§Arguments
  • pauli_string - The Pauli string to be represented by the gate.
§Returns
  • Gate - A new instance of the Gate struct representing a PauliString gate.
Source

pub fn pauli_time_evolution_gate(pauli_string: PauliString, time: f64) -> Self

Creates a new Pauli time evolution gate with the specified Pauli String and time.

§Arguments
  • pauli_string - The Pauli string to be represented by the gate.
  • time - The time parameter for the evolution.
§Returns
  • Gate - A new instance of the Gate struct representing a Pauli time evolution gate.
Source

pub fn matchgate(target_index: usize, theta: f64, phi1: f64, phi2: f64) -> Self

Creates a new Matchgate with the specified qubit index and its adjacent as targets.

§Arguments
  • target_index - The index of the first target qubit. The second target qubit is assumed to be the next qubit.
  • theta - The angle of rotation in radians.
  • phi1 - The first phase shift in radians.
  • phi2 - The second phase shift in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a Matchgate.
§Warning

This gate is not yet compilable to OpenQASM, since it requires advanced decomposition techniques.

Source

pub fn controlled_matchgate( target_index: usize, control_indices: Vec<usize>, theta: f64, phi1: f64, phi2: f64, ) -> Self

Creates a new controlled Matchgate with the specified qubit index and its adjacent as target qubits.

§Arguments
  • target_index - The index of the first target qubit. The second target qubit is assumed to be the next qubit.
  • control_indices - The indices of the control qubits.
  • theta - The angle of rotation in radians.
  • phi1 - The first phase shift in radians.
  • phi2 - The second phase shift in radians.
§Returns
  • Gate - A new instance of the Gate struct representing a controlled Matchgate.
§Warning

This gate is not yet compilable to OpenQASM, since it requires advanced decomposition techniques.

Trait Implementations§

Source§

impl Clone for Gate

Source§

fn clone(&self) -> Gate

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Gate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V