forked from M-Labs/nalgebra
Address review comments
This commit is contained in:
parent
325618ba22
commit
1acd48f6f1
@ -2,6 +2,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::any::TypeId;
|
||||
|
||||
use approx::AbsDiffEq;
|
||||
use num::{One, Zero};
|
||||
|
||||
use crate::allocator::Allocator;
|
||||
@ -93,7 +94,14 @@ where
|
||||
/// The singular values are not guaranteed to be sorted in any particular order.
|
||||
/// If a descending order is required, consider using `new` instead.
|
||||
pub fn new_unordered(matrix: OMatrix<T, R, C>, compute_u: bool, compute_v: bool) -> Self {
|
||||
Self::try_new_unordered(matrix, compute_u, compute_v, crate::convert(1e-15), 0).unwrap()
|
||||
Self::try_new_unordered(
|
||||
matrix,
|
||||
compute_u,
|
||||
compute_v,
|
||||
T::RealField::default_epsilon() * crate::convert(5.0),
|
||||
0,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// Attempts to compute the Singular Value Decomposition of `matrix` using implicit shift.
|
||||
|
@ -462,8 +462,8 @@ fn svd_sorted() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Exercises bug reported in issue #983 of nalgebra
|
||||
fn svd_consistent() {
|
||||
// Exercises bug reported in issue #983 of nalgebra (https://github.com/dimforge/nalgebra/issues/983)
|
||||
fn svd_regression_issue_983() {
|
||||
let m = nalgebra::dmatrix![
|
||||
10.74785316637712f64, -5.994983325167452, -6.064492921857296;
|
||||
-4.149751381521569, 20.654504205822462, -4.470436210703133;
|
||||
@ -475,12 +475,12 @@ fn svd_consistent() {
|
||||
let svd3 = m.clone().svd(true, false);
|
||||
let svd4 = m.svd(false, false);
|
||||
|
||||
assert_relative_eq!(svd1.singular_values, svd2.singular_values, epsilon = 1e-5);
|
||||
assert_relative_eq!(svd1.singular_values, svd3.singular_values, epsilon = 1e-5);
|
||||
assert_relative_eq!(svd1.singular_values, svd4.singular_values, epsilon = 1e-5);
|
||||
assert_relative_eq!(svd1.singular_values, svd2.singular_values, epsilon = 1e-9);
|
||||
assert_relative_eq!(svd1.singular_values, svd3.singular_values, epsilon = 1e-9);
|
||||
assert_relative_eq!(svd1.singular_values, svd4.singular_values, epsilon = 1e-9);
|
||||
assert_relative_eq!(
|
||||
svd1.singular_values,
|
||||
nalgebra::dvector![3.16188022e+01, 2.23811978e+01, 0.],
|
||||
epsilon = 1e-5
|
||||
epsilon = 1e-6
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user