0 votes
asked by (540 points)

I'm recently developing some Krylov subspace algorithm with itensor, and the final step is phi = V*u, where V and u are std::vector<ITensor> V(n) and std::vector<Cplx> u(n) respectively. One can consider V as a matrix (it has n columns with each be an ITensor, all ITensors have same IndexSet).

A possible efficient way is extracting each storage of ITensors in V and joint them into a new large storage(since itensor use column major, it's straightforward to combine these storages into a new one), then do matrix multiplication with u.

I'm not familiar with lower itensor apis and any help is appreciated. It is also necessary to consider the block storage of QN ITensors.

1 Answer

0 votes
answered by (540 points)
Best answer

I've come out with this solution:

for(auto i : range(u.size())) V[i] *= u[i]; for(auto i : range1(u.size())) V[0] += V[i]; phi = V[0];

it works fine. phi=sum_i (u[i]*V[i]), it seems that I'd consider this problem too complex at the first sight.

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.