Skip to content

Commit f987e34

Browse files
compute epsilon based on the scale of matrix data
1 parent e4518f4 commit f987e34

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/structure/matrix.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,9 @@ impl LinearAlgebra<Matrix> for Matrix {
32933293
///
32943294
/// Implementation of [RosettaCode](https://rosettacode.org/wiki/Reduced_row_echelon_form)
32953295
fn rref(&self) -> Matrix {
3296-
let epsilon = 1e-10;
3296+
let max_abs = self.data.iter().fold(0f64, |acc, &x| acc.max(x.abs()));
3297+
let epsilon = (max_abs * 1e-12).max(1e-15);
3298+
32973299
let mut lead = 0usize;
32983300
let mut result = self.clone();
32993301
'outer: for r in 0..self.row {

0 commit comments

Comments
 (0)