Skip to content

Commit 811c81a

Browse files
committed
impl EigValsh
1 parent 7ef6931 commit 811c81a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/eigh.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,37 @@ impl<'a, A, S, Se> Eigh<ArrayBase<Se, Ix1>, &'a mut ArrayBase<S, Ix2>> for &'a m
4848
pub trait EigValsh<EigVal> {
4949
fn eigvalsh(self, UPLO) -> Result<EigVal>;
5050
}
51+
52+
impl<A, S, Se> EigValsh<ArrayBase<Se, Ix1>> for ArrayBase<S, Ix2>
53+
where A: LapackScalar,
54+
S: DataMut<Elem = A>,
55+
Se: DataOwned<Elem = A::Real>
56+
{
57+
fn eigvalsh(mut self, uplo: UPLO) -> Result<ArrayBase<Se, Ix1>> {
58+
let s = A::eigh(false, self.square_layout()?, uplo, self.as_allocated_mut()?)?;
59+
Ok(ArrayBase::from_vec(s))
60+
}
61+
}
62+
63+
impl<'a, A, S, Se> EigValsh<ArrayBase<Se, Ix1>> for &'a ArrayBase<S, Ix2>
64+
where A: LapackScalar + Copy,
65+
S: Data<Elem = A>,
66+
Se: DataOwned<Elem = A::Real>
67+
{
68+
fn eigvalsh(self, uplo: UPLO) -> Result<ArrayBase<Se, Ix1>> {
69+
let mut a = self.to_owned();
70+
let s = A::eigh(false, a.square_layout()?, uplo, a.as_allocated_mut()?)?;
71+
Ok(ArrayBase::from_vec(s))
72+
}
73+
}
74+
75+
impl<'a, A, S, Se> EigValsh<ArrayBase<Se, Ix1>> for &'a mut ArrayBase<S, Ix2>
76+
where A: LapackScalar,
77+
S: DataMut<Elem = A>,
78+
Se: DataOwned<Elem = A::Real>
79+
{
80+
fn eigvalsh(mut self, uplo: UPLO) -> Result<ArrayBase<Se, Ix1>> {
81+
let s = A::eigh(true, self.square_layout()?, uplo, self.as_allocated_mut()?)?;
82+
Ok(ArrayBase::from_vec(s))
83+
}
84+
}

0 commit comments

Comments
 (0)