Saving a MPS tensor as a list of lists in a HDF5 File

Hello!
I have probably a very silly question. I have calculated a MPS using DMRG, using the basic example in the Julia Tutorials. I want to save the MPS tensors as a list of lists in a HDF5 file. How do I convert the MPS to just the tensors and save it?

Thank you for your patience!

What do you mean by a list of lists? Do you mean as a list of matrices, one matrix per value of the site index?

Why would you want to do that as opposed to saving either the entire MPS tensor as-is as an ITensor, or the entire MPS?

Maybe this is what you’re looking for:

julia> using ITensorMPS: linkind, random_mps, siteinds

julia> s = siteinds("S=1/2", 5)
5-element Vector{ITensors.Index{Int64}}:
 (dim=2|id=251|"S=1/2,Site,n=1")
 (dim=2|id=817|"S=1/2,Site,n=2")
 (dim=2|id=160|"S=1/2,Site,n=3")
 (dim=2|id=577|"S=1/2,Site,n=4")
 (dim=2|id=843|"S=1/2,Site,n=5")

julia> x = random_mps(s; linkdims=3)
ITensors.ITensorMPS.MPS
[1] ((dim=2|id=251|"S=1/2,Site,n=1"), (dim=3|id=501|"Link,l=1"))
[2] ((dim=3|id=501|"Link,l=1"), (dim=2|id=817|"S=1/2,Site,n=2"), (dim=3|id=460|"Link,l=2"))
[3] ((dim=3|id=460|"Link,l=2"), (dim=2|id=160|"S=1/2,Site,n=3"), (dim=3|id=620|"Link,l=3"))
[4] ((dim=3|id=620|"Link,l=3"), (dim=2|id=577|"S=1/2,Site,n=4"), (dim=2|id=413|"Link,l=4"))
[5] ((dim=2|id=413|"Link,l=4"), (dim=2|id=843|"S=1/2,Site,n=5"))


julia> Array(x[3], linkind(x, 2), linkind(x, 3), s[3])
3×3×2 Array{Float64, 3}:
[:, :, 1] =
 -0.463847  -0.0272978  -0.519668
  0.376511   0.240638    0.555349
  0.335718   0.107249   -0.160548

[:, :, 2] =
  0.0620362  -0.28103   -0.656673
  0.292919   -0.321849  -0.550029
 -0.251503    0.75701   -0.462274