quspin.tools.lanczos.lanczos_full
- quspin.tools.lanczos.lanczos_full(A, v0, m, full_ortho=False, out=None, eps=None)[source]
Creates 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, or object 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)
- full_orthobool, optional
perform a QR decomposition on Q_T generated from the standard lanczos iteration to remove any loss of orthogonality due to numerical precision.
- outnumpy.ndarray, optional
Array to store the Lanczos vectors in (e.g. Q). in memory efficient way.
- 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 : (m,n) numpy.ndarray: matrix containing the m Lanczos vectors. This is \(Q^T\) (not \(Q^\dagger\))!
Notes
performs classical lanczos algorithm for hermitian matrices and cannot handle degeneracies when calculating eigenvalues.
the function allows for full orthogonalization, see full_ortho. The resulting \(T\) will not neccesarily be tridiagonal.
V is always real-valued, since \(T\) is real and symmetric.
A must have a ‘dot’ method to perform calculation,
The ‘out’ argument to pass back the results of the matrix-vector product will be used if the ‘dot’ function supports this argument.
Examples
>>> E, V, Q_T = lanczos_full(H,v0,20)