From 863ad6a5b34b247f100797fbd4ef9c99ef61c396 Mon Sep 17 00:00:00 2001 From: Soumya Date: Mon, 14 Oct 2024 17:21:19 +0200 Subject: [PATCH] Removed par_matrix implementation - par_matrix removed from matrix.rs and benchmark --- benches/parallel_rayon/matrix_benchmark.rs | 18 --------------- src/structure/matrix.rs | 27 +--------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/benches/parallel_rayon/matrix_benchmark.rs b/benches/parallel_rayon/matrix_benchmark.rs index eaaa1e13..86b39bc9 100644 --- a/benches/parallel_rayon/matrix_benchmark.rs +++ b/benches/parallel_rayon/matrix_benchmark.rs @@ -4,23 +4,6 @@ use peroxide::{ traits::math::{ParallelInnerProduct, ParallelNormed}, }; -pub fn par_matrix_benchmark(cr: &mut Criterion) { - let v: Vec = (0..1000000) - .into_iter() - .map(|i: i32| 2.0 * (i as f64)) - .collect::>(); - - // Result: 1000x1000 matrix: 630.92 µs - cr.bench_function("ser_matrix_bench", |b| { - b.iter(|| black_box(matrix(v.clone(), 1000, 1000, Shape::Row))) - }); - - // Result: 1000x1000 matrix: 9.6995 ms - cr.bench_function("par_matrix_bench", |b| { - b.iter(|| black_box(par_matrix(v.clone(), 1000, 1000, Shape::Row))) - }); -} - pub fn par_matrix_from_index_benchmark(cr: &mut Criterion) { let f = |x: usize, y: usize| 2.0 * (x as f64) * (y as f64); let size: (usize, usize) = (1000, 1000); @@ -112,7 +95,6 @@ pub fn par_matrix_inner_prod_benchmark(cr: &mut Criterion) { criterion_group!( benches, - par_matrix_benchmark, par_matrix_from_index_benchmark, par_matrix_norm_lpq_benchmark, par_matrix_norm_l1_benchmark, diff --git a/src/structure/matrix.rs b/src/structure/matrix.rs index b66267e6..226e7958 100644 --- a/src/structure/matrix.rs +++ b/src/structure/matrix.rs @@ -723,31 +723,6 @@ where } } -/// R-like matrix constructor in parallel -/// -/// # Examples -/// ``` -/// #[macro_use] -/// extern crate peroxide; -/// use peroxide::fuga::*; -/// -/// fn main() { -/// let a = par_matrix(c!(1,2,3,4), 2, 2, Row); -/// a.print(); // Print matrix -/// } -/// ``` -pub fn par_matrix(v: Vec, r: usize, c: usize, shape: Shape) -> Matrix -where - T: Into + Send + Sync, -{ - Matrix { - data: v.into_par_iter().map(|t| t.into()).collect::>(), - row: r, - col: c, - shape, - } -} - /// R-like matrix constructor (Explicit ver.) pub fn r_matrix(v: Vec, r: usize, c: usize, shape: Shape) -> Matrix where @@ -1385,7 +1360,7 @@ impl Matrix { .collect::>() }) .collect::>(); - par_matrix(data, row, col, Row) + matrix(data, row, col, Row) } /// Matrix to `Vec>`