Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed Nov 4, 2024
1 parent f55d959 commit 3da1a78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
22 changes: 4 additions & 18 deletions src/Quantum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,26 +335,12 @@ end
Returns the adjoint of a [`Quantum`](@ref) Tensor Network; i.e. the conjugate Tensor Network with the inputs and outputs swapped.
"""
function Base.adjoint(tn::AbstractQuantum)
tn = conj(tn)
Base.adjoint(tn::AbstractQuantum) = adjoint_sites!(conj(tn))

# update site information
oldsites = copy(Quantum(tn).sites)
empty!(Quantum(tn).sites)
for (site, index) in oldsites
addsite!(tn, site', index)
end

# rename inner indices
replace!(tn, map(i -> i => Symbol(i, "'"), inds(tn; set=:virtual)))

return tn
end

function LinearAlgebra.adjoint!(tn::AbstractQuantum)
conj!(tn)
LinearAlgebra.adjoint!(tn::AbstractQuantum) = adjoint_sites!(conj!(tn))

# update site information
# update site information and rename inner indices
function adjoint_sites!(tn::AbstractQuantum)
oldsites = copy(Quantum(tn).sites)
empty!(Quantum(tn).sites)
for (site, index) in oldsites
Expand Down
2 changes: 1 addition & 1 deletion src/TensorNetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Return a copy of the [`AbstractTensorNetwork`](@ref) with all tensors conjugated
"""
function Base.conj(tn::AbstractTensorNetwork)
tn = copy(tn)
replace!(tn, Pair.(tensors(tn), conj.(tensors(tn))))
replace!(tn, tensors(tn) .=> conj.(tensors(tn)))
return tn
end

Expand Down

0 comments on commit 3da1a78

Please sign in to comment.