openfermion.linalg.get_linear_qubit_operator_diagonal

Return a linear operator's diagonal elements.

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.

qubit_operator QubitOperator

A qubit operator.

linear_operator_diagonal numpy.ndarray

The diagonal elements for LinearQubitOperator(qubit_operator).