From 3da1a78eb6e7c8fb8651eb1965bb53a8af08dc5e Mon Sep 17 00:00:00 2001 From: jofrevalles Date: Thu, 31 Oct 2024 15:09:00 +0100 Subject: [PATCH] Format code --- src/Quantum.jl | 22 ++++------------------ src/TensorNetwork.jl | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Quantum.jl b/src/Quantum.jl index 3eed0db3d..e9f98b00e 100644 --- a/src/Quantum.jl +++ b/src/Quantum.jl @@ -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 diff --git a/src/TensorNetwork.jl b/src/TensorNetwork.jl index 557a150de..f5f4b8fad 100644 --- a/src/TensorNetwork.jl +++ b/src/TensorNetwork.jl @@ -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