Skip to content

Commit

Permalink
WIP: Matvec
Browse files Browse the repository at this point in the history
  • Loading branch information
tbetcke committed Jul 28, 2022
1 parent 530217f commit 73641f4
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 601 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ itertools = "0.10"
rand_distr = "0.4"
thiserror = "1.0"
matrixmultiply = "0.3"
approx = "0.5"
approx = { version = "0.5", features=["num-complex"] }

[dev-dependencies]
criterion = { version = "0.3", features = ["html_reports"] }
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod matrix;
pub mod matrix_ref;
pub mod scalar_mult;
pub mod addition;
pub mod tools;

//pub mod traits;
//pub mod slice_matrix;
Expand Down
31 changes: 2 additions & 29 deletions src/matrix/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::data_container::DataContainerMut;
use crate::traits::*;
use crate::types::*;
use rand::prelude::*;
use rand_distr::{Distribution, StandardNormal};
use rand_distr::StandardNormal;
use crate::tools::*;

use super::GenericBaseMatrixMut;

Expand All @@ -30,31 +31,3 @@ rand_impl!(f64);
rand_impl!(c32);
rand_impl!(c64);

// Random number implementations for the scalar types
trait RandScalar: Scalar {
fn random_scalar<R: Rng, D: Distribution<Self::Real>>(rng: &mut R, dist: &D) -> Self;
}

impl RandScalar for f32 {
fn random_scalar<R: Rng, D: Distribution<Self>>(rng: &mut R, dist: &D) -> Self {
dist.sample(rng)
}
}

impl RandScalar for f64 {
fn random_scalar<R: Rng, D: Distribution<Self>>(rng: &mut R, dist: &D) -> Self {
dist.sample(rng)
}
}

impl RandScalar for c32 {
fn random_scalar<R: Rng, D: Distribution<Self::Real>>(rng: &mut R, dist: &D) -> Self {
c32::new(dist.sample(rng), dist.sample(rng))
}
}

impl RandScalar for c64 {
fn random_scalar<R: Rng, D: Distribution<Self::Real>>(rng: &mut R, dist: &D) -> Self {
c64::new(dist.sample(rng), dist.sample(rng))
}
}
Loading

0 comments on commit 73641f4

Please sign in to comment.