-
Notifications
You must be signed in to change notification settings - Fork 125
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
[ITensors] [ENHANCEMENT] Add truncate
keyword to the MPS constructor
#1509
Comments
I assume you are talking about the function for converting an ITensor to an MPS? Are you sure that isn't already the behavior if you don't specify any truncation parameters? I see: julia> using ITensors, ITensorMPS
julia> i, j = Index.((2, 2))
((dim=2|id=59), (dim=2|id=472))
julia> a = random_itensor(i, j)
ITensor ord=2 (dim=2|id=59) (dim=2|id=472)
NDTensors.Dense{Float64, Vector{Float64}}
julia> x = MPS(a, [i, j])
MPS
[1] ((dim=2|id=59), (dim=2|id=289|"Link,n=1"))
[2] ((dim=2|id=289|"Link,n=1"), (dim=2|id=472))
julia> @show x[1];
x[1] = ITensor ord=2
Dim 1: (dim=2|id=59)
Dim 2: (dim=2|id=289|"Link,n=1")
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-0.5213970227157092 0.8533142121769648
0.8533142121769648 0.5213970227157092
julia> @show x[2];
x[2] = ITensor ord=2
Dim 1: (dim=2|id=289|"Link,n=1")
Dim 2: (dim=2|id=472)
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-1.7428604446123537 0.7202766240206115
0.0 1.9874308479155949 which looks like it is doing a QR decomposition (and therefore isn't truncating): julia> q, r = qr(a, i);
julia> @show q;
q = ITensor ord=2
Dim 1: (dim=2|id=59)
Dim 2: (dim=2|id=950|"Link,qr")
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-0.5213970227157092 0.8533142121769648
0.8533142121769648 0.5213970227157092
julia> @show r;
r = ITensor ord=2
Dim 1: (dim=2|id=950|"Link,qr")
Dim 2: (dim=2|id=472)
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-1.7428604446123537 0.7202766240206115
0.0 1.9874308479155949 |
If we are convinced that indeed by not setting any parameters it achieves the goal of your proposed |
Hey @mtfishman , sorry for not being clearer. In the example above |
How would you make an MPS from just a |
Right, not just |
I'd say go ahead and close this. I experimented a bit more and I am finding that I get agreement down to ~1E-15 whether I specify |
Sounds good, thanks for following up. |
Hello!
Sometimes I create MPS and I want a "lossless" version of whatever field that MPS represents (i.e., no truncation). It is useful for code and algorithm validation purposes. I know I could achieve this thru
maxdim
and/orcutoff
but I think it would be a simple matter to add a new keyword argument to the MPS constructor, calledtruncate
, which skips the truncation step in the SVD algorithm at the low level (buried in NDTensors).So then it would be possible to call the constructor like this
truncate
would default to true so existing behavior would be maintained.If everyone agrees I'd be happy to prepare the pull request. I've read the contributing guidelines here.
Please let me know what you think.
The text was updated successfully, but these errors were encountered: