quspin.tools.lanczos.lanczos_iter

quspin.tools.lanczos.lanczos_iter(A, v0, m, return_vec_iter=True, copy_v0=True, copy_A=False, eps=None)[source]

Creates generator for Lanczos basis; diagonalizes Krylov subspace in Lanczos basis.

Given a hermitian matrix A of size \(n\times n\) and an integer m, the Lanczos algorithm computes

  • an \(n\times m\) matrix \(Q\), and

  • a real symmetric tridiagonal matrix \(T=Q^\dagger A Q\) of size \(m\times m\). The matrix \(T\) can be represented via its eigendecomposition (E,V): \(T=V\mathrm{diag}(E)V^T\).

This function computes the triple \((E,V,Q^T)\).

NOTE: This function returns \(Q^T;\,Q^T\) is (in general) different from \(Q^\dagger\).

Parameters:
ALinearOperator, hamiltonian, numpy.ndarray, etc. with a ‘dot’ method and a ‘dtype’ method.

Python object representing a linear map to compute the Lanczos approximation to the largest eigenvalues/vectors of. Must contain a dot-product method, used as A.dot(v) and a dtype method, used as A.dtype, e.g. hamiltonian, quantum_operator, quantum_LinearOperator, sparse or dense matrix.

v0array_like, (n,)

initial vector to start the Lanczos algorithm from.

mint

Number of Lanczos vectors (size of the Krylov subspace)

return_vec_iterbool, optional

Toggles whether or not to return the Lanczos basis iterator.

copy_v0bool, optional

Whether or not to produce of copy of initial vector v0.

copy_Abool, optional

Whether or not to produce of copy of linear operator A.

epsfloat, optional

Used to cutoff lanczos iteration when off diagonal matrix elements of T drops below this value.

Returns:
tuple(E,V,Q_T)
  • E : (m,) numpy.ndarray: eigenvalues of Krylov subspace tridiagonal matrix \(T\).

  • V : (m,m) numpy.ndarray: eigenvectors of Krylov subspace tridiagonal matrix \(T\).

  • Q_T : generator that yields the m lanczos basis vectors on the fly, produces the same result as: iter(Q_T[:]) where Q_T is the array generated by lanczos_full

Notes

  • this function is useful to minimize any memory requirements in the calculation of the Lanczos basis.

  • the generator of the lanczos basis performs the calculation ‘on the fly’. This means that the lanczos iteration is repeated every time this generator is looped over.

  • this generator Q_T can be reused as many times as needed, this relies on the data in both v0 and A remaining unchanged during runtime. If this cannot be guaranteed then it is safer to set both copy_v0 and copy_A to be true.

  • V is always real-valued, since \(T\) is real and symmetric.

Examples

>>> E, V, Q_T_iterator = lanczos_iter(H,v0,20)