pub struct IrlbaConfig {
pub rank: usize,
pub work: Option<usize>,
pub tol: f64,
pub max_restarts: usize,
pub seed: Option<u64>,
pub mean_center: bool,
pub require_convergence: bool,
}Expand description
Configuration for svd_with.
Fields§
§rank: usizeNumber of singular triplets wanted.
work: Option<usize>Basis size. Must exceed rank; defaults to rank + 7, clamped to
min(rows, cols).
§This is the knob that matters on tall matrices
Each restart re-orthogonalises against the whole basis, so a step costs
O(work · (rows + cols)) — on a matrix with a million rows that dominates the
sparse products by a wide margin. A larger work makes each step dearer but
converges in far fewer restarts, and the second effect wins comfortably.
Measured on 400k × 30k restricted to 2238 columns, 50 components
(cargo run --release --example tune):
work | time | matvecs | accuracy |
|---|---|---|---|
rank + 7 (default) | 30.2 s | 1515 | 6.7e-17 |
rank + 30 | 13.7 s | 701 | 1.9e-14 |
rank + 50 | 18.6 s | 601 | 2.0e-14 |
rank + 100 | 21.4 s | 501 | 2.2e-14 |
So rank + 30 was 2.2× faster at the same accuracy. The cost is basis
memory, which is linear in work: work · rows scalars for the left basis, or
600 MiB rather than 456 MiB at a million rows. The default stays conservative
because memory is the reason to choose this crate; raise it when you have the
headroom.
Run the tune example on your own shape rather than trusting these numbers —
the optimum moves with the aspect ratio and the spectrum.
tol: f64Relative residual tolerance: triplet i is accepted once its residual falls
below tol · σ_max.
max_restarts: usizeCap on restart cycles before giving up.
seed: Option<u64>Fixed seed for the starting vector; None draws from the OS.
mean_center: boolSubtract column means without materialising the centered matrix — i.e. PCA rather than plain SVD.
require_convergence: boolRefuse to return triplets that did not reach tol. Defaults to
true.
Exhausting the restart budget means the answer is a best effort of unknown
quality. Returning it as Ok puts the burden on every caller to remember to
inspect the diagnostics, and a pipeline that forgets gets a silently degraded
decomposition feeding whatever comes next. Failing loudly is the safer default;
set this to false if a best effort is genuinely what you want, then check
SvdRec::converged.
Implementations§
Source§impl IrlbaConfig
impl IrlbaConfig
Sourcepub fn max_restarts(self, n: usize) -> Self
pub fn max_restarts(self, n: usize) -> Self
Set the restart cap.
Sourcepub fn mean_center(self, yes: bool) -> Self
pub fn mean_center(self, yes: bool) -> Self
Enable implicit mean centering.
Sourcepub fn allow_unconverged(self) -> Self
pub fn allow_unconverged(self) -> Self
Accept a best-effort result instead of failing when the restart budget runs out.
Trait Implementations§
Source§impl Clone for IrlbaConfig
impl Clone for IrlbaConfig
Source§fn clone(&self) -> IrlbaConfig
fn clone(&self) -> IrlbaConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IrlbaConfig
impl RefUnwindSafe for IrlbaConfig
impl Send for IrlbaConfig
impl Sync for IrlbaConfig
impl Unpin for IrlbaConfig
impl UnsafeUnpin for IrlbaConfig
impl UnwindSafe for IrlbaConfig
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
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>
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>
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