@@ -169,6 +169,20 @@ used to control the density of eigenvalues near `λ = 0`.
169
169
- `beta`: Dyson index
170
170
- `a`: Parameter used for weighting the joint probability density function of the ensemble
171
171
172
+ ## Examples
173
+ ```@example
174
+ julia> rand(GaussianLaguerre(1, 2), 2)
175
+ 2×2 Matrix{Float64}:
176
+ 5.08544 -0.156801
177
+ -0.156801 3.17245
178
+
179
+ julia> rand(GaussianLaguerre(4, 8), 2)
180
+ 4×4 Matrix{ComplexF64}:
181
+ 2.66965+0.0im 0.616044-0.336025im -8.48419e-18-2.17815e-17im 0.661922-0.190965im
182
+ 0.616044+0.336025im 3.27444+0.0im -0.661922+0.190965im -1.239e-17+8.84953e-17im
183
+ -8.48419e-18+2.17815e-17im -0.661922-0.190965im 2.66965+0.0im 0.616044+0.336025im
184
+ 0.661922+0.190965im -1.239e-17-8.84953e-17im 0.616044-0.336025im 3.27444+0.0im
185
+ ```
172
186
## References:
173
187
- Edelman and Rao, 2005
174
188
"""
@@ -181,27 +195,39 @@ const Wishart = GaussianLaguerre
181
195
# TODO Check - the eigenvalue distribution looks funky
182
196
# TODO The appropriate matrix size should be calculated from a and one matrix dimension
183
197
"""
184
- rand(d::GaussianLaguerre, dims::Tuple )
198
+ rand(d::GaussianLaguerre, n::Int )
185
199
186
200
Generate a random matrix sampled from the Gaussian Laguerre ensemble (also known as the Wishart ensemble)
187
- with parameters defined in `d` and dimensions given by `dims` .
201
+ with parameters defined in `d`.
188
202
189
- The Dyson index `β` is restricted to `β = 1,2` or `4`, for real, complex, and quaternionic fields, respectively.
203
+ The Dyson index `β` is restricted to `β = 1,2` (`n × n` matrix) or `4` (`2n × 2n` block matrix representation),
204
+ for real, complex, and quaternionic fields, respectively.
190
205
"""
191
- function rand (d:: GaussianLaguerre , dims:: Dim2 )
192
- n = 2.0 * a/ d. beta
193
- if d. beta == 1 # real
194
- A = randn (dims)
195
- elseif d. beta == 2 # complex
196
- A = randn (dims) + im* randn (dims)
197
- elseif d. beta == 4 # quaternion
198
- # Employs 2x2 matrix representation of quaternions
199
- X = randn (dims) + im* randn (dims)
200
- Y = randn (dims) + im* randn (dims)
201
- A = [X Y; - conj (Y) conj (X)]
202
- error (" beta = $(d. beta) is not implemented" )
206
+ function rand (d:: GaussianLaguerre , n:: Int )
207
+ a, beta = d. a, d. beta
208
+ a >= beta * n / 2 || throw (ArgumentError (" the minimum value of `a` must be `βn/2`." ))
209
+ m = Int (2 * a/ beta)
210
+ if beta == 1 # real
211
+ A = randn (m, n)
212
+ elseif beta == 2 # complex
213
+ A = randn (ComplexF64, m, n)
214
+ elseif beta == 4 # quaternion
215
+ # employs 2x2 matrix representation of quaternions
216
+ X = randn (ComplexF64, m, n)
217
+ Y = randn (ComplexF64, m, n)
218
+ A = Matrix {ComplexF64} (undef, 2 m, 2 n)
219
+ @inbounds for j in 1 : n, i in 1 : m
220
+ x = X[i, j]
221
+ y = Y[i, j]
222
+ A[i, j] = x
223
+ A[i+ m, j] = - conj (y)
224
+ A[i, j+ n] = y
225
+ A[i+ m, j+ n] = conj (x)
226
+ end
227
+ else
228
+ error (" beta = $(beta) is not implemented" )
203
229
end
204
- return (A * A' ) / dims[ 1 ]
230
+ return (A' * A) / n
205
231
end
206
232
207
233
"""
0 commit comments