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
39
40
41
42
use crateEPSILON;
/// Zeros out small values below a threshold.
///
/// # Arguments
///
/// * `val` - The value to check
/// * `epsilon` - The threshold below which values are zeroed (default: [`EPSILON`])
///
/// # Examples
///
/// ```
/// use eunoia::math::{zap_small, zap_small_with};
/// use nalgebra::Matrix3;
///
/// // Using default epsilon
/// let matrix = Matrix3::new(1.0, 1e-12, 0.0, 1e-12, 2.0, 0.0, 0.0, 0.0, 3.0);
/// let cleaned = matrix.map(zap_small);
///
/// // Using custom epsilon
/// let cleaned = matrix.map(|x| zap_small_with(x, 1e-8));
/// ```
/// Zeros out small values below a custom threshold.
///
/// # Arguments
///
/// * `val` - The value to check
/// * `epsilon` - The threshold below which values are zeroed