Skip to content

Commit

Permalink
qr_fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
lpawela committed Aug 19, 2019
1 parent e6e5144 commit d1d8fd1
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions randommatrices/src/circular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const COE = CircularEnsemble{1}
const CUE = CircularEnsemble{2}
const CSE = CircularEnsemble{4}

function _qr_fix(z::AbstractMatrix)
q, r = qr(z)
function _qr_fix!(z::AbstractMatrix)
q, r = qr!(z)
d = diag(r)
ph = d./abs.(d)
q = Matrix(q)
Expand All @@ -26,22 +26,27 @@ function _qr_fix(z::AbstractMatrix)
q[:, 1:idim]
end

function _qr_fix(z::AbstractMatrix)
a = copy(z)
_qr_fix!(a)
end

function rand(c::COE)
z = rand(c.g)
u = _qr_fix(z)
u = _qr_fix!(z)
transpose(u)*u
end

function rand(c::CUE)
z = rand(c.g)
u = _qr_fix(z)
u = _qr_fix!(z)
u
end

function rand(c::CSE)
z = rand(c.g)
u = _qr_fix(z)
ur = cat([[0 -1; 1 0] for _=1:round(Int, c.d/2)]..., dims=[1,2])
u = _qr_fix!(z)
ur = cat([[0 -1; 1 0] for _=1:c.d÷2]..., dims=[1,2])
ur*u*ur'*transpose(u)
end

Expand All @@ -57,7 +62,7 @@ end

function rand(c::CircularRealEnsemble)
z = rand(c.g)
_qr_fix(z)
_qr_fix!(z)
end

struct CircularQuaternionEnsemble <: ContinuousMatrixDistribution
Expand All @@ -72,7 +77,7 @@ end

function rand(c::CircularQuaternionEnsemble)
z = rand(c.g)
_qr_fix(z)
_qr_fix!(z)
end


Expand All @@ -90,5 +95,5 @@ end

function rand(c::HaarIsometry)
z = rand(c.g)
_qr_fix(z)
_qr_fix!(z)
end

0 comments on commit d1d8fd1

Please sign in to comment.