Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor MPS to account for canonical form #202

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jofrevalles
Copy link
Member

@jofrevalles jofrevalles commented Sep 13, 2024

This is still a draft, but it aims to have an MPS class that has the center of ortogonality, and the λ singular values.
CC @starsfordummies

Example:

julia> using Tenet

julia> mps = rand(MPS, Open; n=10, χ=10, center=Site(5))
[isleftcanonical(mps, Site(i)) for i = 1:n] = Bool[1, 1, 1, 1, 0, 0, 0, 0, 0, 0]
[isrightcanonical(mps, Site(i)) for i = 1:n] = Bool[0, 0, 0, 0, 1, 1, 1, 1, 1, 1]
Matrix{Float64}(I, size(𝟙ₗ, 1), size(𝟙ₗ, 1)) = [1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0]
MPS (inputs=0, outputs=10)

julia> Tenet.convert_left_to_right(mps, 4)
8×8 Tensor{Float64, 2, Matrix{Float64}}:
  1.0          -4.22748e-16  -3.25933e-16  -1.8408e-16   -8.42906e-17  -2.32961e-16  -1.12601e-16   2.9837e-17
 -4.22748e-16   1.0           1.57864e-16  -1.65245e-16   1.41122e-17   1.21602e-16  -1.21454e-17  -9.31933e-17
 -3.25933e-16   1.57864e-16   1.0          -7.27056e-16   5.47332e-16  -7.70478e-16  -2.2881e-16   -3.68635e-16
 -1.8408e-16   -1.65245e-16  -7.27056e-16   1.0          -2.16267e-16  -6.30313e-16   1.46576e-16  -1.76226e-16
 -8.42906e-17   1.41122e-17   5.47332e-16  -2.16267e-16   1.0          -4.14662e-17  -4.36183e-16   6.74531e-17
 -2.32961e-16   1.21602e-16  -7.70478e-16  -6.30313e-16  -4.14662e-17   1.0          -1.03779e-16   8.96328e-17
 -1.12601e-16  -1.21454e-17  -2.2881e-16    1.46576e-16  -4.36183e-16  -1.03779e-16   1.0          -2.83137e-17
  2.9837e-17   -9.31933e-17  -3.68635e-16  -1.76226e-16   6.74531e-17   8.96328e-17  -2.83137e-17   1.0

julia> Tenet.convert_right_to_left(mps, 5)
10×10 Tensor{Float64, 2, Matrix{Float64}}:
  1.0           8.33546e-16   8.18263e-16  -9.26519e-16   9.9221e-16    8.83287e-17  -2.34717e-17   1.84523e-15   8.09384e-16  -4.23474e-16
  8.33546e-16   1.0          -1.48931e-15  -5.00768e-16  -6.41938e-16   5.54066e-16   1.47982e-15   2.98344e-16   1.03615e-16   5.77647e-16
  8.18263e-16  -1.48931e-15   1.0          -3.44524e-16   9.62516e-16  -3.97036e-16   1.01287e-15   1.23511e-16  -7.11506e-16   8.35282e-16
 -9.26519e-16  -5.00768e-16  -3.44524e-16   1.0           9.53429e-16  -3.19678e-16  -7.66375e-16  -3.38745e-16   6.41531e-16   2.26201e-16
  9.9221e-16   -6.41938e-16   9.62516e-16   9.53429e-16   1.0          -4.40842e-16   7.34784e-16  -1.04615e-15  -5.79741e-16   5.26484e-16
  8.83287e-17   5.54066e-16  -3.97036e-16  -3.19678e-16  -4.40842e-16   1.0          -4.45837e-16  -1.79542e-16  -8.49437e-16   1.31244e-15
 -2.34717e-17   1.47982e-15   1.01287e-15  -7.66375e-16   7.34784e-16  -4.45837e-16   1.0          -5.97942e-16   3.53225e-16  -3.2382e-16
  1.84523e-15   2.98344e-16   1.23511e-16  -3.38745e-16  -1.04615e-15  -1.79542e-16  -5.97942e-16   1.0           5.72744e-16   8.43409e-16
  8.09384e-16   1.03615e-16  -7.11506e-16   6.41531e-16  -5.79741e-16  -8.49437e-16   3.53225e-16   5.72744e-16   1.0           8.09661e-16
 -4.23474e-16   5.77647e-16   8.35282e-16   2.26201e-16   5.26484e-16   1.31244e-15  -3.2382e-16    8.43409e-16   8.09661e-16   1.0

julia> mps.λ
9-element Vector{Union{Nothing, Tensor}}:
 [0.796327747399762, 0.604865372393908]
 [0.6017504036070982, 0.5484516246936645, 0.44685610016419625, 0.3706978457930666]
 [0.5414969213553932, 0.49786829596905524, 0.37558092737959625, 0.36639832798659755, 0.2749512698915463, 0.2427195738260526, 0.18556681511691353, 0.1210513984342991]
 [0.5552915300977606, 0.5343145750143071, 0.3762404775497805, 0.316949458463826, 0.249028862689978, 0.21981731436696372, 0.14640247352835156, 0.1448821392800681, 0.08537861213945974, 0.06400268170124704]
 [0.7047734556421628, 0.39900158234406774, 0.3684963163753138, 0.2779876717429905, 0.2510062779512473, 0.21105878212014392, 0.11120836539756873, 0.08103912134469375, 0.06023690988575784, 0.030205075228998186]
 [0.7717046483573069, 0.4461096507664728, 0.3441545649848504, 0.25687653233098595, 0.10168385386238375, 0.07726344847170057, 0.045719183231821676, 0.03890962603869955, 0.030372722876442743, 0.013937220655711948]
 [0.8315127733559501, 0.5023424866874187, 0.179337296419813, 0.12965805498849664, 0.0813152000523422, 0.02267645424101963, 0.011665235358199537, 0.001730795068626314]
 [0.9532682205612897, 0.2648208726347147, 0.1446245813163982, 0.015275325330649814]
 [0.978825377509097, 0.2046970452746542]

@jofrevalles jofrevalles marked this pull request as draft September 13, 2024 13:35
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 391 lines in your changes missing coverage. Please review.

Project coverage is 0.83%. Comparing base (882049b) to head (5c6bd48).
Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
src/Ansatz/MPS.jl 0.00% 391 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #202       +/-   ##
==========================================
- Coverage   72.73%   0.83%   -71.90%     
==========================================
  Files          27      32        +5     
  Lines        1944    2382      +438     
==========================================
- Hits         1414      20     -1394     
- Misses        530    2362     +1832     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant