Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Implement Chain normalization by mixed canonization (#28)
Browse files Browse the repository at this point in the history
* Implement normalization by mixed canonization

* Include testset for normalization by mixed canonization

* Fix centersite var type

* Replace mixed-canonization norm by inplace normalization of LinearAlgebra

* Remove old function export

* Rename center as root & return the tensor network

* Remove useless testset

* Replace Chain by MPS in normalization test

Co-authored-by: Jofre Vallès Muns <[email protected]>

* Fix julia format

* Remove useless test for normalization

---------

Co-authored-by: Jofre Vallès Muns <[email protected]>
  • Loading branch information
Todorbsc and jofrevalles authored Mar 14, 2024
1 parent 92b0b4a commit c2c8e22
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Ansatz/Chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ function mixed_canonize!(::Open, tn::Chain, center::Site) # TODO: center could b
return tn
end

"""
LinearAlgebra.normalize!(tn::Chain, center::Site)
Normalizes the input [`Chain`](@ref) tensor network by transforming it
to mixed-canonized form with the given center site.
"""
function LinearAlgebra.normalize!(tn::Chain, root::Site; p::Real = 2)
mixed_canonize!(tn, root)
normalize!(select(Quantum(tn), :tensor, root), p)
return tn
end

"""
evolve!(qtn::Chain, gate)
Expand Down
6 changes: 6 additions & 0 deletions test/Ansatz/Chain_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,11 @@
end
end

@test begin
qtn = MPS([rand(4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4)])
normalize!(qtn, Site(3))
isapprox(norm(qtn), 1.0)
end

# TODO test `evolve!` methods
end

0 comments on commit c2c8e22

Please sign in to comment.