View source on GitHub |
Return a linear operator's diagonal elements.
openfermion.linalg.get_linear_qubit_operator_diagonal(
qubit_operator, n_qubits=None
)
The main motivation is to use it for Davidson's algorithm, to find out the lowest n eigenvalues and associated eigenvectors.
Qubit terms with X or Y operators will contribute nothing to the diagonal elements, while I or Z will contribute a factor of 1 or -1 together with the coefficient.
Args | |
---|---|
qubit_operator
|
QubitOperator
A qubit operator. |
Returns | |
---|---|
linear_operator_diagonal
|
numpy.ndarray
The diagonal elements for LinearQubitOperator(qubit_operator). |