bsc-quantic / Qrochet.jl

Quantum Tensor Networks
https://bsc-quantic.github.io/Qrochet.jl/
Apache License 2.0
1 stars 0 forks source link

Fix `leftsite` and `rightsite` for `adjoint` `Chain`s #50

Closed jofrevalles closed 2 weeks ago

jofrevalles commented 2 weeks ago

Previously, doing leftsite or rightsite for a Chain that is adjoint, returned a Site that does not have dual=true. This caused the functions leftindex and rightindex to not work for adjointed Chains.

Example (code before the PR):

julia> using Qrochet

julia> mps = rand(Chain, Open, State; n=8, χ=10)
MPS (inputs=0, outputs=8)

julia> Qrochet.rightsite(mps', Site(2; dual=true))
3

julia> rightindex(mps', Site(2; dual=true))
ERROR: AssertionError: Site 3 not found
Stacktrace: ...

julia> rightindex(mps', Site(2))
ERROR: AssertionError: Site 2 not found
Stacktrace: ...

This PR addresses this issue by fixing the leftsite or rightsite functions. Additionally, we added the testset for the adjoint for Chains.

Example (fixed code):

julia> using Qrochet

julia> mps = rand(Chain, Open, State; n=8, χ=10)
MPS (inputs=0, outputs=8)

julia> Qrochet.rightsite(mps', Site(2; dual=true))
3'

julia> rightindex(mps', Site(2; dual=true))
Symbol("Z'")