|
| 1 | + |
| 2 | +use ndarray::*; |
| 3 | + |
| 4 | +use super::error::*; |
| 5 | +use super::layout::*; |
| 6 | + |
| 7 | +use impl2::{LapackScalar, UPLO}; |
| 8 | + |
| 9 | +pub trait Eigh<EigVal, EigVec> { |
| 10 | + fn eigh(self, UPLO) -> Result<(EigVal, EigVec)>; |
| 11 | +} |
| 12 | + |
| 13 | +impl<A, S, Se> Eigh<ArrayBase<Se, Ix1>, ArrayBase<S, Ix2>> for ArrayBase<S, Ix2> |
| 14 | + where A: LapackScalar, |
| 15 | + S: DataMut<Elem = A>, |
| 16 | + Se: DataOwned<Elem = A::Real> |
| 17 | +{ |
| 18 | + fn eigh(mut self, uplo: UPLO) -> Result<(ArrayBase<Se, Ix1>, ArrayBase<S, Ix2>)> { |
| 19 | + let s = A::eigh(true, self.square_layout()?, uplo, self.as_allocated_mut()?)?; |
| 20 | + Ok((ArrayBase::from_vec(s), self)) |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +impl<'a, A, S, Se> Eigh<ArrayBase<Se, Ix1>, &'a mut ArrayBase<S, Ix2>> for &'a mut ArrayBase<S, Ix2> |
| 25 | + where A: LapackScalar, |
| 26 | + S: DataMut<Elem = A>, |
| 27 | + Se: DataOwned<Elem = A::Real> |
| 28 | +{ |
| 29 | + fn eigh(mut self, uplo: UPLO) -> Result<(ArrayBase<Se, Ix1>, &'a mut ArrayBase<S, Ix2>)> { |
| 30 | + let s = A::eigh(true, self.square_layout()?, uplo, self.as_allocated_mut()?)?; |
| 31 | + Ok((ArrayBase::from_vec(s), self)) |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +pub trait EigValsh<EigVal> { |
| 36 | + fn eigvalsh(self, UPLO) -> Result<EigVal>; |
| 37 | +} |
0 commit comments