Skip to content

Commit

Permalink
ADD: Add parallel traits into fuga
Browse files Browse the repository at this point in the history
  • Loading branch information
Axect committed Oct 19, 2024
1 parent 65ec00c commit a0bcb33
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/fuga/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ pub use crate::traits::{
sugar::{Scalable, ScalableMut, VecOps, ConvToMat},
};

#[cfg(feature = "parallel")]
pub use crate::traits::{
fp::{ParallelFPVector, ParallelFPMatrix},
math::{ParallelInnerProduct, ParallelMatrixProduct, ParallelNormed, ParallelVector, ParallelVectorProduct},
mutable::ParallelMutFP,
};

#[allow(unused_imports)]
pub use crate::structure::{
matrix::*,
Expand Down
20 changes: 20 additions & 0 deletions src/structure/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,16 @@ impl Vector for Matrix {

impl Normed for Matrix {
type UnsignedScalar = f64;

/// Norm of Matrix
///
/// # Example
/// ```
/// use peroxide::fuga::*;
///
/// let a = ml_matrix("1 2;3 4");
/// assert_eq!(a.norm(Norm::F), (1f64 + 4f64 + 9f64 + 16f64).sqrt());
/// ```
fn norm(&self, kind: Norm) -> f64 {
match kind {
Norm::F => {
Expand Down Expand Up @@ -1646,6 +1656,16 @@ impl Normed for Matrix {
impl ParallelNormed for Matrix {
type UnsignedScalar = f64;

/// Parallel version of norm
///
/// # Example
/// ```
/// use peroxide::fuga::*;
///
/// let a = ml_matrix("1 2;3 4");
/// assert_eq!(a.par_norm(Norm::F), (1f64 + 4f64 + 9f64 + 16f64).sqrt());
/// ```
///
fn par_norm(&self, kind: Norm) -> f64 {
match kind {
Norm::F => {
Expand Down

0 comments on commit a0bcb33

Please sign in to comment.