pub struct Embedding {
pub data: Vec<f32>,
pub dim: usize,
/* private fields */
}Expand description
A dense vector embedding
Fields§
§data: Vec<f32>The vector data
dim: usizeDimensionality
Implementations§
Source§impl Embedding
impl Embedding
Sourcepub fn normalized(&self) -> Self
pub fn normalized(&self) -> Self
Get a normalized copy
Source§impl Embedding
impl Embedding
Sourcepub fn to_amplitude_encoding(&self) -> Self
pub fn to_amplitude_encoding(&self) -> Self
Convert to amplitude encoding (normalize to unit vector for quantum state) This prepares the embedding for use as quantum state amplitudes
Sourcepub fn from_complex_amplitudes(amplitudes: &[Complex64]) -> Self
pub fn from_complex_amplitudes(amplitudes: &[Complex64]) -> Self
Create embedding from quantum state amplitudes (complex → real) Takes the real parts of complex amplitudes
Sourcepub fn from_probabilities(probs: &[f64]) -> Self
pub fn from_probabilities(probs: &[f64]) -> Self
Create embedding from quantum state probability distribution Each element is sqrt(probability) to preserve amplitude structure
Sourcepub fn fidelity(&self, other: &Embedding) -> f32
pub fn fidelity(&self, other: &Embedding) -> f32
Compute quantum fidelity with another embedding Treats both as normalized quantum state amplitudes Returns |⟨ψ|φ⟩|² ∈ [0, 1]
Sourcepub fn trace_distance(&self, other: &Embedding) -> f32
pub fn trace_distance(&self, other: &Embedding) -> f32
Compute trace distance (quantum distinguishability) Returns value in [0, 1], where 0 = identical, 1 = orthogonal
Sourcepub fn quantize_binary(&self) -> Self
pub fn quantize_binary(&self) -> Self
Quantize embedding to binary (for Hamming distance)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Embedding
impl<'de> Deserialize<'de> for Embedding
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Embedding
impl RefUnwindSafe for Embedding
impl Send for Embedding
impl Sync for Embedding
impl Unpin for Embedding
impl UnwindSafe for Embedding
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