pub trait Operator {
// Required methods
fn apply(
&self,
state: &State,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn base_qubits(&self) -> usize;
}Expand description
A trait defining the interface for all operators.
Required Methods§
Sourcefn 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 operator to the given state’s target qubits, using the control qubits if required.
§Arguments:
-
state- The state to apply the operator to. -
target_qubits- The target qubits to apply the operator to. If no target qubits are specified, the operator will be applied to all qubits in the state. -
control_qubits- The control qubits to apply the operator to.
§Returns:
- The new state after applying the operator.
Sourcefn base_qubits(&self) -> usize
fn base_qubits(&self) -> usize
Returns the number of qubits that the operator acts on.
§Returns:
- The number of qubits that the operator acts on.