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

iitis / QuantumInformation.jl / 402

pending completion
402

push

travis-ci

pgawron
Merge branch 'master' into pg/channels

49 of 49 new or added lines in 9 files covered. (100.0%)

478 of 587 relevant lines covered (81.43%)

187.0 hits per line

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

40.0
/src/channels/applications.jl
1
export applychannel
2

3
################################################################################
4
# Application of channels
5
################################################################################
6
"""
7
$(SIGNATURES)
8
- `Φ`: dynamical matrix.
9
- `ρ`: quantum state.
10

11
Application of dynamical matrix into state `ρ`.
12
"""
13
function applychannel(Φ::DynamicalMatrix{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{T}) where T<:Number
14
    ptrace(Φ.matrix * (Diagonal{T}(I, Φ.odim)⊗transpose(ρ)), [Φ.odim, Φ.idim], [2])
6✔
15
end
16

17
"""
18
$(SIGNATURES)
19
- `Φ`: list of vectors.
20
- `ρ`: input matrix.
21

22
Return application of channel `Φ`` on `ρ`. Kraus representation of quantum channel
23
\$\\Phi\$ is a set \$\\{K_i\\}_{i\\in I}\$ of bounded operators on \$\\mathcal{H}\$
24
such that \$\\sum_{i\\in I} K_i^\\dagger K_i = \\mathcal{1}\$.
25
Then \$\\Phi(\\rho)=\\sum_{i\\in I} K_i \\rho K_i^\\dagger\$.
26
"""
27
function applychannel(Φ::KrausOperators{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{<:Number})
28
    sum(k * ρ * k' for k in Φ.matrices)
4✔
29
end
30

31
"""
32
$(SIGNATURES)
33
- `Φ`: super-operator matrix.
34
- `ρ`: quantum state.
35

36
Application of super-operator matrix into state `ρ`.
37
"""
38
function applychannel(Φ::SuperOperator{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{<:Number})
39
    unres(Φ.matrix * res(ρ))
12✔
40
end
41

42
"""
43
$(SIGNATURES)
44
- `Φ`: Stinespring representation of quantum channel.
45
- `ρ`: quantum state.
46
- `dims`: dimensions of registers of `ρ`.
47

48
Application of Stinespring representation of quantum channel into state `ρ`.
49
"""
50
function applychannel(Φ::Stinespring{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{<:Number})
51
    s = Φ.matrix * ρ * Φ.matrix'
10✔
52
    ptrace(s, [Φ.odim, Φ.odim*Φ.idim], [2])
4✔
53
end
54

55
function applychannel(Φ::IdentityChannel{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{<:Number})
56
    # TODO: promote type
57
    ρ
×
58
end
59

60
function applychannel(Φ::UnitaryChannel{<:AbstractMatrix{<:Number}}, ρ::AbstractMatrix{<:Number})
61
    # TODO: promote type
62
    Φ.matrix*ρ*Φ.matrix'
×
63
end
64

65
function applychannel(Φ::AbstractQuantumOperation, ψ::AbstractVector{<:Number})
66
    # TODO: promote type
67
    applychannel(Φ, proj(ψ))
×
68
end
69

70
function applychannel(Φ::UnitaryChannel{<:AbstractMatrix{<:Number}}, ψ::AbstractVector{<:Number})
71
    # TODO: promote type
72
    Φ.matrix*ψ
×
73
end
74

75
function applychannel(Φ::IdentityChannel{<:AbstractMatrix{<:Number}}, ψ::AbstractVector{<:Number})
76
    # TODO: promote type
77
    ψ
×
78
end
79

80
function applychannel(Φ::POVMMeasurement{T}, ρ::AbstractMatrix{<:Number}) where T<:AbstractMatrix{<:Number}
81
    # TODO: Check if idim and odim are compatible with matrix and length
82
    probs = [real(tr(p'*ρ)) for p in Φ.matrices]
×
83
    Diagonal(probs)
×
84
end
85

86
function applychannel(Φ::PostSelectionMeasurement{T}, ρ::AbstractMatrix{<:Number}) where T<:AbstractMatrix{<:Number}
87
    # TODO: Check if idim and odim are compatible with matrix and length
88
    e = Φ.matrix
×
89
    e * ρ * e'
×
90
end
91

92
################################################################################
93
# making channels callable
94
################################################################################
95
for qop in (:KrausOperators, :SuperOperator, :DynamicalMatrix, :Stinespring,
96
    :UnitaryChannel, :POVMMeasurement, :PostSelectionMeasurement)
97
    @eval begin
98
        function (Φ::$qop)(ρ)
99
            applychannel(Φ, ρ)
30✔
100
        end
101
    end
102
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

© 2023 Coveralls, Inc