qml.liealg.check_commutation_relation¶
- check_commutation_relation(ops1, ops2, vspace)[source]¶
Helper function to check \([\text{ops1}, \text{ops2}] \subseteq \text{vspace}\).
Warning
This function is expensive to compute.
- Parameters:
ops1 (List[Union[PauliSentence, TensorLike]]) – First set of operators.
ops2 (List[Union[PauliSentence, TensorLike]]) – Second set of operators.
vspace (Union[PauliVSpace, List[Union[PauliSentence, TensorLike]]]) – The vector space in form of a
PauliVSpace
that the operators should map to.
- Returns:
Whether or not \([\text{ops1}, \text{ops2}] \subseteq \text{vspace}\).
- Return type:
bool
Example
>>> from pennylane.liealg import check_commutation_relation >>> ops1 = [qml.X(0)] >>> ops2 = [qml.Y(0)] >>> vspace1 = [qml.X(0), qml.Y(0)]
Because \([X_0, Y_0] = 2i Z_0\), the commutators do not map to the selected vector space.
>>> check_commutation_relation(ops1, ops2, vspace1) False
Instead, we need the full \(\mathfrak{su}(2)\) space.
>>> vspace2 = [qml.X(0), qml.Y(0), qml.Z(0)] >>> check_commutation_relation(ops1, ops2, vspace2) True
code/api/pennylane.liealg.check_commutation_relation
Download Python script
Download Notebook
View on GitHub