pub struct MatrixProductState { /* private fields */ }Expand description
Matrix Product State representation of an n-qubit pure state.
Implementations§
Source§impl MatrixProductState
impl MatrixProductState
Sourcepub fn new_zero_state(config: MpsConfig) -> QuantumResult<Self>
pub fn new_zero_state(config: MpsConfig) -> QuantumResult<Self>
Build the product state |0…0⟩ with all bond dimensions equal to 1.
Sourcepub fn bond_dims(&self) -> Vec<usize>
pub fn bond_dims(&self) -> Vec<usize>
The right-bond dimension of each site (one entry per site).
bond_dims()[k] is the dimension of the bond between site k and
site k+1; the final entry is the right boundary bond (always 1).
Sourcepub fn apply_1q(
&mut self,
gate: &[[Complex<f32>; 2]; 2],
qubit: usize,
) -> QuantumResult<()>
pub fn apply_1q( &mut self, gate: &[[Complex<f32>; 2]; 2], qubit: usize, ) -> QuantumResult<()>
Apply a 1-qubit gate to qubit, contracting it into the physical index.
This leaves both bond dimensions unchanged.
Sourcepub fn apply_2q(
&mut self,
gate: &[[Complex<f32>; 4]; 4],
q: usize,
q_plus_1: usize,
) -> QuantumResult<()>
pub fn apply_2q( &mut self, gate: &[[Complex<f32>; 4]; 4], q: usize, q_plus_1: usize, ) -> QuantumResult<()>
Apply a 4×4 two-qubit gate to adjacent qubits q and q+1.
The gate is indexed in the basis |q, q+1⟩ with q the more-significant
of the two physical indices, i.e. the matrix row/column index is
2 * bit(q) + bit(q+1) — matching
apply_2q_inplace.
§Errors
Returns an error if the qubits are not adjacent with q_plus_1 == q + 1,
or if either index is out of range.
Sourcepub fn to_statevector(&self) -> QuantumResult<StateVector>
pub fn to_statevector(&self) -> QuantumResult<StateVector>
Contract the whole chain into a dense 2^n StateVector.
Intended for verification on small systems; cost is exponential in n.
Sourcepub fn expectation_z(&self, qubit: usize) -> QuantumResult<f32>
pub fn expectation_z(&self, qubit: usize) -> QuantumResult<f32>
Expectation value ⟨ψ| Z_qubit |ψ⟩.
Trait Implementations§
Source§impl Clone for MatrixProductState
impl Clone for MatrixProductState
Source§fn clone(&self) -> MatrixProductState
fn clone(&self) -> MatrixProductState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more