• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iitis / QuantumInformation.jl / 20865432878

09 Jan 2026 09:01PM UTC coverage: 92.445% (+16.4%) from 76.078%
20865432878

push

github

web-flow
SCS compat problems solution (#107)

* code quality tests

* update deps

* rmeove old julia versions in CI

* update docs build

* update CI

* increase test coverage

* update documentation

* fix all warnings

48 of 50 new or added lines in 8 files covered. (96.0%)

15 existing lines in 6 files now uncovered.

673 of 728 relevant lines covered (92.45%)

105.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/randomqobjects.jl
1
export HaarKet, HilbertSchmidtStates, ChoiJamiolkowskiMatrices,
2
    HaarPOVM, WishartPOVM, VonNeumannPOVM
3

4

5
struct HaarKet{β} <: QIContinuousMatrixDistribution
6
    d::Int
6✔
7
end
8

9
HaarKet(d::Int) = HaarKet{2}(d)
2✔
10

11
function rand(rng::AbstractRNG, h::HaarKet{1})
2✔
12
    ψ = randn(rng, h.d)
12✔
13
    renormalize!(ψ)
11✔
UNCOV
14
    ψ
1✔
15
 end
16

17
 function rand(rng::AbstractRNG, h::HaarKet{2})
4✔
18
     ψ = randn(rng, h.d) + 1im * randn(rng, h.d)
24✔
19
     renormalize!(ψ)
22✔
UNCOV
20
     ψ
2✔
21
  end
22

23
# Random mixed states
24
struct HilbertSchmidtStates{β, K} <: QIContinuousMatrixDistribution
25
    w::WishartEnsemble
26
    d::Int
27

28
    function HilbertSchmidtStates{β, K}(d::Int) where {β, K}
12✔
29
        w = WishartEnsemble{β, K}(d)
12✔
30
        new(w, w.d)
12✔
31
    end
32
end
33
HilbertSchmidtStates{β}(d::Int) where β = HilbertSchmidtStates{β, 1}(d)
2✔
34
HilbertSchmidtStates(d::Int) = HilbertSchmidtStates{2, 1}(d)
2✔
35

36
function rand(rng::AbstractRNG, hs::HilbertSchmidtStates{β, K}) where {β, K}
4✔
37
    ρ = rand(rng, hs.w)
4✔
38
    renormalize!(ρ)
4✔
UNCOV
39
    ρ
2✔
40
end
41

42
#Random channels
43
struct ChoiJamiolkowskiMatrices{β, K} <: QIContinuousMatrixDistribution
44
    w::WishartEnsemble
45
    idim::Int
46
    odim::Int
47

48
    function ChoiJamiolkowskiMatrices{β, K}(idim::Int, odim::Int)  where {β, K}
24✔
49
        w = WishartEnsemble{β, K}(idim * odim)
24✔
50
        new(w, idim, odim)
24✔
51
    end
52
end
53

54
function ChoiJamiolkowskiMatrices{β}(idim::Int, odim::Int) where β
12✔
55
    ChoiJamiolkowskiMatrices{β, 1}(idim, odim)
12✔
56
end
57

58
function ChoiJamiolkowskiMatrices{β}(d::Int) where β
2✔
59
    ChoiJamiolkowskiMatrices{β}(d, d)
2✔
60
end
61

62
function ChoiJamiolkowskiMatrices(idim::Int, odim::Int)
8✔
63
    ChoiJamiolkowskiMatrices{2}(idim, odim)
8✔
64
end
65

66
function ChoiJamiolkowskiMatrices(d::Int)
2✔
67
    ChoiJamiolkowskiMatrices(d, d)
2✔
68
end
69

70
function rand(rng::AbstractRNG, c::ChoiJamiolkowskiMatrices{β, K}) where {β, K}
8✔
71
    z = rand(rng, c.w)
8✔
72
    y = ptrace(z, [c.odim, c.idim], [1])
16✔
73
    sy = funcmh!(x -> 1 / sqrt(x), y)
40✔
74
    onesy = Matrix(I, c.odim, c.odim) ⊗ sy # onesy = eye(c.odim) ⊗ sy
8✔
75
    DynamicalMatrix(onesy * z * onesy, c.idim, c.odim)
8✔
76
end
77

78
# Random POVMs implemented according to
79
# https://arxiv.org/pdf/1902.04751.pdf
80
abstract type AbstractHaarPOVM <: QIContinuousMatrixDistribution
81
end
82

83
struct HaarPOVM{N} <: AbstractHaarPOVM
84
    idim::Int
85
    odim::Int
86
    c::HaarIsometry
87

88
    function HaarPOVM{N}(idim::Int, odim::Int) where N
4✔
89
        c = HaarIsometry(idim::Int, N*odim::Int)
6✔
90
        new(idim, odim, c)
2✔
91
    end
92
end
93
# N controls the rank (mixedness) of the effects, N=1 gives rank-one effects
94
HaarPOVM(idim::Int, odim::Int) = HaarPOVM{1}(idim, odim)
4✔
95

96
#this should use slicing of V
97
function rand(rng::AbstractRNG, c::HaarPOVM{N}) where N
2✔
98
    V = rand(rng, c.c)
2✔
99
    POVMMeasurement([V'*(ketbra(i, i, c.odim) ⊗ 𝕀(N))*V for i=1:c.odim])
2✔
100
end
101

102
struct VonNeumannPOVM <: AbstractHaarPOVM
103
    d::Int
104
    c::CUE
105

106
    function VonNeumannPOVM(d::Int)
2✔
107
        c = CUE(d)
2✔
108
        new(d, c)
2✔
109
    end
110
end
111

112
function rand(rng::AbstractRNG, c::VonNeumannPOVM)
2✔
113
    V = rand(rng, c.c)
2✔
114
    POVMMeasurement([proj(V[:, i]) for i=1:c.d])
2✔
115
end
116

117
struct WishartPOVM{V} <: QIContinuousMatrixDistribution
118
    idim::Int
119
    odim::Int
120
    c::Vector{WishartEnsemble}
121

122
    function WishartPOVM{V}(idim::Int) where V
2✔
123
        odim = length(V)
2✔
124
        c = [WishartEnsemble{2, v}(idim) for v=V]
2✔
125
        new(idim, odim, c)
2✔
126
    end
127
end
128

129
function WishartPOVM(idim::Int, odim::Int, K::Real=1)
4✔
130
    V = Tuple(round.(Int, K .* ones(odim)))
4✔
131
    WishartPOVM{V}(idim)
2✔
132
end
133

134
function rand(rng::AbstractRNG, c::WishartPOVM)
2✔
135
    Ws = map(x->rand(rng, x), c.c)
8✔
136
    S = sum(Ws)
2✔
137
    Ssq = funcmh!(x->1/sqrt(x), S)
6✔
138
    POVMMeasurement([Ssq * W * Ssq for W=Ws])
2✔
139
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc