State

Type Alias State 

Source
pub type State = QubitSized<StateData>;
Expand description

The state of a quantum system.

Aliased Type§

pub struct State { /* private fields */ }

Implementations§

Source§

impl State

Source

pub fn new_mixed(n_qubits: usize) -> State

Returns a new mixed state on a given number of qubits. By convention, new mixed states start off in the “all-zeros” state, $\rho = \ket{00\cdots 0}\bra{00\cdots 0}$.

Source

pub fn new_stabilizer(n_qubits: usize) -> State

Returns a new stabilizer state on a given number of qubits. By convention, new stabilizer states start off in the “all-zeros” state, $\left\langle Z_0, Z_1, \dots, Z_{n - 1} \right\rangle$.

Source

pub fn new_pure(n_qubits: usize) -> State

Returns a new pure state on a given number of qubits. By convention, new pure states start off in the “all-zeros” state, $\ket{\psi} = \ket{00\cdots 0}$.

Source

pub fn as_json(&self) -> String

Returns a serialization of this quantum state as a JSON object.

Source

pub fn extend(&self, n_qubits: usize) -> State

Extends this state to be a state on n_qubits additional qubits. New qubits are added “to the right,” e.g.: $\left|\psi\right\rangle$ is extended to $\left|\psi 0\right\rangle$.

§Example
let rho = State::new_mixed(2);
assert_eq!(5, rho.extend(3).get_n_qubits());
Source

pub fn to_mixed(&self) -> State

Returns a copy of this state, represented as a mixed state.

Source

pub fn get_tableau(&self) -> Option<&Tableau>

If the given state can be represented by a stabilizer tableau, returns that tableau.

Trait Implementations§

Source§

impl Display for State

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Trace for &State

Source§

type Output = Complex<f64>

The type returned by the trace.
Source§

fn trace(self) -> Self::Output

The trace (typically, the sum of the eigenvalues, or the sum of the diagonal elements $\sum_i A_{ii}$). Read more