2021-03-01 00:52:14 +08:00
|
|
|
#![cfg(feature = "proptest-support")]
|
2017-08-03 01:37:44 +08:00
|
|
|
|
|
|
|
use na::balancing;
|
2021-03-01 00:52:14 +08:00
|
|
|
use na::DMatrix;
|
|
|
|
|
|
|
|
use crate::proptest::*;
|
|
|
|
use proptest::{prop_assert_eq, proptest};
|
2017-08-03 01:37:44 +08:00
|
|
|
|
2021-03-01 00:52:14 +08:00
|
|
|
proptest! {
|
|
|
|
#[test]
|
|
|
|
fn balancing_parlett_reinsch(n in PROPTEST_MATRIX_DIM) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(n, n);
|
|
|
|
let mut balanced = m.clone();
|
|
|
|
let d = balancing::balance_parlett_reinsch(&mut balanced);
|
|
|
|
balancing::unbalance(&mut balanced, &d);
|
|
|
|
|
2021-03-01 00:52:14 +08:00
|
|
|
prop_assert_eq!(balanced, m);
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-01 00:52:14 +08:00
|
|
|
#[test]
|
|
|
|
fn balancing_parlett_reinsch_static(m in matrix4()) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let mut balanced = m;
|
|
|
|
let d = balancing::balance_parlett_reinsch(&mut balanced);
|
|
|
|
balancing::unbalance(&mut balanced, &d);
|
|
|
|
|
2021-03-01 00:52:14 +08:00
|
|
|
prop_assert_eq!(balanced, m);
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
}
|