Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lp/gpurandqobj #87

Merged
merged 15 commits into from
Oct 19, 2020
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ os:
- linux
- osx
julia:
- 1.2
- 1.3
- 1.4
- nightly
- 1.5

notifications:
email: false
Expand All @@ -23,7 +21,7 @@ after_success:
jobs:
include:
- stage: "Documentation"
julia: 1.0
julia: 1.5
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.add("SCS"); Pkg.add("Documenter"); Pkg.instantiate();
Expand Down
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[compat]
julia = "0.7, 1.0, 1.1, 1.2"
julia = "1.4, 1.5"

[extras]
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["SparseArrays", "Test"]
9 changes: 0 additions & 9 deletions REQUIRE

This file was deleted.

17 changes: 17 additions & 0 deletions bench.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using CuArrays, CuTensorOperations, QuantumInformation

for (fname, f) in ((:bench_device, QuantumInformation.curand), (:bench_cpu, rand))
@eval begin
function $fname(d=256)
c = HaarKet(d^2)
psi = $f(c)
@time ptrace(psi, [d, d], 1)
@time ptrace(psi, [d, d], 2)
end
end
end

bench_device()
bench_device()
bench_cpu()
bench_cpu()
15 changes: 0 additions & 15 deletions curandommatrices/src/CuRandomMatrices.jl

This file was deleted.

42 changes: 0 additions & 42 deletions curandommatrices/src/circular.jl

This file was deleted.

10 changes: 0 additions & 10 deletions curandommatrices/src/ginibre.jl

This file was deleted.

4 changes: 0 additions & 4 deletions curandommatrices/src/wigner.jl

This file was deleted.

4 changes: 0 additions & 4 deletions curandommatrices/src/wishart.jl

This file was deleted.

74 changes: 0 additions & 74 deletions curandommatrices/test/circular.jl

This file was deleted.

23 changes: 0 additions & 23 deletions curandommatrices/test/ginibre.jl

This file was deleted.

17 changes: 0 additions & 17 deletions curandommatrices/test/runtests.jl

This file was deleted.

11 changes: 0 additions & 11 deletions curandommatrices/test/wigner.jl

This file was deleted.

15 changes: 0 additions & 15 deletions curandommatrices/test/wishart.jl

This file was deleted.

8 changes: 6 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using Documenter, QuantumInformation

format = Documenter.HTML(edit_link = "master",
prettyurls = get(ENV, "CI", nothing) == "true",
)

makedocs(
clean = true,
format = :html,
format = format,
sitename = "QuantumInformation.jl",
authors = "Piotr Gawron, Dariusz Kurzyk, Łukasz Pawela",
assets = ["assets/favicon.ico"],
Expand Down Expand Up @@ -31,5 +35,5 @@ makedocs(
deploydocs(
deps = Deps.pip("pygments", "mkdocs", "python-markdown-math"),
target = "build",
repo = "github.com/ZKSI/QuantumInformation.jl.git"
repo = "github.com/iitis/QuantumInformation.jl.git"
)
5 changes: 0 additions & 5 deletions src/QuantumInformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ include("../randommatrices/src/RandomMatrices.jl")
using .RandomMatrices
eval(Expr(:export, names(RandomMatrices)...))

using Requires
@init @require CuArrays = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" include("../curandommatrices/src/CuRandomMatrices.jl")
@init @require CuArrays = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" using ..CuRandomMatrices
@init @require CuArrays = "3a865a2d-5b23-5a0f-bc46-62713ec82fae" export curand

include("base.jl")
include("randomqobjects.jl")
include("gates.jl")
Expand Down
16 changes: 5 additions & 11 deletions src/convex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ $(SIGNATURES)

Return [diamond norm](https://arxiv.org/pdf/1207.5726.pdf) of dynamical matrix `Φ`.
"""
function norm_diamond(Φ::AbstractQuantumOperation{T}, method=:primal, eps=1e-7) where T<:AbstractMatrix{<:Number}
ψ = convert(DynamicalMatrix{T}, Φ)
(method == :primal || method == :dual) || throw(ArgumentError("method must be either :primal or :dual"))
norm_diamond(Φ::AbstractQuantumOperation, method::Symbol=:primal, eps=1e-7) = norm_diamond(Φ, Val(method), eps)

method == :dual ? norm_diamond_dual(Φ,eps) : norm_diamond_primal(Φ,eps)
end


function norm_diamond_primal(Φ::DynamicalMatrix{T}, eps) where T<:AbstractMatrix{<:Number}
function norm_diamond(Φ::DynamicalMatrix, ::Val{:primal}, eps)
J = Φ.matrix
# TODO: compare d1, d2 with idim, odim
d1 = Φ.idim
Expand All @@ -31,12 +25,12 @@ function norm_diamond_primal(Φ::DynamicalMatrix{T}, eps) where T<:AbstractMatri
constraints += [𝕀(d2) ⊗ ρ₀ X; X' 𝕀(d2) ⊗ ρ₁] in :SDP

problem = maximize(t, constraints)
solve!(problem, SCSSolver(verbose=0, eps=eps))
solve!(problem, () -> SCS.Optimizer(verbose=false, eps=eps))
problem.optval
end


function norm_diamond_dual(Φ::DynamicalMatrix{T}, eps) where T<:AbstractMatrix{<:Number}
function norm_diamond(Φ::DynamicalMatrix, ::Val{:dual}, eps)
J = Φ.matrix
# TODO: compare d1, d2 with idim, odim
d1 = Φ.idim
Expand All @@ -52,7 +46,7 @@ function norm_diamond_dual(Φ::DynamicalMatrix{T}, eps) where T<:AbstractMatrix{
constraints += Z+Z' in :SDP

problem = minimize(t, constraints)
solve!(problem, SCSSolver(verbose=0, eps=eps))
solve!(problem, () -> SCS.Optimizer(verbose=false, eps=eps))
problem.optval
end

Expand Down
4 changes: 2 additions & 2 deletions src/ptrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function ptrace(ψ::AbstractVector{<:Number}, idims::Vector{Int}, sys::Int)
m = unres(ψ, cols)
length(idims) == 2 ? () : throw(ArgumentError("idims has to be of length 2"))
if sys == 1
return m'*m
return transpose(m) * conj.(m)
elseif sys == 2
return m*m'
return m * transpose(conj.(m))
else
throw(ArgumentError("sys must be 1 or 2"))
end
Expand Down
2 changes: 1 addition & 1 deletion src/randomqobjects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ struct WishartPOVM{V} <: QIContinuousMatrixDistribution
end

function WishartPOVM(idim::Int, odim::Int, K::Real=1)
V = Tuple(K .* ones(odim))
V = Tuple(round.(Int, K .* ones(odim)))
WishartPOVM{V}(idim)
end

Expand Down
Loading