def _operator_generator(self, index, conj):
        """
        Internal method to generate the appropriate ladder operator at fermion
        orbital at 'index'
        If conj == -1 --> creation
           conj == +1 --> annihilation

        :param int index: fermion orbital to generate ladder operator at
        :param int conj: -1 for creation, +1 for annihilation
        """
        if conj != -1 and conj != +1:
            raise ValueError("Improper conjugate coefficient")
        if index >= self.n_qubits or index < 0:
            raise IndexError("Operator index outside number of qubits for "
                             "current Bravyi-Kitaev transform.")

        # parity set P(j). apply Z to, for parity sign.
        parity_set = [node.index for node in self.tree.get_parity_set(index)]

        # update set U(j). apply X to, for updating purposes.
        ancestors = [node.index for node in self.tree.get_update_set(index)]

        # remainder set C(j) = P(j) \ F(j)
        ancestor_children = [node.index for node in self.tree.get_remainder_set(index)]

        # Under Majorana basis, creation/annihilation operators given by
        # a^{\pm} = (c \mp id) / 2

        # c_j = a_j + a_j^{\dagger} = X_{U(j)} X_j Z_{P(j)}
        c_maj = PauliTerm('X', index)
        for node_idx in parity_set:
            c_maj *= PauliTerm('Z', node_idx)
        for node_idx in ancestors:
            c_maj *= PauliTerm('X', node_idx)

        # d_j = i(a_j^{\dagger} - a_j) = X_{U(j)} Y_j Z_{C(j)}
        d_maj = PauliTerm('Y', index)
        for node_idx in ancestors:
            d_maj *= PauliTerm('X', node_idx)
        for node_idx in ancestor_children:
            d_maj *= PauliTerm('Z', node_idx)

        result = 0.5 * (c_maj + 1j * conj * d_maj)
        return result.simplify()
def _operator_generator ( self , index , conj ) : if conj != - 1 and conj != + 1 : raise ValueError ( "Improper conjugate coefficient" ) if index >= self . n_qubits or index < 0 : raise IndexError ( "Operator index outside number of qubits for " "current Bravyi-Kitaev transform." ) parity_set = [ node . index for node in self . tree . get_parity_set ( index ) ] ancestors = [ node . index for node in self . tree . get_update_set ( index ) ] ancestor_children = [ node . index for node in self . tree . get_remainder_set ( index ) ] c_maj = PauliTerm ( 'X' , index ) for node_idx in parity_set : c_maj *= PauliTerm ( 'Z' , node_idx ) for node_idx in ancestors : c_maj *= PauliTerm ( 'X' , node_idx ) d_maj = PauliTerm ( 'Y' , index ) for node_idx in ancestors : d_maj *= PauliTerm ( 'X' , node_idx ) for node_idx in ancestor_children : d_maj *= PauliTerm ( 'Z' , node_idx ) result = 0.5 * ( c_maj + 1j * conj * d_maj ) return result . simplify ( )
Internal method to generate the appropriate ladder operator at fermion
        orbital at 'index'
        If conj == -1 --> creation
           conj == +1 --> annihilation

        :param int index: fermion orbital to generate ladder operator at
        :param int conj: -1 for creation, +1 for annihilation