1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! This module contains various mathematical functions and utilities.
////////////
// Consts //
////////////
/// The default oversampling for randomised SVD
pub const DEFAULT_OVERSAMPLING_RAND_SVD: usize = 10;
/// Oversampling for randomised SVD on single-cell data.
///
/// Ten times [DEFAULT_OVERSAMPLING_RAND_SVD]. Single-cell embeddings have a
/// long flat noise floor below the first few components, and a narrow sketch
/// under-estimates every singular value in it. Every CPU and GPU single-cell
/// PCA path uses this, so the two stay comparable; a mismatch between them
/// shows up as a silent accuracy gap rather than an error.
///
/// Clamp it against the rank of the input before use: on a small matrix
/// `no_pcs + 100` can exceed `min(rows, cols)`.
pub const MAX_OVERSAMPLING_SINGLE_CELL: usize = 100;
/// The default power iterations for randomised SVD
pub const DEFAULT_N_POWER_ITERS_RAND_SVD: usize = 2;
/// MAD scaling constant. R's `mad()` applies this factor by default.
pub const MAD_SCALE: f64 = 1.482_602_218_505_602;