Skip to content

Commit 02de421

Browse files
committed
Fix test of householder_append
1 parent e4adcd6 commit 02de421

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/krylov/householder.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ impl<A: Scalar + Lapack> Orthogonalizer for Householder<A> {
7474
// Add reflector
7575
let k = self.len();
7676
let xi = a[k].re();
77-
a[k] = A::from(if xi > Zero::zero() { xi + alpha } else { xi - alpha }).unwrap();
77+
a[k] = A::from(if xi >= Zero::zero() { xi + alpha } else { xi - alpha }).unwrap();
7878
let norm = a.slice(s![k..]).norm_l2();
79-
dbg!(alpha);
80-
dbg!(norm);
81-
azip!(mut a (a.slice_mut(s![k..])) in { *a = a.div_real(norm)} );
79+
azip!(mut a (a.slice_mut(s![..k])) in { *a = Zero::zero() });
80+
azip!(mut a (a.slice_mut(s![k..])) in { *a = a.div_real(norm) });
8281
self.v.push(a.into_owned());
83-
dbg!(&self.v);
8482
Ok(coef)
8583
}
8684

@@ -105,16 +103,17 @@ mod tests {
105103
fn householder_append() {
106104
let mut householder = Householder::new(3);
107105
let coef = householder.append(array![0.0, 1.0, 0.0], 1e-9).unwrap();
106+
dbg!(&coef);
108107
close_l2(&coef, &array![1.0], 1e-9).unwrap();
109108

110109
let coef = householder.append(array![1.0, 1.0, 0.0], 1e-9).unwrap();
111-
close_l2(&coef, &array![1.0, 1.0], 1e-9).unwrap();
110+
dbg!(&coef);
111+
close_l2(&coef, &array![-1.0, 1.0], 1e-9).unwrap();
112112

113113
assert!(householder.append(array![1.0, 2.0, 0.0], 1e-9).is_err());
114-
115114
if let Err(coef) = householder.append(array![1.0, 2.0, 0.0], 1e-9) {
116115
dbg!(&coef);
117-
close_l2(&coef, &array![2.0, 1.0, 0.0], 1e-9).unwrap();
116+
close_l2(&coef, &array![-2.0, 1.0, 0.0], 1e-9).unwrap();
118117
}
119118
}
120119

0 commit comments

Comments
 (0)