-
Notifications
You must be signed in to change notification settings - Fork 1
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
convert to/from ITensors MPS #247
Comments
You can convert from using Tenet
using ITensors
using Tenet: MPS, tensors
using ITensors: Index, ITensor, dim
using ITensorMPS
psi_tensors = [rand(2,10), rand(2,10,12), rand(2,12,4), rand(2,4)]
psi_tenet = MPS(psi_tensors)
itensors = ITensor[]
for (j,t) in enumerate(tensors(psi_tenet))
it = if j == 1 || j == length(tensors(psi_tenet))
ITensor(parent(t), Index(size(t, 1), "Site,n=$j"), Index(size(t, 2), "Link,l=$j"))
else
ITensor(parent(t), Index(size(t, 1), "Site,n=$j"), Index(size(t, 2), "Link,l=$j"), Index(size(t, 3), "Link,l=$(j+1)"))
end
push!(itensors, it)
end
psi_itensors = ITensorMPS.MPS(itensors) Do you want to have this as an extension in |
Conversion from/to # Tensor -> ITensor
convert(ITensor, tensor)
# ITensor -> Tensor
convert(Tensor, itensor) Furthermore, you can convert a What I'm not sure about is whether |
It would be good to be able to convert between the two. An ITensorMPS.MPS is basically a list of ITensors plus a couple integers (llim, rlim) that localize the orthogonality center, but those should be added automatically when you create one.
The simplest way is probably to convert the tensors of Tenet's MPS into ITensors, and feed the list of ITensors into the ITensorMPS.MPS() constructor. The only thing I don't know how to do in Tenet,as always, is how to map the indices into the tensors. Here's a (non-working) attempt
the other way around is probably simpler (for me at least), here's one way to do it
The text was updated successfully, but these errors were encountered: