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
View source
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
View source
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
View source
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
View source
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
View source
with_function_applied_elementwise(
func
)
__add__
View source
__add__(
addend
)
__eq__
View source
__eq__(
other
)
Return self==value.
__getitem__
View source
__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__
View source
__iter__()
Iterate over non-zero elements of PolynomialTensor.
__mod__
View source
__mod__(
other
)
__mul__
View source
__mul__(
multiplier
)
__ne__
View source
__ne__(
other
)
Return self!=value.
__neg__
View source
__neg__()
__radd__
View source
__radd__(
addend
)
__rmul__
View source
__rmul__(
multiplier
)
__rsub__
View source
__rsub__(
subtrahend
)
__sub__
View source
__sub__(
subtrahend
)
__truediv__
View source
__truediv__(
dividend
)