qml.labs.trotter_error.Fragment¶
- class Fragment[source]¶
Bases:
ABCAbstract class used to define a fragment object for product formula error estimation.
A
Fragmentis an object that has a well-defined notion of a commutator. To ensure the existence of commutators, the implementation requires the following arithmetic dunder methods:__add__(): implements addition__mul__(): implements multiplication__matmul__(): implements matrix multiplication
In addition to the arithmetic operators, a
normmethod should be defined. The norm is required to compute error estimates of Trotter error operators.Methods
apply(state)Apply the Fragment to a state on the right.
expectation(left, right)Return the expectation value of a state.
norm(params)Compute the norm of the fragment.
- abstract apply(state)[source]¶
Apply the Fragment to a state on the right. The type of
stateis determined by each class inheriting fromFragment.- Parameters:
state (AbstractState) – an object representing a quantum state
- Returns:
the result of applying the
Fragmenttostate- Return type:
- expectation(left, right)[source]¶
Return the expectation value of a state. The type of
stateis determined by each class inheriting fromFragment.- Parameters:
left (AbstractState) – the state to be multiplied on the left of the
Fragmentright (AbstractState) – the state to be multiplied on the right of the
Fragment
- Returns:
the expectation value obtained by applying
Fragmentto the given states- Return type:
float