Processing math: 100%

qml.liealg.check_commutation_relation

check_commutation_relation(ops1, ops2, vspace)[source]

Helper function to check [ops1,ops2]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 [ops1,ops2]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 [X0,Y0]=2iZ0, the commutators do not map to the selected vector space.

>>> check_commutation_relation(ops1, ops2, vspace1)
False

Instead, we need the full su(2) space.

>>> vspace2 = [qml.X(0), qml.Y(0), qml.Z(0)]
>>> check_commutation_relation(ops1, ops2, vspace2)
True