Removed extra memory allocation for buffer (now redundant)

This commit is contained in:
metric-space 2022-02-05 23:44:05 -05:00 committed by Saurabh
parent ed09700280
commit 8ef7c42328

View File

@ -205,10 +205,12 @@ where
Allocator<Complex<T>, D, D> + Allocator<Complex<T>, D> + Allocator<(Complex<T>, T), D>, Allocator<Complex<T>, D, D> + Allocator<Complex<T>, D> + Allocator<(Complex<T>, T), D>,
{ {
let n = self.vsl.shape().0; let n = self.vsl.shape().0;
let mut l = self let mut l = self
.vsl .vsl
.clone() .clone()
.map(|x| Complex::new(x, T::RealField::zero())); .map(|x| Complex::new(x, T::RealField::zero()));
let mut r = self let mut r = self
.vsr .vsr
.clone() .clone()
@ -216,8 +218,8 @@ where
let eigenvalues = &self.eigenvalues(); let eigenvalues = &self.eigenvalues();
let mut ll;
let mut c = 0; let mut c = 0;
while c < n { while c < n {
if eigenvalues[c].im.abs() > T::RealField::default_epsilon() && c + 1 < n && { if eigenvalues[c].im.abs() > T::RealField::default_epsilon() && c + 1 < n && {
let e_conj = eigenvalues[c].conj(); let e_conj = eigenvalues[c].conj();
@ -225,22 +227,20 @@ where
((e_conj.re - e.re).abs() < T::RealField::default_epsilon()) ((e_conj.re - e.re).abs() < T::RealField::default_epsilon())
&& ((e_conj.im - e.im).abs() < T::RealField::default_epsilon()) && ((e_conj.im - e.im).abs() < T::RealField::default_epsilon())
} { } {
ll = l.column(c + 1).into_owned(); // taking care of the left eigenvector matrix
l.column_mut(c).zip_apply(&ll, |r, i| { l.column_mut(c).zip_apply(&self.vsl.column(c + 1), |r, i| {
*r = Complex::new(r.re.clone(), i.re); *r = Complex::new(r.re.clone(), i.clone());
}); });
ll.copy_from(&l.column(c)); l.column_mut(c + 1).zip_apply(&self.vsl.column(c), |i, r| {
l.column_mut(c + 1).zip_apply(&ll, |r, i| { *i = Complex::new(r.clone(), -i.re.clone());
*r = i.conj();
}); });
ll.copy_from(&r.column(c + 1)); // taking care of the right eigenvector matrix
r.column_mut(c).zip_apply(&ll, |r, i| { r.column_mut(c).zip_apply(&self.vsr.column(c + 1), |r, i| {
*r = Complex::new(r.re, i.re); *r = Complex::new(r.re.clone(), i.clone());
}); });
ll.copy_from(&r.column(c)); r.column_mut(c + 1).zip_apply(&self.vsr.column(c), |i, r| {
r.column_mut(c + 1).zip_apply(&ll, |r, i| { *i = Complex::new(r.clone(), -i.re.clone());
*r = i.conj();
}); });
c += 2; c += 2;