11//! Generator functions for matrices
22
33use ndarray:: * ;
4- use rand:: { distributions :: Standard , prelude:: * } ;
4+ use rand:: prelude:: * ;
55
66use super :: convert:: * ;
77use super :: error:: * ;
@@ -25,13 +25,13 @@ where
2525/// Generate random array
2626pub fn random < A , S , Sh , D > ( sh : Sh ) -> ArrayBase < S , D >
2727where
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
4040pub fn random_unitary < A > ( n : usize ) -> Array2 < A >
4141where
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 ( ) ;
5352pub fn random_regular < A > ( n : usize ) -> Array2 < A >
5453where
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>
6866where
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>
8885where
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