Fix some tests requiring a square matrix.

This commit is contained in:
Crozet Sébastien 2021-03-01 10:02:45 +01:00
parent e27ff8ce4e
commit 2e16057e7b
3 changed files with 14 additions and 12 deletions

View File

@ -11,8 +11,9 @@ fn hessenberg_simple() {
}
macro_rules! gen_tests(
($module: ident, $scalar: expr) => {
($module: ident, $scalar: expr, $scalar_type: ty) => {
mod $module {
use na::DMatrix;
#[allow(unused_imports)]
use crate::core::helper::{RandScalar, RandComplex};
@ -21,7 +22,8 @@ macro_rules! gen_tests(
proptest! {
#[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 (p, h) = hess.unpack();
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!(f64, PROPTEST_F64);
gen_tests!(complex, complex_f64(), RandComplex<f64>);
gen_tests!(f64, PROPTEST_F64, RandScalar<f64>);

View File

@ -43,7 +43,6 @@ mod proptest_tests {
macro_rules! gen_tests(
($module: ident, $scalar: expr, $scalar_type: ty) => {
mod $module {
use std::cmp;
use na::{DMatrix, Matrix4x3, DVector, Vector4};
#[allow(unused_imports)]
use crate::core::helper::{RandScalar, RandComplex};
@ -92,8 +91,6 @@ mod proptest_tests {
#[test]
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 lu = m.clone().lu();
@ -121,7 +118,8 @@ mod proptest_tests {
}
#[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 u = m.upper_triangle();

View File

@ -16,8 +16,9 @@ fn schur_simpl_mat3() {
#[cfg(feature = "proptest-support")]
mod proptest_tests {
macro_rules! gen_tests(
($module: ident, $scalar: expr) => {
($module: ident, $scalar: expr, $scalar_type: ty) => {
mod $module {
use na::DMatrix;
#[allow(unused_imports)]
use crate::core::helper::{RandScalar, RandComplex};
use crate::proptest::*;
@ -25,7 +26,8 @@ mod proptest_tests {
proptest! {
#[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();
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!(f64, PROPTEST_F64);
gen_tests!(complex, complex_f64(), RandComplex<f64>);
gen_tests!(f64, PROPTEST_F64, RandScalar<f64>);
}
#[test]