Commutator of `A` and `B`

    If ``B != None``, return the commutator :math:`[A,B]`, otherwise return
    the super-operator :math:`[A,\cdot]`.  The super-operator :math:`[A,\cdot]`
    maps any other operator ``B`` to the commutator :math:`[A, B] = A B - B A`.

    Args:
        A: The first operator to form the commutator of.
        B: The second operator to form the commutator of, or None.

    Returns:
        SuperOperator: The linear superoperator :math:`[A,\cdot]`

def commutator(A, B=None):
    """Commutator of `A` and `B`

    If ``B != None``, return the commutator :math:`[A,B]`, otherwise return
    the super-operator :math:`[A,\cdot]`.  The super-operator :math:`[A,\cdot]`
    maps any other operator ``B`` to the commutator :math:`[A, B] = A B - B A`.

    Args:
        A: The first operator to form the commutator of.
        B: The second operator to form the commutator of, or None.

    Returns:
        SuperOperator: The linear superoperator :math:`[A,\cdot]`

    """
    if B:
        return A * B - B * A
    return SPre(A) - SPost(A)