1
+ export rand, Ginibre, NeedPiecewiseCorrection, jpdfGinibre,
2
+ CircularOrthogonal, CircularUnitary, CircularSymplectic
3
+ import Base. rand
4
+
1
5
# Computes samplex of real or complex Haar matrices of size nxn
2
6
#
3
- # For beta=1,2,4, generates random matrices from the circular
4
- # orthogonal, unitary and symplectic ensembles (COE, CUE, CSE) respectively
5
- # These are collectively known as the Dyson circular ensembles.
7
+ # For beta=1,2,4, generates random orthogonal, unitary and symplectic matrices
8
+ # of uniform Haar measure.
6
9
# These matrices are distributed with uniform Haar measure over the
7
10
# classical orthogonal, unitary and symplectic groups O(N), U(N) and
8
11
# Sp(N)~USp(2N) respectively.
12
15
# This addresses an inconsistency in the Householder reflections as
13
16
# implemented in most versions of LAPACK
14
17
# Method 0: No correction
15
- # Method 1: Edelman correction - multiply rows by uniform random phases
16
- # Method 2: Mezzadri correction - multiply rows by phases of diag(R)
18
+ # Method 1: Multiply rows by uniform random phases
19
+ # Method 2: Multiply rows by phases of diag(R)
17
20
# References:
18
21
# Edelman and Rao, 2005
19
22
# Mezzadri, 2006, math-ph/0609050
20
23
# TODO implement O(n^2) method
21
- function HaarMatrix (n:: Integer , beta:: Integer , doCorrection:: Integer )
22
- M= GinibreMatrix (n, beta)
24
+ function rand (W:: UniformHaar , doCorrection:: Integer )
25
+ n, beta = W. N, W. beta
26
+ M= rand (Ginibre (n, beta))
23
27
q,r= qr (M)
24
28
if doCorrection== 0
25
29
q
49
53
50
54
# By default, always do piecewise correction
51
55
# For most applications where you use the HaarMatrix as a similarity transform
52
- # it doesn't matter, but better safe than sorry... let the user choose
53
- HaarMatrix (n:: Integer , beta:: Integer ) = HaarMatrix (n, beta, 1 )
54
-
56
+ # it doesn't matter, but better safe than sorry... let the user choose else
57
+ rand (W:: UniformHaar ) = rand (W, 1 )
55
58
56
59
# A utility method to check if the piecewise correction is needed
57
60
# This checks the R part of the QR factorization; if correctly done,
58
61
# the diagonals are all chi variables so are non-negative
59
62
function NeedPiecewiseCorrection ()
60
63
n= 20
61
- R= qr (randn (n,n ))[2 ]
64
+ R= qr (randn (Ginibre ( 2 ,n) ))[2 ]
62
65
return any ([x< 0 for x in diag (R)])
63
66
end
64
67
67
70
# This ensemble lives in GL(N, F), the set of all invertible N x N matrices
68
71
# over the field F
69
72
# For beta=1,2,4, F=R, C, H respectively
70
- function GinibreMatrix (n:: Integer , beta:: Integer )
73
+ immutable Ginibre <: ContinuousMatrixDistribution
74
+ beta:: Float64
75
+ N:: Integer
76
+ end
77
+
78
+ function rand (W:: Ginibre )
71
79
if beta== 1
72
80
randn (n,n)
73
81
elseif beta== 2
@@ -87,6 +95,28 @@ function jpdfGinibre{z<:Complex}(Z::AbstractMatrix{z})
87
95
pi ^ (size (Z,1 )^ 2 )* exp (- trace (Z' * Z))
88
96
end
89
97
98
+ # Dyson Circular orthogonal, unitary and symplectic ensembles
99
+ immutable CircularOrthogonal
100
+ N :: Int64
101
+ end
102
+
103
+ function rand (M:: CircularOrthogonal )
104
+ U = rand (Ginibre (2 , M. N))
105
+ U * U'
106
+ end
107
+
108
+ immutable CircularUnitary
109
+ N :: Int64
110
+ end
111
+
112
+ rand (M:: CircularUnitary ) = rand (Ginibre (2 , M. N))
113
+
114
+ immutable CircularSymplectic
115
+ N :: Int64
116
+ end
117
+
118
+ rand (M:: CircularSymplectic ) = error (" Not implemented" )
119
+
90
120
# TODO maybe, someday
91
121
# Haar measure on U(N) in terms of local coordinates
92
122
# Zyczkowski and Kus, Random unitary matrices, J. Phys. A: Math. Gen. 27,
0 commit comments