2017-08-03 01:37:44 +08:00
|
|
|
use na::{DMatrix, DVector, FullPivLU};
|
2018-11-07 01:32:20 +08:00
|
|
|
use test::{self, Bencher};
|
2017-08-03 01:37:44 +08:00
|
|
|
|
|
|
|
// Without unpack.
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_decompose_10x10(bh: &mut Bencher) {
|
|
|
|
let m = DMatrix::<f64>::new_random(10, 10);
|
|
|
|
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_decompose_100x100(bh: &mut Bencher) {
|
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
|
|
|
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_decompose_500x500(bh: &mut Bencher) {
|
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
|
|
|
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_solve_10x10(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(10, 10);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
|
|
|
bh.iter(|| {
|
|
|
|
let mut b = DVector::<f64>::from_element(10, 1.0);
|
|
|
|
lu.solve(&mut b);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_solve_100x100(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
|
|
|
bh.iter(|| {
|
|
|
|
let mut b = DVector::<f64>::from_element(100, 1.0);
|
|
|
|
lu.solve(&mut b);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_solve_500x500(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
|
|
|
bh.iter(|| {
|
|
|
|
let mut b = DVector::<f64>::from_element(500, 1.0);
|
|
|
|
lu.solve(&mut b);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_inverse_10x10(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(10, 10);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.try_inverse()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_inverse_100x100(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.try_inverse()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_inverse_500x500(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.try_inverse()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_determinant_10x10(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(10, 10);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.determinant()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_determinant_100x100(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.determinant()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn full_piv_lu_determinant_500x500(bh: &mut Bencher) {
|
2018-02-02 19:26:35 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
2017-08-03 01:37:44 +08:00
|
|
|
let lu = FullPivLU::new(m.clone());
|
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
bh.iter(|| test::black_box(lu.determinant()))
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|