pub struct SinkhornSolver { /* private fields */ }Expand description
Log-stabilized Sinkhorn solver for entropic optimal transport
Implementations§
Source§impl SinkhornSolver
impl SinkhornSolver
Sourcepub fn new(regularization: f64, max_iterations: usize) -> Self
pub fn new(regularization: f64, max_iterations: usize) -> Self
Create a new Sinkhorn solver
§Arguments
regularization- Entropy regularization ε (0.01-0.1 typical)max_iterations- Maximum Sinkhorn iterations (100-1000 typical)
Sourcepub fn with_threshold(self, threshold: f64) -> Self
pub fn with_threshold(self, threshold: f64) -> Self
Set convergence threshold
Sourcepub fn compute_cost_matrix(
source: &[Vec<f64>],
target: &[Vec<f64>],
) -> Vec<Vec<f64>>
pub fn compute_cost_matrix( source: &[Vec<f64>], target: &[Vec<f64>], ) -> Vec<Vec<f64>>
Compute the cost matrix for squared Euclidean distance Uses SIMD-friendly 4-way unrolled accumulator for better performance
Sourcepub fn solve(
&self,
cost_matrix: &[Vec<f64>],
source_weights: &[f64],
target_weights: &[f64],
) -> Result<TransportPlan>
pub fn solve( &self, cost_matrix: &[Vec<f64>], source_weights: &[f64], target_weights: &[f64], ) -> Result<TransportPlan>
Solve optimal transport using log-stabilized Sinkhorn
§Arguments
cost_matrix- C[i,j] = cost to move from source[i] to target[j]source_weights- Marginal distribution a (sum to 1)target_weights- Marginal distribution b (sum to 1)
Trait Implementations§
Source§impl Clone for SinkhornSolver
impl Clone for SinkhornSolver
Source§fn clone(&self) -> SinkhornSolver
fn clone(&self) -> SinkhornSolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SinkhornSolver
impl RefUnwindSafe for SinkhornSolver
impl Send for SinkhornSolver
impl Sync for SinkhornSolver
impl Unpin for SinkhornSolver
impl UnwindSafe for SinkhornSolver
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