Debian Codegraph @

debian/missing-sources/nalgebra/benches/linalg/lu.rs

raw
1 use na::{DMatrix, DVector, LU};
2
3 // Without unpack.
4 fn lu_decompose_10x10(bh: &mut criterion::Criterion) {
5 let m = DMatrix::<f64>::new_random(10, 10);
6 bh.bench_function("lu_decompose_10x10", move |bh| {
7 bh.iter(|| std::hint::black_box(LU::new(m.clone())))
8 });
9 }
10
11 fn lu_decompose_100x100(bh: &mut criterion::Criterion) {
12 let m = DMatrix::<f64>::new_random(100, 100);
13 bh.bench_function("lu_decompose_100x100", move |bh| {
14 bh.iter(|| std::hint::black_box(LU::new(m.clone())))
15 });
16 }
17
18 fn lu_solve_10x10(bh: &mut criterion::Criterion) {
19 let m = DMatrix::<f64>::new_random(10, 10);
20 let lu = LU::new(m.clone());
21
22 bh.bench_function("lu_solve_10x10", move |bh| {
23 bh.iter(|| {
24 let mut b = DVector::<f64>::from_element(10, 1.0);
25 lu.solve_mut(&mut b);
26 b
27 })
28 });
29 }
30
31 fn lu_solve_100x100(bh: &mut criterion::Criterion) {
32 let m = DMatrix::<f64>::new_random(100, 100);
33 let lu = LU::new(m.clone());
34
35 bh.bench_function("lu_solve_100x100", move |bh| {
36 bh.iter(|| {
37 let mut b = DVector::<f64>::from_element(100, 1.0);
38 lu.solve_mut(&mut b);
39 b
40 })
41 });
42 }
43
44 fn lu_inverse_10x10(bh: &mut criterion::Criterion) {
45 let m = DMatrix::<f64>::new_random(10, 10);
46 let lu = LU::new(m.clone());
47
48 bh.bench_function("lu_inverse_10x10", move |bh| {
49 bh.iter(|| std::hint::black_box(lu.try_inverse()))
50 });
51 }
52
53 fn lu_inverse_100x100(bh: &mut criterion::Criterion) {
54 let m = DMatrix::<f64>::new_random(100, 100);
55 let lu = LU::new(m.clone());
56
57 bh.bench_function("lu_inverse_100x100", move |bh| {
58 bh.iter(|| std::hint::black_box(lu.try_inverse()))
59 });
60 }
61
62 fn lu_determinant_10x10(bh: &mut criterion::Criterion) {
63 let m = DMatrix::<f64>::new_random(10, 10);
64 let lu = LU::new(m.clone());
65
66 bh.bench_function("lu_determinant_10x10", move |bh| {
67 bh.iter(|| std::hint::black_box(lu.determinant()))
68 });
69 }
70
71 fn lu_determinant_100x100(bh: &mut criterion::Criterion) {
72 let m = DMatrix::<f64>::new_random(100, 100);
73 let lu = LU::new(m.clone());
74
75 bh.bench_function("lu_determinant_100x100", move |bh| {
76 bh.iter(|| std::hint::black_box(lu.determinant()))
77 });
78 }
79
80 criterion_group!(
81 lu,
82 lu_decompose_10x10,
83 lu_decompose_100x100,
84 lu_solve_10x10,
85 lu_solve_100x100,
86 lu_inverse_10x10,
87 lu_inverse_100x100,
88 lu_determinant_10x10,
89 lu_determinant_100x100,
90 );