def change_basis(operator, change_basis_matrix):
    """
    Write a given operator in another basis.

    :param operator: The operator to write in another basis.
    :param change_basis_matrix: The matrix to pass from the old basis to the
        new basis (each column contains the coordinates of a new basis vector
        in the old basis).
    :return: The operator in the new basis.

    >>> # Write sigmax operator in its eigenbasis
    >>> change_basis( \
            qutip.sigmax(), \
            qutip.Qobj(np.column_stack( \
                x.full() for x in qutip.sigmax().eigenstates()[1]) \
            ) \
        ).full()
    array([[-1.+0.j,  0.+0.j],
           [ 0.+0.j,  1.+0.j]])
    """
    return change_basis_matrix.dag() * operator * change_basis_matrix