Skip to content

Commit

Permalink
Test for axes with zero magnitude
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusgo committed Nov 9, 2023
1 parent 03c24fb commit 7ea9ece
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/linalg/bidiagonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use simba::scalar::ComplexField;

use crate::geometry::Reflection;
use crate::linalg::householder;
use crate::num::Zero;
use std::mem::MaybeUninit;

/// The bidiagonalization of a general matrix.
Expand Down Expand Up @@ -227,7 +228,10 @@ where

for i in (0..dim - shift).rev() {
let axis = self.uv.view_range(i + shift.., i);
// TODO: sometimes, the axis might have a zero magnitude.
// Sometimes, the axis might have a zero magnitude.
if axis.magnitude().is_zero() {
continue;
}
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());

let mut res_rows = res.view_range_mut(i + shift.., i..);
Expand Down Expand Up @@ -263,7 +267,10 @@ 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);
// TODO: sometimes, the axis might have a zero magnitude.
// Sometimes, the axis might have a zero magnitude.
if axis_packed.magnitude().is_zero() {
continue;
}
let refl = Reflection::new(Unit::new_unchecked(axis_packed), T::zero());

let mut res_rows = res.view_range_mut(i.., i + shift..);
Expand Down

0 comments on commit 7ea9ece

Please sign in to comment.