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

Add JET.jl runtest #61

Merged
merged 16 commits into from
Apr 8, 2024
Merged
11 changes: 10 additions & 1 deletion .github/workflows/CI.yml → .github/workflows/Runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# for core tests
version:
- '1.8'
- '1.9'
Expand All @@ -40,6 +41,14 @@ jobs:
- x64
group:
- Core

# for code quality tests
include:
- version: '1'
os: 'ubuntu-latest'
arch: 'x64'
group: 'Code-Quality'

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
Expand All @@ -58,4 +67,4 @@ jobs:
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: true
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

[compat]
Aqua = "0.6, 0.7, 0.8"
DiffEqCallbacks = "2.24, 3"
DiffEqCallbacks = "2, 3"
Distributed = "<0.0.1, 1"
FFTW = "1.5"
Graphs = "1.7.4"
Graphs = "1.7"
IncompleteLU = "0.2"
LinearAlgebra = "<0.0.1, 1"
LinearMaps = "3"
LinearSolve = "2"
OrdinaryDiffEq = "6.30"
OrdinaryDiffEq = "6"
Pkg = "<0.0.1, 1"
Random = "<0.0.1, 1"
Reexport = "1"
SparseArrays = "<0.0.1, 1"
SpecialFunctions = "2.2"
SpecialFunctions = "2"
Test = "<0.0.1, 1"
julia = "1.7"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"

[targets]
test = ["Test", "Aqua"]
test = ["Pkg", "Test"]
28 changes: 17 additions & 11 deletions src/general_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ end

Convert a quantum object from vector (`OperatorKetQuantumObject`-type) to matrix (`OperatorQuantumObject`-type)
"""
vec2mat(A::QuantumObject{<:AbstractArray{T},OperatorKetQuantumObject}) where {T} = QuantumObject(vec2mat(A.data), OperatorQuantumObject, A.dims)
vec2mat(A::QuantumObject{<:AbstractArray{T},OperatorKetQuantumObject}) where {T} = QuantumObject(vec2mat(A.data), OperatorQuantumObject(), A.dims)

@doc raw"""
gaussian(x::Number, μ::Number, σ::Number)
Expand Down Expand Up @@ -166,18 +166,24 @@ Quantum Object: type=Operator dims=[2] size=(2, 2) ishermitian=true
0.0+0.0im 0.5+0.0im
```
"""
function ptrace(QO::QuantumObject{<:AbstractArray{T1},OpType}, sel::Vector{T2}) where
{T1,T2<:Int,OpType<:Union{KetQuantumObject,OperatorQuantumObject}}
function ptrace(QO::QuantumObject{<:AbstractArray{T1},KetQuantumObject}, sel::Vector{T2}) where
{T1,T2<:Integer}

length(QO.dims) == 1 && return QO

if isket(QO) || isbra(QO)
ρtr, dkeep = _ptrace_ket(QO.data, QO.dims, sel)
return QuantumObject(ρtr, dims=dkeep)
elseif isoper(QO)
ρtr, dkeep = _ptrace_oper(QO.data, QO.dims, sel)
return QuantumObject(ρtr, dims=dkeep)
end
ρtr, dkeep = _ptrace_ket(QO.data, QO.dims, sel)
return QuantumObject(ρtr, dims=dkeep)
end

ptrace(QO::QuantumObject{<:AbstractArray{T1},BraQuantumObject}, sel::Vector{T2}) where {T1,T2<:Integer} = ptrace(QO', sel)

function ptrace(QO::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject}, sel::Vector{T2}) where
{T1,T2<:Integer}

length(QO.dims) == 1 && return QO

ρtr, dkeep = _ptrace_oper(QO.data, QO.dims, sel)
return QuantumObject(ρtr, dims=dkeep)
end
ptrace(QO::QuantumObject, sel::Int) = ptrace(QO, [sel])

Expand Down Expand Up @@ -400,4 +406,4 @@ end

Convert a quantum object from matrix (`OperatorQuantumObject`-type) to vector (`OperatorKetQuantumObject`-type)
"""
mat2vec(A::QuantumObject{<:AbstractArray{T},OperatorQuantumObject}) where {T} = QuantumObject(mat2vec(A.data), OperatorKetQuantumObject, A.dims)
mat2vec(A::QuantumObject{<:AbstractArray{T},OperatorQuantumObject}) where {T} = QuantumObject(mat2vec(A.data), OperatorKetQuantumObject(), A.dims)
4 changes: 2 additions & 2 deletions src/negativity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function _partial_transpose(ρ::QuantumObject{<:AbstractArray, OperatorQuantumOb
]
return QuantumObject(
reshape(PermutedDimsArray(reshape(ρ.data, (ρ.dims..., ρ.dims...)), pt_idx), size(ρ)),
OperatorQuantumObject,
OperatorQuantumObject(),
ρ.dims
)
end
Expand Down Expand Up @@ -130,7 +130,7 @@ function _partial_transpose(ρ::QuantumObject{<:AbstractSparseArray, OperatorQua

return QuantumObject(
sparse(I_pt, J_pt, V_pt, M, N),
OperatorQuantumObject,
OperatorQuantumObject(),
ρ.dims
)
end
Loading
Loading