Trait roqoqo::operations::OperateSingleQubitGate
source · [−]pub trait OperateSingleQubitGate: Operate + OperateGate + InvolveQubits + Substitute + OperateSingleQubit + Clone + PartialEq + OperateSingleQubit + Debug {
fn alpha_r(&self) -> CalculatorFloat;
fn alpha_i(&self) -> CalculatorFloat;
fn beta_r(&self) -> CalculatorFloat;
fn beta_i(&self) -> CalculatorFloat;
fn global_phase(&self) -> CalculatorFloat;
fn mul<T>(&self, other: &T) -> Result<SingleQubitGate, RoqoqoError>
where
T: OperateSingleQubitGate,
{ ... }
}
Expand description
Trait for unitary operations acting on exactly one qubit.
Implements the general single qubit unitary gates that can be brought into the form:
$$ U =e^{i \phi}\begin{pmatrix} \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\ \beta_r+i \beta_i & \alpha_r-i\alpha_i \end{pmatrix} $$
These gates can be parametrized by five real parameters:
alpha_r
- The real part $ \alpha_r $ of the on-diagonal elements of the single-qubit unitary.alpha_i
- The imaginary part $ \alpha_i $ of the on-diagonal elements of the single-qubit unitary.beta_r
- The real part $ \beta_r $ of the off-diagonal elements of the single-qubit unitary.beta_i
- The imaginary part $ \beta_i $ of the off-diagonal elements of the single-qubit unitary.global_phase
- The global phase $ \phi $ of the single-qubit unitary.
These are the single qubit gates that are performed in the Circuit(), and are then translated to quantum hardware through the relevant backend. Two-qubit gates are also available (see roqoqo/src/operations/two_qubit_gate_operations.rs).
Example
use qoqo_calculator::CalculatorFloat;
use roqoqo::operations::{OperateSingleQubitGate, PauliX};
use std::f64::consts::PI;
let paulix = PauliX::new(0);
assert_eq!(paulix.alpha_r(), 0.0.into());
assert_eq!(paulix.alpha_i(), 0.0.into());
assert_eq!(paulix.beta_r(), 0.0.into());
assert_eq!(paulix.beta_i(), CalculatorFloat::from(-1.0));
assert_eq!(paulix.global_phase(), ((PI) / 2.0).into());
Required methods
fn alpha_r(&self) -> CalculatorFloat
fn alpha_r(&self) -> CalculatorFloat
Returns alpha_r parameter of operation.
Returns
alpha_r
- The real part $\alpha_r$ of the on-diagonal elements of the single-qubit unitary matrix.
fn alpha_i(&self) -> CalculatorFloat
fn alpha_i(&self) -> CalculatorFloat
Returns alpha_i parameter of operation.
Returns
alpha_i
- The imaginary part $ \alpha_i $ of the on-diagonal elements of the single-qubit unitary matrix.
fn beta_r(&self) -> CalculatorFloat
fn beta_r(&self) -> CalculatorFloat
Returns beta_r parameter of operation.
Returns
beta_r
- The real part $ \beta_r $ of the off-diagonal elements of the single-qubit unitary matrix.
fn beta_i(&self) -> CalculatorFloat
fn beta_i(&self) -> CalculatorFloat
Returns beta_i parameter of operation.
Returns
beta_i
- imaginary part $ \beta_i $ of the off-diagonal elements of the single-qubit unitary matrix.
fn global_phase(&self) -> CalculatorFloat
fn global_phase(&self) -> CalculatorFloat
Returns global_phase parameter of operation.
Returns
global_phase
- The global phase phi $ \phi $ of the single-qubit unitary.
Provided methods
fn mul<T>(&self, other: &T) -> Result<SingleQubitGate, RoqoqoError> where
T: OperateSingleQubitGate,
fn mul<T>(&self, other: &T) -> Result<SingleQubitGate, RoqoqoError> where
T: OperateSingleQubitGate,
Multiplies two compatible operations implementing OperateSingleQubitGate.
Does not consume the two operations being multiplied. Only Operations
Arguments:
other
- An Operation implementing OperateSingleQubitGate.
Example
use roqoqo::operations::{RotateZ, RotateX};
use roqoqo::prelude::*;
use qoqo_calculator::CalculatorFloat;
let gate1 = RotateZ::new(0, CalculatorFloat::from(1));
let gate2 = RotateX::new(0, CalculatorFloat::from(1));
let multiplied = gate1.mul(&gate2).unwrap();
Implementors
impl OperateSingleQubitGate for SingleQubitGateOperation
impl OperateSingleQubitGate for Hadamard
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for InvSqrtPauliX
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for PauliX
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for PauliY
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for PauliZ
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for PhaseShiftState0
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for PhaseShiftState1
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for RotateAroundSphericalAxis
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for RotateX
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for RotateY
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for RotateZ
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for SGate
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for SingleQubitGate
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for SqrtPauliX
Trait for unitary operations acting on exactly one qubit.
impl OperateSingleQubitGate for TGate
Trait for unitary operations acting on exactly one qubit.