From 469390f4b922e8c0d455ead00dfd99e8ea610671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 12 Nov 2023 23:12:52 +0100 Subject: [PATCH] Check norm_squared instead of mangnitude. --- src/linalg/bidiagonal.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/linalg/bidiagonal.rs b/src/linalg/bidiagonal.rs index fd32e744..4faa9c5a 100644 --- a/src/linalg/bidiagonal.rs +++ b/src/linalg/bidiagonal.rs @@ -228,8 +228,9 @@ where for i in (0..dim - shift).rev() { let axis = self.uv.view_range(i + shift.., i); + // Sometimes, the axis might have a zero magnitude. - if axis.magnitude().is_zero() { + if axis.norm_squared().is_zero() { continue; } let refl = Reflection::new(Unit::new_unchecked(axis), T::zero()); @@ -267,8 +268,9 @@ where let axis = self.uv.view_range(i, i + shift..); let mut axis_packed = axis_packed.rows_range_mut(i + shift..); axis_packed.tr_copy_from(&axis); + // Sometimes, the axis might have a zero magnitude. - if axis_packed.magnitude().is_zero() { + if axis_packed.norm_squared().is_zero() { continue; } let refl = Reflection::new(Unit::new_unchecked(axis_packed), T::zero());