pub struct BatchKernelComputer { /* private fields */ }Expand description
Batch kernel matrix computation engine.
Computes the full n x n kernel matrix for a batch of n input vectors, exploiting symmetry (only computing the upper triangle) and optionally caching results for repeated computations.
Implementations§
Source§impl BatchKernelComputer
impl BatchKernelComputer
Sourcepub fn with_cache(capacity: usize) -> Self
pub fn with_cache(capacity: usize) -> Self
Create a new batch computer with an LRU cache of the given capacity.
Sourcepub fn compute<F>(
&mut self,
inputs: &[Vec<f64>],
kernel_fn: F,
) -> Result<(GramMatrix, KernelMatrixStats)>
pub fn compute<F>( &mut self, inputs: &[Vec<f64>], kernel_fn: F, ) -> Result<(GramMatrix, KernelMatrixStats)>
Compute the full kernel matrix for a batch of input vectors.
The kernel function kernel_fn takes two vectors (as slices) and returns
the kernel value. The resulting matrix is symmetric: K[i,j] = K[j,i].
§Errors
Returns BatchKernelError::EmptyBatch if inputs is empty.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the internal cache (no-op if caching is disabled).
Sourcepub fn cache_hit_rate(&self) -> Option<f64>
pub fn cache_hit_rate(&self) -> Option<f64>
Return cache statistics, if caching is enabled.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BatchKernelComputer
impl RefUnwindSafe for BatchKernelComputer
impl Send for BatchKernelComputer
impl Sync for BatchKernelComputer
impl Unpin for BatchKernelComputer
impl UnsafeUnpin for BatchKernelComputer
impl UnwindSafe for BatchKernelComputer
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> 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 more