Skip to content

Commit 4638183

Browse files
committed
impl SolveH for ArrayBase
1 parent e32ee3b commit 4638183

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

examples/solveh.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ fn solve() -> Result<(), error::LinalgError> {
1010
let a: Array2<c64> = random_hermite(3); // complex Hermite positive definite matrix
1111
let b: Array1<c64> = random(3);
1212
println!("b = {:?}", &b);
13-
let f = a.factorizeh()?; // DK factorize
14-
let x = f.solveh(b)?;
13+
let x = a.solveh(&b)?;
1514
println!("Ax = {:?}", a.dot(&x));;
1615
Ok(())
1716
}
@@ -23,7 +22,7 @@ fn factorize() -> Result<(), error::LinalgError> {
2322
// once factorized, you can use it several times:
2423
for _ in 0..10 {
2524
let b: Array1<f64> = random(3);
26-
let _x = f.solveh(b)?;
25+
let _x = f.solveh_into(b)?;
2726
}
2827
Ok(())
2928
}

src/solveh.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ where
4949
}
5050
}
5151

52+
impl<A, S> SolveH<A> for ArrayBase<S, Ix2>
53+
where
54+
A: Scalar,
55+
S: Data<Elem = A>,
56+
{
57+
fn solveh_mut<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
58+
where
59+
Sb: DataMut<Elem = A>,
60+
{
61+
let f = self.factorizeh()?;
62+
f.solveh_mut(rhs)
63+
}
64+
}
65+
66+
5267
impl<A, S> FactorizedH<S>
5368
where
5469
A: Scalar,

0 commit comments

Comments
 (0)