Skip to content

Commit

Permalink
Removed par_matrix implementation
Browse files Browse the repository at this point in the history
- par_matrix removed from matrix.rs
and benchmark
  • Loading branch information
soumyasen1809 committed Oct 14, 2024
1 parent 3737099 commit 863ad6a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
18 changes: 0 additions & 18 deletions benches/parallel_rayon/matrix_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ use peroxide::{
traits::math::{ParallelInnerProduct, ParallelNormed},
};

pub fn par_matrix_benchmark(cr: &mut Criterion) {
let v: Vec<f64> = (0..1000000)
.into_iter()
.map(|i: i32| 2.0 * (i as f64))
.collect::<Vec<f64>>();

// 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);
Expand Down Expand Up @@ -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,
Expand Down
27 changes: 1 addition & 26 deletions src/structure/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(v: Vec<T>, r: usize, c: usize, shape: Shape) -> Matrix
where
T: Into<f64> + Send + Sync,
{
Matrix {
data: v.into_par_iter().map(|t| t.into()).collect::<Vec<f64>>(),
row: r,
col: c,
shape,
}
}

/// R-like matrix constructor (Explicit ver.)
pub fn r_matrix<T>(v: Vec<T>, r: usize, c: usize, shape: Shape) -> Matrix
where
Expand Down Expand Up @@ -1385,7 +1360,7 @@ impl Matrix {
.collect::<Vec<f64>>()
})
.collect::<Vec<f64>>();
par_matrix(data, row, col, Row)
matrix(data, row, col, Row)
}

/// Matrix to `Vec<Vec<f64>>`
Expand Down

0 comments on commit 863ad6a

Please sign in to comment.