pub struct ReversibleVSAEncoder { /* private fields */ }Expand description
Reversible encoder using position-aware VSA binding
Implementations§
Source§impl ReversibleVSAEncoder
impl ReversibleVSAEncoder
Sourcepub fn encode(&mut self, data: &[u8]) -> SparseVec
pub fn encode(&mut self, data: &[u8]) -> SparseVec
Encode data into a holographic representation
Returns a single SparseVec that contains all the data holographically.
Sourcepub fn encode_chunked(
&mut self,
data: &[u8],
chunk_size: usize,
) -> Vec<SparseVec>
pub fn encode_chunked( &mut self, data: &[u8], chunk_size: usize, ) -> Vec<SparseVec>
Encode data in chunks for better accuracy with large files
Returns a vector of SparseVecs, one per chunk.
§Panics
Panics if chunk_size is 0.
Sourcepub fn decode(&self, encoded: &SparseVec, length: usize) -> Vec<u8> ⓘ
pub fn decode(&self, encoded: &SparseVec, length: usize) -> Vec<u8> ⓘ
Decode data from a holographic representation
Uses bind + similarity search to retrieve each byte.
Sourcepub fn decode_chunked(
&self,
chunks: &[SparseVec],
chunk_size: usize,
total_length: usize,
) -> Vec<u8> ⓘ
pub fn decode_chunked( &self, chunks: &[SparseVec], chunk_size: usize, total_length: usize, ) -> Vec<u8> ⓘ
Sourcepub fn get_byte_vectors(&self) -> &[SparseVec]
pub fn get_byte_vectors(&self) -> &[SparseVec]
Get reference to byte vectors (for GPU acceleration)
Returns slice of 256 basis vectors, one per byte value.
Sourcepub fn get_position_vector_ref(&self, pos: usize) -> &SparseVec
pub fn get_position_vector_ref(&self, pos: usize) -> &SparseVec
Get position vector for a given position (for GPU acceleration)
Returns reference to position basis vector. Uses modulo if position exceeds pre-allocated vectors.
Note: Call ensure_positions(max_pos) first if you need exact position
vectors without modulo wrapping.
Sourcepub fn ensure_positions(&mut self, max_pos: usize)
pub fn ensure_positions(&mut self, max_pos: usize)
Sourcepub fn try_ensure_positions(&mut self, max_pos: usize) -> Result<(), String>
pub fn try_ensure_positions(&mut self, max_pos: usize) -> Result<(), String>
Ensure position vectors exist up to the given position, returning error on invalid input
This is a non-panicking alternative to ensure_positions.
§Returns
Returns Ok(()) if positions are allocated successfully, or Err if
max_pos >= MAX_POSITIONS.
Sourcepub fn test_accuracy(&mut self, data: &[u8]) -> f64
pub fn test_accuracy(&mut self, data: &[u8]) -> f64
Compute reconstruction accuracy (for testing)
Sourcepub fn test_accuracy_chunked(&mut self, data: &[u8], chunk_size: usize) -> f64
pub fn test_accuracy_chunked(&mut self, data: &[u8], chunk_size: usize) -> f64
Compute chunked reconstruction accuracy