Skip to content

Commit

Permalink
impl SolveH for ArrayBase
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Aug 22, 2017
1 parent e32ee3b commit 4638183
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/solveh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ fn solve() -> Result<(), error::LinalgError> {
let a: Array2<c64> = random_hermite(3); // complex Hermite positive definite matrix
let b: Array1<c64> = random(3);
println!("b = {:?}", &b);
let f = a.factorizeh()?; // DK factorize
let x = f.solveh(b)?;
let x = a.solveh(&b)?;
println!("Ax = {:?}", a.dot(&x));;
Ok(())
}
Expand All @@ -23,7 +22,7 @@ fn factorize() -> Result<(), error::LinalgError> {
// once factorized, you can use it several times:
for _ in 0..10 {
let b: Array1<f64> = random(3);
let _x = f.solveh(b)?;
let _x = f.solveh_into(b)?;
}
Ok(())
}
Expand Down
15 changes: 15 additions & 0 deletions src/solveh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ where
}
}

impl<A, S> SolveH<A> for ArrayBase<S, Ix2>
where
A: Scalar,
S: Data<Elem = A>,
{
fn solveh_mut<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
where
Sb: DataMut<Elem = A>,
{
let f = self.factorizeh()?;
f.solveh_mut(rhs)
}
}


impl<A, S> FactorizedH<S>
where
A: Scalar,
Expand Down

0 comments on commit 4638183

Please sign in to comment.