In order to use `arnoldi`, you need to define your own class that can be passed into the function. The only requirements are that it defines the functions `.size()` and `.product()` which give the size of the matrix (i.e. `m` for an `m x m` matrix) and the product of the operator with an ITensor. Here is an example code for getting the eigenvector with the largest magnitude eigenvalue:

#include "itensor/all.h"

using namespace itensor;

class ITensorMap

{

ITensor const& A_;

mutable long size_;

public:

ITensorMap(ITensor const& A)

: A_(A)

{

size_ = 1;

for(auto& I : A_.inds())

{

if(I.primeLevel() == 0)

size_ *= dim(I);

}

}

void

product(ITensor const& x, ITensor& b) const

{

b = A_*x;

b.noPrime();

}

long

size() const

{

return size_;

}

};

int

main()

{

auto i = Index(2,"i");

auto j = Index(2,"j");

auto k = Index(2,"k");

auto A = randomITensor(i,j,k,prime(i),prime(j),prime(k));

// Using the ITensorMap class

// to make an object that can be passed

// to arnoldi

auto AM = ITensorMap(A);

PrintData(AM.size());

// Random starting vector for Arnoldi

auto x = randomITensor(i,j,k);

auto lambda = arnoldi(AM,x,{"ErrGoal=",1E-14,"MaxIter=",20,"MaxRestart=",5});

// Check it is an eigenvector

PrintData(lambda);

PrintData(norm((A*x).noPrime() - lambda*x));

return 0;

}

Unfortunately I have been seeing problems when I try to calculate more than one eigenvalue/eigenvector (you can try it by passing a vector of ITensors as the starting state `x`).

The `eigen` function doesn't have any named arguments (other than setting the tag of the newly created index). In order to get only a particular eigenvector, you will have to figure out which one you want (i.e. by searching the eigenvalues and finding the largest one) and projecting the tensor of eigenvectors onto that index (for example by using `setElt(d=1)` if the new index is `d` and you want the first eigenvector).

I also seem to be having trouble with the `eigen` function, we will have to look into it to make sure it is working correctly (I believe it is calculating the correct eigenvalues and eigenvectors, but it may be outputting it in a strange way).

Let me know if the arnoldi code above is sufficient for what you need. You can play around with increasing "MaxIter" and "MaxRestart" to try to get better convergence.

Cheers,

Matt