Skip to content

Commit

Permalink
Additional fixes for dim issue and related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Gawron committed Mar 26, 2019
1 parent 778f1f2 commit 04fcec4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ function Base.kron(Φ1::UnitaryChannel{M1}, Φ2::UnitaryChannel{M2}) where {M1<:
end

function Base.kron(::Type{T}, Φ1::IdentityChannel, Φ2::UnitaryChannel) where {T<:AbstractQuantumOperation{M}} where {M<:AbstractMatrix{<:Number}}
matrix = convert(M, Matrix(I, Φ1.idim, Φ1.odim) Φ2.matrix)
matrix = convert(M, Matrix(I, Φ1.odim, Φ1.idim) Φ2.matrix)
uc = UnitaryChannel(matrix, Φ1.idim * Φ2.idim, Φ1.odim * Φ2.odim)
convert(T, uc)
end
Expand All @@ -574,7 +574,7 @@ function Base.kron(Φ1::IdentityChannel{M1}, Φ2::UnitaryChannel{M2}) where {M1<
end

function Base.kron(::Type{T}, Φ1::UnitaryChannel, Φ2::IdentityChannel) where {T<:AbstractQuantumOperation{M}} where {M<:AbstractMatrix{<:Number}}
matrix = convert(M, Φ1.matrix Matrix(I, Φ2.idim, Φ2.odim))
matrix = convert(M, Φ1.matrix Matrix(I, Φ2.odim, Φ2.idim))
uc = UnitaryChannel(matrix, Φ1.idim * Φ2.idim, Φ1.odim * Φ2.odim)
convert(T, uc)
end
Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ function ispositive(ρ::AbstractMatrix{<:Number}; atol=1e-13)
if rows!=cols
return false
end
if !ishermitian(ρ)
return false
end
# if !ishermitian(ρ) # TODO: ishermitian function has no tolerance
# return false
# end
h = Hermitian(ρ)
fact = eigen(h)
all(fact.values .> -atol)
Expand Down

0 comments on commit 04fcec4

Please sign in to comment.