+1 vote
asked by (140 points)

The internal format used by "writeToFile" and "readFromFile" is not explicit. Is there any way of writing things e.g. using a HDF5 format? This would be useful for inspecting the results using hdfview or silx, and to interface ITensor with other MPS programs. Any development planned in this direction?

2 Answers

+1 vote
answered by (70.1k points)

Yes, HDF5 would be great to have and we are planning to support HDF5 at some point soon, probably starting this summer. But I'm not sure when it will happen since I'm the only developer currently and I'll be traveling quite a bit until July.

In the meantime, if you want to create your own code to export ITensor data to a format of your choosing, here is a documentation page showing how to extract the storage inside of a dense ITensor, which is just a std::vector of Real (double) or Cplx (std::complex) numbers:
http://itensor.org/docs.cgi?page=formulas/extractdense

If you decide to work on that and encounter a more complicated ITensor storage type (such as the storage of an IQTensor) I can discuss with you how to extract that storage and what format it has.

Best regards,
Miles

commented by (150 points)
Hi,
is there something analogous for IQTensor?

Best,
Mateusz
commented by (70.1k points)
Hi Mateusz,
Yes you can extract the storage of any ITensor or IQTensor. Here is some code analogous to the code linked above but for extracting the storage of a dense, real IQTensor:

    auto extractReal = [](QDense<Real> const& d)
        {
        return d.store;
        };
    
    auto store = applyFunc(extractReal,T.store());

The variable "store" above will now hold a copy of the storage of the IQTensor "T". This storage is an object of type QDense<Real> (or alternatively QDenseReal which is an alias or typedef). I haven't gotten around to documenting the storage types in detail yet, but briefly the definition of QDense is in itensor/itdata/qdense.h and it has two main storage fields: one called "offsets" is a list of block information (the block number, when viewing an IQTensor as a "tensor of tensors" and the offset in the data storage array) and the storage array "store" which is just an array of numbers (real numbers in the case of QDenseReal).
0 votes
answered by (170 points)

So here's another piece of an answer: I wanted to write an ITensor of results to an hdf5 file for analysis in Julia. To save everybody else from having to re-invent this particular wheel, the code is in a gist. (Too long for the answer box.)

FWIW the code in the gist can take IQTensors---but it deals with them by flattening them down to ordinary ITensors.

commented by (170 points)
(Looking over this again, I'm realizing the comments are a little unhelpful: e.g. it's useful to think about HDF5 doing reshaping, but I'm willing to bet an hdf5 dataset is just a big contiguous block of storage with metadata for stride etc.)
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...