Trait ChainableState

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

Source

fn h(self, index: usize) -> Result<State, Error>

Applies the Hadamard gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn x(self, index: usize) -> Result<State, Error>

Applies the Pauli-X (NOT) gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn y(self, index: usize) -> Result<State, Error>

Applies the Pauli-Y gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn z(self, index: usize) -> Result<State, Error>

Applies the Pauli-Z gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn i(self, qubit: usize) -> Result<State, Error>

Applies the Identity gate to the state vector.

Source

fn i_multi(self, qubits: &[usize]) -> Result<State, Error>

Applies the Identity gate to the state vector for multiple qubits in the given order.

Source

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.

Source

fn s(self, index: usize) -> Result<State, Error>

Applies the Phase S gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn t(self, index: usize) -> Result<State, Error>

Applies the Phase T gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn s_dag(self, index: usize) -> Result<State, Error>

Applies the Phase S dagger gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn t_dag(self, index: usize) -> Result<State, Error>

Applies the Phase T dagger gate to the specified qubit in the state vector.

Source

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.

Source

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.

Source

fn p(self, index: usize, angle: f64) -> Result<State, Error>

Applies the Phase Shift gate with the specified angle to the given qubit.

Source

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.

Source

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.

Source

fn rx(self, index: usize, angle: f64) -> Result<State, Error>

Applies the RotateX gate with the specified angle to the given qubit.

Source

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.

Source

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.

Source

fn ry(self, index: usize, angle: f64) -> Result<State, Error>

Applies the RotateY gate with the specified angle to the given qubit.

Source

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.

Source

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.

Source

fn rz(self, index: usize, angle: f64) -> Result<State, Error>

Applies the RotateZ gate with the specified angle to the given qubit.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn cnot(self, control: usize, target: usize) -> Result<State, Error>

Applies the CNOT (Controlled-NOT) gate to the state vector.

Source

fn swap(self, qubit1: usize, qubit2: usize) -> Result<State, Error>

Applies the SWAP gate to the state vector.

Source

fn cswap( self, target1: usize, target2: usize, controls: &[usize], ) -> Result<State, Error>

Applies the controlled SWAP gate to the state vector.

Source

fn toffoli( self, control1: usize, control2: usize, target: usize, ) -> Result<State, Error>

Applies the Toffoli (Controlled-Controlled-NOT) gate to the state vector.

Source

fn operate( self, unitary: impl Operator, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Applies a unitary operation to the state vector.

Source

fn measure( self, basis: MeasurementBasis, measured_qubits: &[usize], ) -> Result<MeasurementResult, Error>

Measures the state vector in the specified basis and returns the measurement result.

Source

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.

Implementations on Foreign Types§

Source§

impl ChainableState for Result<State, Error>

Source§

fn h(self, index: usize) -> Result<State, Error>

Source§

fn h_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn ch_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn x(self, index: usize) -> Result<State, Error>

Source§

fn x_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn cx_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn y(self, index: usize) -> Result<State, Error>

Source§

fn y_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn cy_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn z(self, index: usize) -> Result<State, Error>

Source§

fn z_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn cz_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn i(self, qubit: usize) -> Result<State, Error>

Source§

fn i_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn ci_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn s(self, index: usize) -> Result<State, Error>

Source§

fn s_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn cs_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn t(self, index: usize) -> Result<State, Error>

Source§

fn t_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn ct_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn s_dag(self, index: usize) -> Result<State, Error>

Source§

fn s_dag_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn cs_dag_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn t_dag(self, index: usize) -> Result<State, Error>

Source§

fn t_dag_multi(self, qubits: &[usize]) -> Result<State, Error>

Source§

fn ct_dag_multi( self, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn p(self, index: usize, angle: f64) -> Result<State, Error>

Source§

fn p_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>

Source§

fn cp_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>

Source§

fn rx(self, index: usize, angle: f64) -> Result<State, Error>

Source§

fn rx_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>

Source§

fn crx_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>

Source§

fn ry(self, index: usize, angle: f64) -> Result<State, Error>

Source§

fn ry_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>

Source§

fn cry_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>

Source§

fn rz(self, index: usize, angle: f64) -> Result<State, Error>

Source§

fn rz_multi(self, qubits: &[usize], angle: f64) -> Result<State, Error>

Source§

fn crz_multi( self, target_qubits: &[usize], control_qubits: &[usize], angle: f64, ) -> Result<State, Error>

Source§

fn unitary( self, index: usize, unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>

Source§

fn unitary_multi( self, qubits: &[usize], unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>

Source§

fn cunitary_multi( self, target_qubits: &[usize], control_qubits: &[usize], unitary: [[Complex<f64>; 2]; 2], ) -> Result<State, Error>

Source§

fn cnot(self, control: usize, target: usize) -> Result<State, Error>

Source§

fn swap(self, qubit1: usize, qubit2: usize) -> Result<State, Error>

Source§

fn cswap( self, target1: usize, target2: usize, controls: &[usize], ) -> Result<State, Error>

Source§

fn toffoli( self, control1: usize, control2: usize, target: usize, ) -> Result<State, Error>

Source§

fn operate( self, unitary: impl Operator, target_qubits: &[usize], control_qubits: &[usize], ) -> Result<State, Error>

Source§

fn measure( self, basis: MeasurementBasis, measured_qubits: &[usize], ) -> Result<MeasurementResult, Error>

Source§

fn measure_n( self, basis: MeasurementBasis, measured_qubits: &[usize], n: usize, ) -> Result<Vec<MeasurementResult>, Error>

Implementors§