Skip to content

Commit aff643d

Browse files
committed
Remove Standard: Distribution<A> restriction using cauchy 0.2.1
1 parent 7bc7ef4 commit aff643d

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ serde-1 = ["ndarray/serde-1", "num-complex/serde"]
2222
[dependencies]
2323
lapacke = "0.2"
2424
num-traits = "0.2"
25+
cauchy = "0.2.1"
26+
num-complex = "0.2.1"
2527
rand = "0.5"
26-
cauchy = "0.2"
27-
28-
[dependencies.num-complex]
29-
version = "0.2.1"
30-
default-features = false
31-
features = ["rand"]
3228

3329
[dependencies.ndarray]
3430
version = "0.12"

src/generate.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Generator functions for matrices
22
33
use ndarray::*;
4-
use rand::{distributions::Standard, prelude::*};
4+
use rand::prelude::*;
55

66
use super::convert::*;
77
use super::error::*;
@@ -25,13 +25,13 @@ where
2525
/// Generate random array
2626
pub fn random<A, S, Sh, D>(sh: Sh) -> ArrayBase<S, D>
2727
where
28+
A: Scalar,
2829
S: DataOwned<Elem = A>,
2930
D: Dimension,
3031
Sh: ShapeBuilder<Dim = D>,
31-
Standard: Distribution<A>,
3232
{
3333
let mut rng = thread_rng();
34-
ArrayBase::from_shape_fn(sh, |_| rng.sample(Standard))
34+
ArrayBase::from_shape_fn(sh, |_| A::rand(&mut rng))
3535
}
3636

3737
/// Generate random unitary matrix using QR decomposition
@@ -40,7 +40,6 @@ where
4040
pub fn random_unitary<A>(n: usize) -> Array2<A>
4141
where
4242
A: Scalar + Lapack,
43-
Standard: Distribution<A>,
4443
{
4544
let a: Array2<A> = random((n, n));
4645
let (q, _r) = a.qr_into().unwrap();
@@ -53,7 +52,6 @@ where
5352
pub fn random_regular<A>(n: usize) -> Array2<A>
5453
where
5554
A: Scalar + Lapack,
56-
Standard: Distribution<A>,
5755
{
5856
let a: Array2<A> = random((n, n));
5957
let (q, mut r) = a.qr_into().unwrap();
@@ -68,7 +66,6 @@ pub fn random_hermite<A, S>(n: usize) -> ArrayBase<S, Ix2>
6866
where
6967
A: Scalar,
7068
S: DataOwned<Elem = A> + DataMut,
71-
Standard: Distribution<A>,
7269
{
7370
let mut a: ArrayBase<S, Ix2> = random((n, n));
7471
for i in 0..n {
@@ -88,7 +85,6 @@ pub fn random_hpd<A, S>(n: usize) -> ArrayBase<S, Ix2>
8885
where
8986
A: Scalar,
9087
S: DataOwned<Elem = A> + DataMut,
91-
Standard: Distribution<A>,
9288
{
9389
let a: Array2<A> = random((n, n));
9490
let ah: Array2<A> = conjugate(&a);

0 commit comments

Comments
 (0)