Format file

This commit is contained in:
metric-space 2022-01-18 22:42:12 -05:00 committed by Saurabh
parent 372152dc31
commit ccbd0f02e5
1 changed files with 64 additions and 49 deletions

View File

@ -38,11 +38,11 @@ where
{ {
alphar: OVector<T, D>, alphar: OVector<T, D>,
alphai: OVector<T, D>, alphai: OVector<T, D>,
beta: OVector<T,D>, beta: OVector<T, D>,
vsl: OMatrix<T, D, D>, vsl: OMatrix<T, D, D>,
s: OMatrix<T, D, D>, s: OMatrix<T, D, D>,
vsr: OMatrix<T, D, D>, vsr: OMatrix<T, D, D>,
t: OMatrix<T, D, D> t: OMatrix<T, D, D>,
} }
impl<T: Scalar + Copy, D: Dim> Copy for QZ<T, D> impl<T: Scalar + Copy, D: Dim> Copy for QZ<T, D>
@ -61,7 +61,7 @@ where
/// ///
/// Panics if the method did not converge. /// Panics if the method did not converge.
pub fn new(a: OMatrix<T, D, D>, b: OMatrix<T, D, D>) -> Self { pub fn new(a: OMatrix<T, D, D>, b: OMatrix<T, D, D>) -> Self {
Self::try_new(a,b).expect("Schur decomposition: convergence failed.") Self::try_new(a, b).expect("Schur decomposition: convergence failed.")
} }
/// Computes the eigenvalues and real Schur form of the matrix `m`. /// Computes the eigenvalues and real Schur form of the matrix `m`.
@ -140,14 +140,27 @@ where
); );
lapack_check!(info); lapack_check!(info);
Some(QZ {alphar, alphai, beta, Some(QZ {
vsl, s:a, alphar,
vsr, t:b}) alphai,
beta,
vsl,
s: a,
vsr,
t: b,
})
} }
/// Retrieves the unitary matrix `Q` and the upper-quasitriangular matrix `T` such that the /// Retrieves the unitary matrix `Q` and the upper-quasitriangular matrix `T` such that the
/// decomposed matrix equals `Q * T * Q.transpose()`. /// decomposed matrix equals `Q * T * Q.transpose()`.
pub fn unpack(self) -> (OMatrix<T, D, D>, OMatrix<T, D, D>, OMatrix<T, D, D>, OMatrix<T, D, D>){ pub fn unpack(
self,
) -> (
OMatrix<T, D, D>,
OMatrix<T, D, D>,
OMatrix<T, D, D>,
OMatrix<T, D, D>,
) {
(self.vsl, self.s, self.t, self.vsr) (self.vsl, self.s, self.t, self.vsr)
} }
@ -160,8 +173,10 @@ where
let mut out = Matrix::zeros_generic(self.t.shape_generic().0, Const::<1>); let mut out = Matrix::zeros_generic(self.t.shape_generic().0, Const::<1>);
for i in 0..out.len() { for i in 0..out.len() {
out[i] = Complex::new(self.alphar[i].clone()/self.beta[i].clone(), out[i] = Complex::new(
self.alphai[i].clone()/self.beta[i].clone()) self.alphar[i].clone() / self.beta[i].clone(),
self.alphai[i].clone() / self.beta[i].clone(),
)
} }
out out
@ -189,7 +204,7 @@ pub trait QZScalar: Scalar {
sdim: &mut i32, sdim: &mut i32,
alphar: &mut [Self], alphar: &mut [Self],
alphai: &mut [Self], alphai: &mut [Self],
beta : &mut [Self], beta: &mut [Self],
vsl: &mut [Self], vsl: &mut [Self],
ldvsl: i32, ldvsl: i32,
vsr: &mut [Self], vsr: &mut [Self],
@ -197,7 +212,7 @@ pub trait QZScalar: Scalar {
work: &mut [Self], work: &mut [Self],
lwork: i32, lwork: i32,
bwork: &mut [i32], bwork: &mut [i32],
info: &mut i32 info: &mut i32,
); );
#[allow(missing_docs)] #[allow(missing_docs)]
@ -214,13 +229,13 @@ pub trait QZScalar: Scalar {
sdim: &mut i32, sdim: &mut i32,
alphar: &mut [Self], alphar: &mut [Self],
alphai: &mut [Self], alphai: &mut [Self],
beta : &mut [Self], beta: &mut [Self],
vsl: &mut [Self], vsl: &mut [Self],
ldvsl: i32, ldvsl: i32,
vsr: &mut [Self], vsr: &mut [Self],
ldvsr: i32, ldvsr: i32,
bwork: &mut [i32], bwork: &mut [i32],
info: &mut i32 info: &mut i32,
) -> i32; ) -> i32;
} }