1
1
//! Generator functions for matrices
2
2
3
3
use ndarray:: * ;
4
- use rand:: { distributions :: Standard , prelude:: * } ;
4
+ use rand:: prelude:: * ;
5
5
6
6
use super :: convert:: * ;
7
7
use super :: error:: * ;
@@ -25,13 +25,13 @@ where
25
25
/// Generate random array
26
26
pub fn random < A , S , Sh , D > ( sh : Sh ) -> ArrayBase < S , D >
27
27
where
28
+ A : Scalar ,
28
29
S : DataOwned < Elem = A > ,
29
30
D : Dimension ,
30
31
Sh : ShapeBuilder < Dim = D > ,
31
- Standard : Distribution < A > ,
32
32
{
33
33
let mut rng = thread_rng ( ) ;
34
- ArrayBase :: from_shape_fn ( sh, |_| rng . sample ( Standard ) )
34
+ ArrayBase :: from_shape_fn ( sh, |_| A :: rand ( & mut rng ) )
35
35
}
36
36
37
37
/// Generate random unitary matrix using QR decomposition
40
40
pub fn random_unitary < A > ( n : usize ) -> Array2 < A >
41
41
where
42
42
A : Scalar + Lapack ,
43
- Standard : Distribution < A > ,
44
43
{
45
44
let a: Array2 < A > = random ( ( n, n) ) ;
46
45
let ( q, _r) = a. qr_into ( ) . unwrap ( ) ;
53
52
pub fn random_regular < A > ( n : usize ) -> Array2 < A >
54
53
where
55
54
A : Scalar + Lapack ,
56
- Standard : Distribution < A > ,
57
55
{
58
56
let a: Array2 < A > = random ( ( n, n) ) ;
59
57
let ( q, mut r) = a. qr_into ( ) . unwrap ( ) ;
@@ -68,7 +66,6 @@ pub fn random_hermite<A, S>(n: usize) -> ArrayBase<S, Ix2>
68
66
where
69
67
A : Scalar ,
70
68
S : DataOwned < Elem = A > + DataMut ,
71
- Standard : Distribution < A > ,
72
69
{
73
70
let mut a: ArrayBase < S , Ix2 > = random ( ( n, n) ) ;
74
71
for i in 0 ..n {
@@ -88,7 +85,6 @@ pub fn random_hpd<A, S>(n: usize) -> ArrayBase<S, Ix2>
88
85
where
89
86
A : Scalar ,
90
87
S : DataOwned < Elem = A > + DataMut ,
91
- Standard : Distribution < A > ,
92
88
{
93
89
let a: Array2 < A > = random ( ( n, n) ) ;
94
90
let ah: Array2 < A > = conjugate ( & a) ;
0 commit comments