1
1
//! Generator functions for matrices
2
2
3
3
use ndarray:: * ;
4
- use rand:: prelude :: * ;
4
+ use rand:: Rng ;
5
5
6
6
use super :: convert:: * ;
7
7
use super :: error:: * ;
24
24
25
25
/// Generate random array with given shape
26
26
///
27
- /// - This function uses [rand::thread_rng ].
27
+ /// - This function uses [rand::rng ].
28
28
/// See [random_using] for using another RNG
29
29
pub fn random < A , S , Sh , D > ( sh : Sh ) -> ArrayBase < S , D >
30
30
where
33
33
D : Dimension ,
34
34
Sh : ShapeBuilder < Dim = D > ,
35
35
{
36
- let mut rng = thread_rng ( ) ;
36
+ let mut rng = rand :: rng ( ) ;
37
37
random_using ( sh, & mut rng)
38
38
}
39
39
@@ -55,13 +55,13 @@ where
55
55
///
56
56
/// - Be sure that this it **NOT** a uniform distribution.
57
57
/// Use it only for test purpose.
58
- /// - This function uses [rand::thread_rng ].
58
+ /// - This function uses [rand::rng ].
59
59
/// See [random_unitary_using] for using another RNG.
60
60
pub fn random_unitary < A > ( n : usize ) -> Array2 < A >
61
61
where
62
62
A : Scalar + Lapack ,
63
63
{
64
- let mut rng = thread_rng ( ) ;
64
+ let mut rng = rand :: rng ( ) ;
65
65
random_unitary_using ( n, & mut rng)
66
66
}
67
67
@@ -84,13 +84,13 @@ where
84
84
///
85
85
/// - Be sure that this it **NOT** a uniform distribution.
86
86
/// Use it only for test purpose.
87
- /// - This function uses [rand::thread_rng ].
87
+ /// - This function uses [rand::rng ].
88
88
/// See [random_regular_using] for using another RNG.
89
89
pub fn random_regular < A > ( n : usize ) -> Array2 < A >
90
90
where
91
91
A : Scalar + Lapack ,
92
92
{
93
- let mut rng = rand:: thread_rng ( ) ;
93
+ let mut rng = rand:: rng ( ) ;
94
94
random_regular_using ( n, & mut rng)
95
95
}
96
96
@@ -114,14 +114,14 @@ where
114
114
115
115
/// Random Hermite matrix
116
116
///
117
- /// - This function uses [rand::thread_rng ].
117
+ /// - This function uses [rand::rng ].
118
118
/// See [random_hermite_using] for using another RNG.
119
119
pub fn random_hermite < A , S > ( n : usize ) -> ArrayBase < S , Ix2 >
120
120
where
121
121
A : Scalar ,
122
122
S : DataOwned < Elem = A > + DataMut ,
123
123
{
124
- let mut rng = rand:: thread_rng ( ) ;
124
+ let mut rng = rand:: rng ( ) ;
125
125
random_hermite_using ( n, & mut rng)
126
126
}
127
127
@@ -147,15 +147,15 @@ where
147
147
/// Random Hermite Positive-definite matrix
148
148
///
149
149
/// - Eigenvalue of matrix must be larger than 1 (thus non-singular)
150
- /// - This function uses [rand::thread_rng ].
150
+ /// - This function uses [rand::rng ].
151
151
/// See [random_hpd_using] for using another RNG.
152
152
///
153
153
pub fn random_hpd < A , S > ( n : usize ) -> ArrayBase < S , Ix2 >
154
154
where
155
155
A : Scalar ,
156
156
S : DataOwned < Elem = A > + DataMut ,
157
157
{
158
- let mut rng = rand:: thread_rng ( ) ;
158
+ let mut rng = rand:: rng ( ) ;
159
159
random_hpd_using ( n, & mut rng)
160
160
}
161
161
0 commit comments