pub trait ChainableState {
Show 49 methods
// Required methods
fn h(self, index: usize) -> Result<State, Error>;
fn h_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn ch_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn x(self, index: usize) -> Result<State, Error>;
fn x_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn cx_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn y(self, index: usize) -> Result<State, Error>;
fn y_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn cy_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn z(self, index: usize) -> Result<State, Error>;
fn z_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn cz_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn i(self, qubit: usize) -> Result<State, Error>;
fn i_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn ci_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn s(self, index: usize) -> Result<State, Error>;
fn s_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn cs_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn t(self, index: usize) -> Result<State, Error>;
fn t_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn ct_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn s_dag(self, index: usize) -> Result<State, Error>;
fn s_dag_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn cs_dag_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn t_dag(self, index: usize) -> Result<State, Error>;
fn t_dag_multi(self, qubits: &[usize]) -> Result<State, Error>;
fn ct_dag_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn p(self, index: usize, angle: f64) -> Result<State, Error>;
fn p_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>;
fn cp_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>;
fn rx(self, index: usize, angle: f64) -> Result<State, Error>;
fn rx_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>;
fn crx_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>;
fn ry(self, index: usize, angle: f64) -> Result<State, Error>;
fn ry_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>;
fn cry_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>;
fn rz(self, index: usize, angle: f64) -> Result<State, Error>;
fn rz_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>;
fn crz_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>;
fn unitary(
self,
index: usize,
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>;
fn unitary_multi(
self,
qubits: &[usize],
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>;
fn cunitary_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>;
fn cnot(self, control: usize, target: usize) -> Result<State, Error>;
fn swap(self, qubit1: usize, qubit2: usize) -> Result<State, Error>;
fn cswap(
self,
target1: usize,
target2: usize,
controls: &[usize],
) -> Result<State, Error>;
fn toffoli(
self,
control1: usize,
control2: usize,
target: usize,
) -> Result<State, Error>;
fn operate(
self,
unitary: impl Operator,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>;
fn measure(
self,
basis: MeasurementBasis,
measured_qubits: &[usize],
) -> Result<MeasurementResult, Error>;
fn measure_n(
self,
basis: MeasurementBasis,
measured_qubits: &[usize],
n: usize,
) -> Result<Vec<MeasurementResult>, Error>;
}Expand description
A trait to enable chainable operations on Result<State, Error>
Required Methods§
Sourcefn h(self, index: usize) -> Result<State, Error>
fn h(self, index: usize) -> Result<State, Error>
Applies the Hadamard gate to the specified qubit in the state vector.
Sourcefn h_multi(self, qubits: &[usize]) -> Result<State, Error>
fn h_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Hadamard gate to the specified qubits in the state vector in the given order.
Sourcefn ch_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn ch_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Hadamard gate to the specified qubits in the state vector in the given order.
Sourcefn x(self, index: usize) -> Result<State, Error>
fn x(self, index: usize) -> Result<State, Error>
Applies the Pauli-X (NOT) gate to the specified qubit in the state vector.
Sourcefn x_multi(self, qubits: &[usize]) -> Result<State, Error>
fn x_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Pauli-X (NOT) gate to the specified qubits in the state vector in the given order.
Sourcefn cx_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn cx_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Pauli-X (NOT) gate to the specified qubits in the state vector in the given order.
Sourcefn y(self, index: usize) -> Result<State, Error>
fn y(self, index: usize) -> Result<State, Error>
Applies the Pauli-Y gate to the specified qubit in the state vector.
Sourcefn y_multi(self, qubits: &[usize]) -> Result<State, Error>
fn y_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Pauli-Y gate to the specified qubits in the state vector in the given order.
Sourcefn cy_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn cy_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Pauli-Y gate to the specified qubits in the state vector in the given order.
Sourcefn z(self, index: usize) -> Result<State, Error>
fn z(self, index: usize) -> Result<State, Error>
Applies the Pauli-Z gate to the specified qubit in the state vector.
Sourcefn z_multi(self, qubits: &[usize]) -> Result<State, Error>
fn z_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Pauli-Z gate to the specified qubits in the state vector in the given order.
Sourcefn cz_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn cz_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Pauli-Z gate to the specified qubits in the state vector in the given order.
Sourcefn i(self, qubit: usize) -> Result<State, Error>
fn i(self, qubit: usize) -> Result<State, Error>
Applies the Identity gate to the state vector.
Sourcefn i_multi(self, qubits: &[usize]) -> Result<State, Error>
fn i_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Identity gate to the state vector for multiple qubits in the given order.
Sourcefn ci_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn ci_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Identity gate to the state vector for multiple qubits in the given order.
Sourcefn s(self, index: usize) -> Result<State, Error>
fn s(self, index: usize) -> Result<State, Error>
Applies the Phase S gate to the specified qubit in the state vector.
Sourcefn s_multi(self, qubits: &[usize]) -> Result<State, Error>
fn s_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Phase S gate to the specified qubits in the state vector in the given order.
Sourcefn cs_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn cs_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Phase S gate to the specified qubits in the state vector in the given order.
Sourcefn t(self, index: usize) -> Result<State, Error>
fn t(self, index: usize) -> Result<State, Error>
Applies the Phase T gate to the specified qubit in the state vector.
Sourcefn t_multi(self, qubits: &[usize]) -> Result<State, Error>
fn t_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Phase T gate to the specified qubits in the state vector in the given order.
Sourcefn ct_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn ct_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Phase T gate to the specified qubits in the state vector in the given order.
Sourcefn s_dag(self, index: usize) -> Result<State, Error>
fn s_dag(self, index: usize) -> Result<State, Error>
Applies the Phase S dagger gate to the specified qubit in the state vector.
Sourcefn s_dag_multi(self, qubits: &[usize]) -> Result<State, Error>
fn s_dag_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Phase S dagger gate to the specified qubits in the state vector in the given order.
Sourcefn cs_dag_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn cs_dag_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Phase S dagger gate to the specified qubits in the state vector in the given order.
Sourcefn t_dag(self, index: usize) -> Result<State, Error>
fn t_dag(self, index: usize) -> Result<State, Error>
Applies the Phase T dagger gate to the specified qubit in the state vector.
Sourcefn t_dag_multi(self, qubits: &[usize]) -> Result<State, Error>
fn t_dag_multi(self, qubits: &[usize]) -> Result<State, Error>
Applies the Phase T dagger gate to the specified qubits in the state vector in the given order.
Sourcefn ct_dag_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn ct_dag_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies the controlled Phase T dagger gate to the specified qubits in the state vector in the given order.
Sourcefn p(self, index: usize, angle: f64) -> Result<State, Error>
fn p(self, index: usize, angle: f64) -> Result<State, Error>
Applies the Phase Shift gate with the specified angle to the given qubit.
Sourcefn p_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
fn p_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
Applies the Phase Shift gate with the specified angle to the given qubits in order.
Sourcefn cp_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>
fn cp_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>
Applies the controlled Phase Shift gate with the specified angle to the given qubits in order.
Sourcefn rx(self, index: usize, angle: f64) -> Result<State, Error>
fn rx(self, index: usize, angle: f64) -> Result<State, Error>
Applies the RotateX gate with the specified angle to the given qubit.
Sourcefn rx_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
fn rx_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
Applies the RotateX gate with the specified angle to the given qubits in order.
Sourcefn crx_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>
fn crx_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>
Applies the controlled RotateX gate with the specified angle to the given qubits in order.
Sourcefn ry(self, index: usize, angle: f64) -> Result<State, Error>
fn ry(self, index: usize, angle: f64) -> Result<State, Error>
Applies the RotateY gate with the specified angle to the given qubit.
Sourcefn ry_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
fn ry_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
Applies the RotateY gate with the specified angle to the given qubits in order.
Sourcefn cry_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>
fn cry_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>
Applies the controlled RotateY gate with the specified angle to the given qubits in order.
Sourcefn rz(self, index: usize, angle: f64) -> Result<State, Error>
fn rz(self, index: usize, angle: f64) -> Result<State, Error>
Applies the RotateZ gate with the specified angle to the given qubit.
Sourcefn rz_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
fn rz_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>
Applies the RotateZ gate with the specified angle to the given qubits in order.
Sourcefn crz_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
angle: f64,
) -> Result<State, Error>
fn crz_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>
Applies the controlled RotateZ gate with the specified angle to the given qubits in order.
Sourcefn unitary(
self,
index: usize,
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>
fn unitary( self, index: usize, unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>
Applies the unitary gate to the specified qubit in the state vector.
Sourcefn unitary_multi(
self,
qubits: &[usize],
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>
fn unitary_multi( self, qubits: &[usize], unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>
Applies the unitary gate to the specified qubits in the state vector in the given order.
Sourcefn cunitary_multi(
self,
target_qubits: &[usize],
control_qubits: &[usize],
unitary: [[Complex<f64>; 2]; 2],
) -> Result<State, Error>
fn cunitary_multi( self, target_qubits: &[usize], control_qubits: &[usize], unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>
Applies the controlled unitary gate to the specified qubits in the state vector in the given order.
Sourcefn cnot(self, control: usize, target: usize) -> Result<State, Error>
fn cnot(self, control: usize, target: usize) -> Result<State, Error>
Applies the CNOT (Controlled-NOT) gate to the state vector.
Sourcefn swap(self, qubit1: usize, qubit2: usize) -> Result<State, Error>
fn swap(self, qubit1: usize, qubit2: usize) -> Result<State, Error>
Applies the SWAP gate to the state vector.
Sourcefn cswap(
self,
target1: usize,
target2: usize,
controls: &[usize],
) -> Result<State, Error>
fn cswap( self, target1: usize, target2: usize, controls: &[usize], ) -> Result<State, Error>
Applies the controlled SWAP gate to the state vector.
Sourcefn toffoli(
self,
control1: usize,
control2: usize,
target: usize,
) -> Result<State, Error>
fn toffoli( self, control1: usize, control2: usize, target: usize, ) -> Result<State, Error>
Applies the Toffoli (Controlled-Controlled-NOT) gate to the state vector.
Sourcefn operate(
self,
unitary: impl Operator,
target_qubits: &[usize],
control_qubits: &[usize],
) -> Result<State, Error>
fn operate( self, unitary: impl Operator, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>
Applies a unitary operation to the state vector.
Sourcefn measure(
self,
basis: MeasurementBasis,
measured_qubits: &[usize],
) -> Result<MeasurementResult, Error>
fn measure( self, basis: MeasurementBasis, measured_qubits: &[usize], ) -> Result<MeasurementResult, Error>
Measures the state vector in the specified basis and returns the measurement result.
Sourcefn measure_n(
self,
basis: MeasurementBasis,
measured_qubits: &[usize],
n: usize,
) -> Result<Vec<MeasurementResult>, Error>
fn measure_n( self, basis: MeasurementBasis, measured_qubits: &[usize], n: usize, ) -> Result<Vec<MeasurementResult>, Error>
Measures the state vector n times in the specified basis and returns the measurement results.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.