+1 vote
asked by (310 points)

Dear ITensor,

I'm using the gmres algorithm. I'm wondering how should the size() function be defined in the BigMatrix type.

I was assuming that, since it's a Krylov space method, size() should be n, if the BigMatrix is nxn when written as a matrix. gmres in Itensor works very well in most cases. However, I find that sometimes it does not give the correct answer. However, if I change n to n^2 in the size() function, gmres does give the correct answer. Is n^2 supposed to be the correction return for size()?


commented by (7.8k points)
`size()` is meant to be the linear size (what you call `n`, for an `n x n` linear operator). It's been a while since I looked at that function, but it appears that the `size()` function is only used to set the maximum number of iterations, as you can see here: https://github.com/ITensor/ITensor/blob/v3/itensor/iterativesolvers.h#L537

It is possible that for some problems it is having trouble converging, and for some reason requires more than `size()` iterations. I would think at least theoretically that shouldn't be the case, since once you reach `n` Krylov vectors then the entire space is determined, but perhaps there are some orthogonality issues that are showing up that are degrading the accuracy when using such a large Krylov space.

Instead of changing the definition of `size()`, I would instead try playing around with the arguments "MaxIter", "ErrGoal", and "RestartIter". Generally for iterative solvers I would recommend setting "MaxIter" to something quite large, and then adjust "ErrGoal" based on the accuracy you need for your particular application. "RestartIter" sets the number of iterations before the Krylov space is restarted, which can help if your "ErrGoal" is not reached in a relatively small number of iterations and orthogonality issues show up. So an example might be, for a problem of size 100 x 100, to use something like:

    gmres(A, b, x, {"MaxIter=", 200, "ErrGoal=", 1E-10, "RestartIter=", 30)

where of course you should adjust the specific numbers based on your application (perhaps try setting `"MaxIter=", 2*n` for a problem of size `n`, for example).
commented by (310 points)
Dear Matt,

Thanks very much. I will try these.


1 Answer

+1 vote
answered by (44.9k points)

(Marked as answered by discussion in comments above)

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.