[−][src]Trait q1tsim::gates::Gate
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
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.
Implementors
impl Gate for CCRX
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CCRY
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CCRZ
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CCX
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CCZ
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CH
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CRX
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CRY
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CRZ
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CS
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CSdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CT
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CTdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CU1
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CU2
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CU3
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CV
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CVdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for CX
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for CY
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for CZ
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Composite
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for H
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for I
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, _state: CVecSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, _ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Loop
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for RX
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for RY
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for RZ
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for S
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Sdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Swap
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for T
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for Tdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl Gate for U1
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
impl Gate for U2
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
impl Gate for U3
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
impl Gate for V
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Vdg
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for X
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Y
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl Gate for Z
[src]
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
fn is_stabilizer(&self) -> bool
[src]
fn conjugate(&self, ops: &mut [PauliOp]) -> Result<bool>
[src]
impl<G> Gate for C<G> where
G: Gate,
[src]
G: Gate,
fn cost(&self) -> f64
[src]
fn description(&self) -> &str
[src]
fn nr_affected_bits(&self) -> usize
[src]
fn matrix(&self) -> CMatrix
[src]
fn apply_slice(&self, state: CVecSliceMut)
[src]
fn apply_mat_slice(&self, state: CMatSliceMut)
[src]
impl<G0, G1> Gate for Kron<G0, G1> where
G0: Gate,
G1: Gate,
[src]
G0: Gate,
G1: Gate,