[][src]Trait q1tsim::gates::Gate

pub trait Gate {
    fn description(&self) -> &str;
fn nr_affected_bits(&self) -> usize;
fn matrix(&self) -> CMatrix; fn cost(&self) -> f64 { ... }
fn apply(&self, state: &mut CVector) { ... }
fn apply_mat(&self, state: &mut CMatrix) { ... }
fn apply_slice(&self, state: CVecSliceMut) { ... }
fn apply_mat_slice(&self, state: CMatSliceMut) { ... }
fn check_nr_bits(&self, n: usize) -> Result<()> { ... }
fn is_stabilizer(&self) -> bool { ... }
fn conjugate(&self, _ops: &mut [PauliOp]) -> Result<bool> { ... } }

Required methods

fn description(&self) -> &str

Return a short description of the gate. This may be the name of the gate (e.g. "H", "CX"), or the way the gate was constructed (like "I⊗Z")

fn nr_affected_bits(&self) -> usize

The number of qubits affected by this gate.

fn matrix(&self) -> CMatrix

Return a matrix describing the unitary transformation that the gate provides

Loading content...

Provided methods

fn cost(&self) -> f64

Cost of this gate.

An estimate of the cost of using this gate. This can be used e.g. in optimizing circuits, or when trying to decompose a transformation in an optimal gate sequence. The default implementation returns std::f64::INFINITY.

fn apply(&self, state: &mut CVector)

Apply a gate.

Apply a gate to quantum state state. The number of rows r in state must be a multiple of 2n, where n is the number of qubits this gate acts upon. The rows must be ordered, such that the first block of r/2n rows corresponds to qustates with basis states |00...0⟩ for the affected qubits, the second block to |00...1⟩, etc., up until |11...1⟩.

fn apply_mat(&self, state: &mut CMatrix)

Apply a gate.

Apply a gate to quantum state state. The number of rows r in state must be a multiple of 2n, where n is the number of qubits this gate acts upon. The rows must be ordered, such that the first block of r/2n rows corresponds to qustates with basis states |00...0⟩ for the affected qubits, the second block to |00...1⟩, etc., up until |11...1⟩.

fn apply_slice(&self, state: CVecSliceMut)

Apply a gate.

Apply a gate to quantum state state. The number of rows r in state must be a multiple of 2n, where n is the number of qubits this gate acts upon. The rows must be ordered, such that the first block of r/2n rows corresponds to qustates with basis states |00...0⟩ for the affected qubits, the second block to |00...1⟩, etc., up until |11...1⟩.

fn apply_mat_slice(&self, state: CMatSliceMut)

Apply a gate.

Apply a gate to quantum state state. The number of rows r in state must be a multiple of 2n, where n is the number of qubits this gate acts upon. The rows must be ordered, such that the first block of r/2n rows corresponds to qustates with basis states |00...0⟩ for the affected qubits, the second block to |00...1⟩, etc., up until |11...1⟩.

fn check_nr_bits(&self, n: usize) -> Result<()>

Check the number of bits

Check if the number of bit indices n is equal to the number of bits this gate operates on. If not, return an InvalidNrBits error.

fn is_stabilizer(&self) -> bool

Whether this gate is a stabilizer gate

Return true if this gate is a stabilizer gate, i.e. if conjugating a Pauli operator (or tensor product thereof for multi-bit gates) with this gate, again returns a Pauli operator. Circuits consisting of only these types of gates can be simulated more efficiently. The default implementation returns false.

fn conjugate(&self, _ops: &mut [PauliOp]) -> Result<bool>

Conjugate Pauli operators

Conjugate the (tensor product of) Pauli operator ops with this gate, and return the sign of the resulting operator. I.e., if this gate is called G, replace the operator O described by ops with GOG. This of course only works if the result can be expressed in Pauli operators, so only if this gate can be written in terms of H, S and CX gates. The default implementation of this function returns a NotAStabilizer error.

Loading content...

Implementors

impl Gate for CCRX[src]

impl Gate for CCRY[src]

impl Gate for CCRZ[src]

impl Gate for CCX[src]

impl Gate for CCZ[src]

impl Gate for CH[src]

impl Gate for CRX[src]

impl Gate for CRY[src]

impl Gate for CRZ[src]

impl Gate for CS[src]

impl Gate for CSdg[src]

impl Gate for CT[src]

impl Gate for CTdg[src]

impl Gate for CU1[src]

impl Gate for CU2[src]

impl Gate for CU3[src]

impl Gate for CV[src]

impl Gate for CVdg[src]

impl Gate for CX[src]

impl Gate for CY[src]

impl Gate for CZ[src]

impl Gate for Composite[src]

impl Gate for H[src]

impl Gate for I[src]

impl Gate for Loop[src]

impl Gate for RX[src]

impl Gate for RY[src]

impl Gate for RZ[src]

impl Gate for S[src]

impl Gate for Sdg[src]

impl Gate for Swap[src]

impl Gate for T[src]

impl Gate for Tdg[src]

impl Gate for U1[src]

impl Gate for U2[src]

impl Gate for U3[src]

impl Gate for V[src]

impl Gate for Vdg[src]

impl Gate for X[src]

impl Gate for Y[src]

impl Gate for Z[src]

impl<G> Gate for C<G> where
    G: Gate
[src]

impl<G0, G1> Gate for Kron<G0, G1> where
    G0: Gate,
    G1: Gate
[src]

Loading content...