2018-01-17 23:48:47 +08:00
|
|
|
#![cfg(feature = "arbitrary")]
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
use std::cmp;
|
|
|
|
|
2017-08-14 01:52:46 +08:00
|
|
|
use na::{DMatrix, Matrix2, Matrix4};
|
2019-03-03 02:33:49 +08:00
|
|
|
use core::helper::{RandScalar, RandComplex};
|
2017-08-03 01:37:44 +08:00
|
|
|
|
|
|
|
quickcheck! {
|
2019-03-12 20:15:02 +08:00
|
|
|
fn symm_tridiagonal(n: usize) -> bool {
|
|
|
|
let n = cmp::max(1, cmp::min(n, 50));
|
|
|
|
let m = DMatrix::<RandComplex<f64>>::new_random(n, n).map(|e| e.0).hermitian_part();
|
|
|
|
let tri = m.clone().symmetric_tridiagonalize();
|
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
2019-03-03 02:33:49 +08:00
|
|
|
|
2019-03-18 18:23:19 +08:00
|
|
|
fn symm_tridiagonal_singular(n: usize) -> bool {
|
|
|
|
let n = cmp::max(1, cmp::min(n, 4));
|
|
|
|
let mut m = DMatrix::<RandComplex<f64>>::new_random(n, n).map(|e| e.0).hermitian_part();
|
|
|
|
m.row_mut(n / 2).fill(na::zero());
|
|
|
|
m.column_mut(n / 2).fill(na::zero());
|
|
|
|
let tri = m.clone().symmetric_tridiagonalize();
|
|
|
|
println!("Tri: {:?}", tri);
|
|
|
|
let recomp = tri.recompose();
|
|
|
|
println!("Recomp: {:?}", recomp);
|
|
|
|
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
|
|
|
|
2019-03-03 02:33:49 +08:00
|
|
|
fn symm_tridiagonal_static_square(m: Matrix4<RandComplex<f64>>) -> bool {
|
|
|
|
let m = m.map(|e| e.0).hermitian_part();
|
2017-08-14 01:52:46 +08:00
|
|
|
let tri = m.symmetric_tridiagonalize();
|
2017-08-03 01:37:44 +08:00
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
|
|
|
|
2019-03-12 20:15:02 +08:00
|
|
|
fn symm_tridiagonal_static_square_2x2(m: Matrix2<RandComplex<f64>>) -> bool {
|
|
|
|
let m = m.map(|e| e.0).hermitian_part();
|
|
|
|
let tri = m.symmetric_tridiagonalize();
|
|
|
|
let recomp = tri.recompose();
|
|
|
|
|
|
|
|
relative_eq!(m.lower_triangle(), recomp.lower_triangle(), epsilon = 1.0e-7)
|
|
|
|
}
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|