pub enum MixedPrecisionStateVector {
Half(Array1<Complex32>),
Single(Array1<Complex32>),
Double(Array1<Complex64>),
Adaptive {
primary: Box<MixedPrecisionStateVector>,
secondary: Option<Box<MixedPrecisionStateVector>>,
precision_map: Vec<QuantumPrecision>,
},
}
Expand description
Mixed-precision state vector
Variants§
Half(Array1<Complex32>)
Half precision state vector (using Complex32 as approximation)
Single(Array1<Complex32>)
Single precision state vector
Double(Array1<Complex64>)
Double precision state vector
Adaptive
Adaptive precision with multiple representations
Fields
§
primary: Box<MixedPrecisionStateVector>
§
secondary: Option<Box<MixedPrecisionStateVector>>
§
precision_map: Vec<QuantumPrecision>
Implementations§
Source§impl MixedPrecisionStateVector
impl MixedPrecisionStateVector
Sourcepub fn new(size: usize, precision: QuantumPrecision) -> Self
pub fn new(size: usize, precision: QuantumPrecision) -> Self
Create a new state vector with the specified precision
Sourcepub fn computational_basis(
num_qubits: usize,
precision: QuantumPrecision,
) -> Self
pub fn computational_basis( num_qubits: usize, precision: QuantumPrecision, ) -> Self
Create a computational basis state |0…0>
Sourcepub fn precision(&self) -> QuantumPrecision
pub fn precision(&self) -> QuantumPrecision
Get the current precision of the state vector
Sourcepub fn to_precision(&self, target_precision: QuantumPrecision) -> Result<Self>
pub fn to_precision(&self, target_precision: QuantumPrecision) -> Result<Self>
Convert to a specific precision
Sourcepub fn probability(&self, index: usize) -> Result<f64>
pub fn probability(&self, index: usize) -> Result<f64>
Calculate probability of measuring a specific state
Sourcepub fn amplitude(&self, index: usize) -> Result<Complex64>
pub fn amplitude(&self, index: usize) -> Result<Complex64>
Get amplitude at a specific index as Complex64
Sourcepub fn set_amplitude(
&mut self,
index: usize,
amplitude: Complex64,
) -> Result<()>
pub fn set_amplitude( &mut self, index: usize, amplitude: Complex64, ) -> Result<()>
Set amplitude at a specific index
Sourcepub fn fidelity(&self, other: &Self) -> Result<f64>
pub fn fidelity(&self, other: &Self) -> Result<f64>
Calculate fidelity with another state vector
Sourcepub fn clone_to_precision(&self, precision: QuantumPrecision) -> Result<Self>
pub fn clone_to_precision(&self, precision: QuantumPrecision) -> Result<Self>
Clone the state vector to a specific precision
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimate memory usage in bytes
Sourcepub fn is_normalized(&self, tolerance: f64) -> bool
pub fn is_normalized(&self, tolerance: f64) -> bool
Check if the state vector is normalized (within tolerance)
Sourcepub fn num_qubits(&self) -> usize
pub fn num_qubits(&self) -> usize
Get the number of qubits this state vector represents
Trait Implementations§
Source§impl Clone for MixedPrecisionStateVector
impl Clone for MixedPrecisionStateVector
Auto Trait Implementations§
impl Freeze for MixedPrecisionStateVector
impl RefUnwindSafe for MixedPrecisionStateVector
impl Send for MixedPrecisionStateVector
impl Sync for MixedPrecisionStateVector
impl Unpin for MixedPrecisionStateVector
impl UnwindSafe for MixedPrecisionStateVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.