openfermion.ops.InteractionRDM

Class for storing 1- and 2-body reduced density matrices.

Inherits From: PolynomialTensor

one_body_tensor Expectation values .
two_body_tensor Expectation values .

one_body_tensor The expectation values .
two_body_tensor The expectation values .
constant The value of the constant term.
n_body_tensors

n_qubits

Methods

expectation

View source

Return expectation value of an InteractionRDM with an operator.

Args
operator A QubitOperator or InteractionOperator.

Returns
float Expectation value

Raises
InteractionRDMError Invalid operator provided.

get_qubit_expectations

View source

Return expectations of QubitOperator in new QubitOperator.

Args
qubit_operator QubitOperator instance to be evaluated on this InteractionRDM.

Returns
QubitOperator QubitOperator with coefficients corresponding to expectation values of those operators.

Raises
InteractionRDMError Observable not contained in 1-RDM or 2-RDM.

projected_n_body_tensors

View source

Keep only selected elements.

Args
selection (Union[int, Iterable[int]): If int, keeps terms with at most (exactly, if exact is True) that many unique indices. If iterable, keeps only terms containing (all of, if exact is True) the specified indices. exact (bool): Whether or not the selection is strict.

rotate_basis

View source

Rotate the orbital basis of the PolynomialTensor.

Args
rotation_matrix A square numpy array or matrix having dimensions of n_qubits by n_qubits. Assumed to be real and invertible.

with_function_applied_elementwise

View source

__add__

View source

__eq__

View source

Return self==value.

__getitem__

View source

Look up matrix element.

Args
args Tuples indicating which coefficient to get. For instance, my_tensor[(6, 1), (8, 1), (2, 0)] returns my_tensor.n_body_tensors[1, 1, 0][6, 8, 2]

__iter__

View source

Iterate over non-zero elements of PolynomialTensor.

__mod__

View source

__mul__

View source

__ne__

View source

Return self!=value.

__neg__

View source

__radd__

View source

__rmul__

View source

__rsub__

View source

__sub__

View source

__truediv__

View source