# Krylov Subspace Method to the Matrix Exponential for TDVP

Hi,

I am trying to implement TDVP method using ITensor. TDVP requires an approximate Krylov method to get the matrix exponential, which is considerably faster than exact diagonalization technique, eg. expHermitian, especially at large bond dimension.

Can you please suggest a library or give a reference of the algorithm, that is well suited for ITensor library (for both ITensor and IQTensor)?

Another thing, can you please tell me about the way to efficiently extract the data of an ITensor (or IQTensor) as a 2D array (like the ones, used in Eigen or Armadillo, or native C++ dynamic array), and then put it back into ITensor (or IQTensor)? Currently, I am doing brute force method using loops to copy/insert the data from/in ITensor (or IQTensor).

Thanking you,
Titas

Hi Titas,
Regarding Krylov, this is a good idea for a low-level algorithm we should supply with ITensor. However, this is in addition to many other things we should or would like to add (tensor slicing, other algorithms, etc) so it may take some time for us to add Krylov.

But in the meantime, it is something that should be quite possible to implement yourself. Good examples of similar algorithms written in ITensor can be found in this file:
https://github.com/ITensor/ITensor/blob/master/itensor/iterativesolvers.h
In that file there are the Arnoldi, gmres, and Davidson algorithms.

These all follow similar principles, which is that one multiplies a large linear operator onto an initial 'state' or vector, then orthogonalizes the resulting produced vector against all previously produced vectors from earlier in the algorithm to build a Krylov subspace. Then one solves the desired problem, whether an eigenvalue or Ax=b problem etc., within the Krylov space.

The key operations of ITensor taking place in each of these algorithms are just contracting ITensors together (used when multiplying the vectors by the large linear operator and dot-producting the vectors with each other) and addition of ITensors. Most of the code is just dealing with scalars and small matrices to enact the logic of the algorithm, and to check for convergence and things.

Finally, regarding extracting the data of a dense ITensor, you can refer to this code formula page:
http://itensor.org/docs.cgi?vers=cppv2&page=formulas/extractdense

Unfortunately, things aren't as simple for extracting storage of block-sparse tensors i.e. IQTensors. I could give you a similar code to the above that would extract the low level storage of an IQTensor, but you'd still need to know how this storage is organized to read out the different blocks properly. Let me know if you definitely decide you need to do that. But it could be easier to just convert the IQTensor to a dense ITensor and then read that out instead.

Best regards,
Miles

commented by (300 points)
Hi Miles,

Thanks for the answers. I have written a simple Lanczos exponentiation using a LocalOp like class with .product() method, and it works well for TDVP methods.

For the data extraction, I believe, I will stick to ITensors for now and use doTask() method.

With regards,
Titas
commented by (41.3k points)
That's great to hear & glad you got that working. Thanks for the update -
commented by (330 points)
Hello,

regarding
"Finally, regarding extracting the data of a dense ITensor, you can refer to this code formula page:
http://itensor.org/docs.cgi?vers=cppv2&page=formulas/extractdense