View source on GitHub |
Class for storing 1- and 2-body reduced density matrices.
Inherits From: PolynomialTensor
openfermion.ops.InteractionRDM(
one_body_tensor, two_body_tensor
)
Args | |
---|---|
one_body_tensor
|
Expectation values . |
two_body_tensor
|
Expectation values . |
Attributes | |
---|---|
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
expectation(
operator
)
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
get_qubit_expectations(
qubit_operator
)
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
projected_n_body_tensors(
selection, exact=False
)
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
rotate_basis(
rotation_matrix
)
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
with_function_applied_elementwise(
func
)
__add__
__add__(
addend
)
__eq__
__eq__(
other
)
Return self==value.
__getitem__
__getitem__(
args
)
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__
__iter__()
Iterate over non-zero elements of PolynomialTensor.
__mod__
__mod__(
other
)
__mul__
__mul__(
multiplier
)
__ne__
__ne__(
other
)
Return self!=value.
__neg__
__neg__()
__radd__
__radd__(
addend
)
__rmul__
__rmul__(
multiplier
)
__rsub__
__rsub__(
subtrahend
)
__sub__
__sub__(
subtrahend
)
__truediv__
__truediv__(
dividend
)