2017-08-03 01:37:44 +08:00
|
|
|
use na::{Matrix4, SVD};
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn svd_decompose_4x4(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = Matrix4::<f64>::new_random();
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("svd_decompose_4x4", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn svd_decompose_10x10(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(10, 10);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("svd_decompose_10x10", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn svd_decompose_100x100(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(100, 100);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("svd_decompose_100x100", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn svd_decompose_200x200(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(200, 200);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("svd_decompose_200x200", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn rank_4x4(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = Matrix4::<f64>::new_random();
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("rank_4x4", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn rank_10x10(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(10, 10);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("rank_10x10", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn rank_100x100(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(100, 100);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("rank_100x100", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn rank_200x200(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(200, 200);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("rank_200x200", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn singular_values_4x4(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = Matrix4::<f64>::new_random();
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("singular_values_4x4", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.singular_values()))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn singular_values_10x10(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(10, 10);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("singular_values_10x10", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.singular_values()))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn singular_values_100x100(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(100, 100);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("singular_values_100x100", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.singular_values()))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn singular_values_200x200(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(200, 200);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("singular_values_200x200", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.singular_values()))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn pseudo_inverse_4x4(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = Matrix4::<f64>::new_random();
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("pseudo_inverse_4x4", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn pseudo_inverse_10x10(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(10, 10);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("pseudo_inverse_10x10", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn pseudo_inverse_100x100(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(100, 100);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("pseudo_inverse_100x100", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
|
|
|
});
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 02:07:16 +08:00
|
|
|
fn pseudo_inverse_200x200(bh: &mut criterion::Criterion) {
|
2019-03-23 21:29:07 +08:00
|
|
|
let m = crate::reproductible_dmatrix(200, 200);
|
2020-04-06 00:49:48 +08:00
|
|
|
bh.bench_function("pseudo_inverse_200x200", move |bh| {
|
|
|
|
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
|
|
|
});
|
2019-03-24 02:07:16 +08:00
|
|
|
}
|
|
|
|
|
2020-04-06 00:49:48 +08:00
|
|
|
criterion_group!(
|
|
|
|
svd,
|
2019-03-24 02:07:16 +08:00
|
|
|
svd_decompose_4x4,
|
|
|
|
svd_decompose_10x10,
|
|
|
|
svd_decompose_100x100,
|
|
|
|
svd_decompose_200x200,
|
|
|
|
rank_4x4,
|
|
|
|
rank_10x10,
|
|
|
|
rank_100x100,
|
|
|
|
rank_200x200,
|
|
|
|
singular_values_4x4,
|
|
|
|
singular_values_10x10,
|
|
|
|
singular_values_100x100,
|
|
|
|
singular_values_200x200,
|
|
|
|
pseudo_inverse_4x4,
|
|
|
|
pseudo_inverse_10x10,
|
|
|
|
pseudo_inverse_100x100,
|
|
|
|
pseudo_inverse_200x200
|
2020-04-06 00:49:48 +08:00
|
|
|
);
|