Fix some tests requiring a square matrix.
This commit is contained in:
parent
e27ff8ce4e
commit
2e16057e7b
|
@ -11,8 +11,9 @@ fn hessenberg_simple() {
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! gen_tests(
|
macro_rules! gen_tests(
|
||||||
($module: ident, $scalar: expr) => {
|
($module: ident, $scalar: expr, $scalar_type: ty) => {
|
||||||
mod $module {
|
mod $module {
|
||||||
|
use na::DMatrix;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::core::helper::{RandScalar, RandComplex};
|
use crate::core::helper::{RandScalar, RandComplex};
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@ macro_rules! gen_tests(
|
||||||
|
|
||||||
proptest! {
|
proptest! {
|
||||||
#[test]
|
#[test]
|
||||||
fn hessenberg(m in dmatrix_($scalar)) {
|
fn hessenberg(n in PROPTEST_MATRIX_DIM) {
|
||||||
|
let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0);
|
||||||
let hess = m.clone().hessenberg();
|
let hess = m.clone().hessenberg();
|
||||||
let (p, h) = hess.unpack();
|
let (p, h) = hess.unpack();
|
||||||
prop_assert!(relative_eq!(m, &p * h * p.adjoint(), epsilon = 1.0e-7))
|
prop_assert!(relative_eq!(m, &p * h * p.adjoint(), epsilon = 1.0e-7))
|
||||||
|
@ -45,5 +47,5 @@ macro_rules! gen_tests(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
gen_tests!(complex, complex_f64());
|
gen_tests!(complex, complex_f64(), RandComplex<f64>);
|
||||||
gen_tests!(f64, PROPTEST_F64);
|
gen_tests!(f64, PROPTEST_F64, RandScalar<f64>);
|
||||||
|
|
|
@ -43,7 +43,6 @@ mod proptest_tests {
|
||||||
macro_rules! gen_tests(
|
macro_rules! gen_tests(
|
||||||
($module: ident, $scalar: expr, $scalar_type: ty) => {
|
($module: ident, $scalar: expr, $scalar_type: ty) => {
|
||||||
mod $module {
|
mod $module {
|
||||||
use std::cmp;
|
|
||||||
use na::{DMatrix, Matrix4x3, DVector, Vector4};
|
use na::{DMatrix, Matrix4x3, DVector, Vector4};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::core::helper::{RandScalar, RandComplex};
|
use crate::core::helper::{RandScalar, RandComplex};
|
||||||
|
@ -92,8 +91,6 @@ mod proptest_tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lu_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) {
|
fn lu_solve(n in PROPTEST_MATRIX_DIM, nb in PROPTEST_MATRIX_DIM) {
|
||||||
let n = cmp::min(n, 50); // To avoid slowing down the test too much.
|
|
||||||
let nb = cmp::min(nb, 50); // To avoid slowing down the test too much.
|
|
||||||
let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0);
|
let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0);
|
||||||
|
|
||||||
let lu = m.clone().lu();
|
let lu = m.clone().lu();
|
||||||
|
@ -121,7 +118,8 @@ mod proptest_tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lu_inverse(m in dmatrix_($scalar)) {
|
fn lu_inverse(n in PROPTEST_MATRIX_DIM) {
|
||||||
|
let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0);
|
||||||
let mut l = m.lower_triangle();
|
let mut l = m.lower_triangle();
|
||||||
let mut u = m.upper_triangle();
|
let mut u = m.upper_triangle();
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,9 @@ fn schur_simpl_mat3() {
|
||||||
#[cfg(feature = "proptest-support")]
|
#[cfg(feature = "proptest-support")]
|
||||||
mod proptest_tests {
|
mod proptest_tests {
|
||||||
macro_rules! gen_tests(
|
macro_rules! gen_tests(
|
||||||
($module: ident, $scalar: expr) => {
|
($module: ident, $scalar: expr, $scalar_type: ty) => {
|
||||||
mod $module {
|
mod $module {
|
||||||
|
use na::DMatrix;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::core::helper::{RandScalar, RandComplex};
|
use crate::core::helper::{RandScalar, RandComplex};
|
||||||
use crate::proptest::*;
|
use crate::proptest::*;
|
||||||
|
@ -25,7 +26,8 @@ mod proptest_tests {
|
||||||
|
|
||||||
proptest! {
|
proptest! {
|
||||||
#[test]
|
#[test]
|
||||||
fn schur(m in dmatrix_($scalar)) {
|
fn schur(n in PROPTEST_MATRIX_DIM) {
|
||||||
|
let m = DMatrix::<$scalar_type>::new_random(n, n).map(|e| e.0);
|
||||||
let (vecs, vals) = m.clone().schur().unpack();
|
let (vecs, vals) = m.clone().schur().unpack();
|
||||||
prop_assert!(relative_eq!(&vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(&vecs * vals * vecs.adjoint(), m, epsilon = 1.0e-7));
|
||||||
}
|
}
|
||||||
|
@ -52,8 +54,8 @@ mod proptest_tests {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
gen_tests!(complex, complex_f64());
|
gen_tests!(complex, complex_f64(), RandComplex<f64>);
|
||||||
gen_tests!(f64, PROPTEST_F64);
|
gen_tests!(f64, PROPTEST_F64, RandScalar<f64>);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue