Skip to content

Commit 43b0480

Browse files
committed
WIP: reconstruct_eigs
1 parent e603f61 commit 43b0480

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

lax/src/eig.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ pub struct EigWork<T: Scalar> {
4040
pub jobvl: JobEv,
4141

4242
/// Eigenvalues used in complex routines
43-
pub eigs: Option<Vec<MaybeUninit<T>>>,
43+
pub eigs: Option<Vec<MaybeUninit<T::Complex>>>,
4444
/// Real part of eigenvalues used in real routines
45-
pub eigs_re: Option<Vec<MaybeUninit<T>>>,
45+
pub eigs_re: Option<Vec<MaybeUninit<T::Real>>>,
4646
/// Imaginary part of eigenvalues used in real routines
47-
pub eigs_im: Option<Vec<MaybeUninit<T>>>,
47+
pub eigs_im: Option<Vec<MaybeUninit<T::Real>>>,
4848

4949
/// Left eigenvectors
5050
pub vl: Option<Vec<MaybeUninit<T>>>,
@@ -57,6 +57,26 @@ pub struct EigWork<T: Scalar> {
5757
pub rwork: Option<Vec<MaybeUninit<T::Real>>>,
5858
}
5959

60+
impl<T: Scalar> EigWork<T> {
61+
/// Create complex eigenvalues from real and imaginary parts.
62+
unsafe fn reconstruct_eigs(&mut self) {
63+
let n = self.n as usize;
64+
if self.eigs.is_none() {
65+
self.eigs = Some(vec_uninit(n));
66+
}
67+
let eigs = self.eigs.as_mut().unwrap();
68+
if let (Some(re), Some(im)) = (self.eigs_re.as_ref(), self.eigs_im.as_ref()) {
69+
assert_eq!(re.len(), n);
70+
assert_eq!(im.len(), n);
71+
for i in 0..n {
72+
eigs[i].write(T::complex(re[i].assume_init(), im[i].assume_init()));
73+
}
74+
} else {
75+
panic!("Called without constructing eigs_re and eigs_im");
76+
}
77+
}
78+
}
79+
6080
pub trait EigWorkImpl: Sized {
6181
type Elem: Scalar;
6282
/// Create new working memory for eigenvalues compution.

0 commit comments

Comments
 (0)