Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/QuanEstimationBase/src/Common/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,10 @@ function repeat_copy(scheme, N)
[deepcopy(scheme) for _ = 1:N]
end

function filterZeros!(x::Matrix{T}) where {T<:Complex}
x[abs.(x).<eps()] .= zero(T)
x
end
function filterZeros!(x)
filterZeros!.(x)
end

function filterZeros(x::AbstractVecOrMat{T}) where {T<:Number}
[x + 1 ≈ 1 ? zero(T) : x for x in x]
end

function t2Num(t0, dt, t)
Int(round((t - t0) / dt)) + 1
end

function basis(dim, si, ::T)::Array{T} where {T<:Complex}
result = zeros(T, dim)
result[si] = 1.0
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ end
end
end

@testset "Parameterization" begin
include("test_parameterization.jl")
@testset "Scheme" begin
include("test_scheme.jl")
end

@testset "Resource" begin
Expand Down
13 changes: 12 additions & 1 deletion test/test_parameterization.jl → test/test_scheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,22 @@ function test_kraus()
evolve(GeneralScheme(; probe=rho0, param=channel))
evolve(GeneralScheme(; probe=psi, param=channel))
end

function test_state()
@test PlusState() == [1.0, 1.0]/sqrt(2)
@test MinusState() == [1.0, -1.0]/sqrt(2)
@test BellState() == BellState(1) == [1.0, 0.0, 0.0, 1.0]/sqrt(2)
@test BellState(2) == [1.0, 0.0, 0.0, -1.0]/sqrt(2)
@test BellState(3) == [0.0, 1.0, 1.0, 0.0]/sqrt(2)
@test BellState(4) == [0.0, 1.0, -1.0, 0.0]/sqrt(2)
end # function test_state

function test_parameterization()
test_lindblad(dyn_method=:Ode)
test_lindblad(dyn_method=:Expm)
test_lindblad_pure()
test_kraus()
end # function test_parameterization

test_parameterization()
test_parameterization()
test_state()
Loading