Return the complex conjugate of this Kraus operation
493293
def H(self) -> 'Kraus':
        """"""
        operators = [op.H for op in self.operators]
        return Kraus(operators, self.weights)
1022008
def get_diagonalizing_basis(list_of_pauli_terms):
    
    qubit_ops = set(reduce(lambda x, y: x + y,
                       [list(term._ops.items()) for term in list_of_pauli_terms]))
    qubit_ops = sorted(list(qubit_ops), key=lambda x: x[0])

    return PauliTerm.from_list(list(map(lambda x: tuple(reversed(x)), qubit_ops)))
250631
def to_fock_representation(self, index_symbol='n', max_terms=None):
        """"""
        phase_factor = sympy.exp(
            sympy.Rational(-1, 2) * self.ampl * self.ampl.conjugate())
        if not isinstance(index_symbol, IdxSym):
            index_symbol = IdxSym(index_symbol)
        n = index_symbol
        if max_terms is None:
            index_range = IndexOverFockSpace(n, hs=self._hs)
        else:
            index_range = IndexOverRange(n, 0, max_terms-1)
        term = (
            (self.ampl**n / sympy.sqrt(sympy.factorial(n))) *
            BasisKet(FockIndex(n), hs=self._hs))
        return phase_factor * KetIndexedSum(term, index_range)
313965
def koenig(self):
        
        L = self
        Y = L - (L*L)
        while True:
            Ybar = Y + ~Y
            take = L - Ybar
            if not len(take):
                return Y
            else:
                ZZ = list(set(take)-set(Y))#use significant which is not in Y
                if len(ZZ) > 0:
                    v = ZZ[0]
                    z=(v,take[v][0])
                else:
                    z = next(take.flatten())
                Yzgen = Y**z
                Y = (Y - Yzgen) + z
682508
def _apply_krauss_multi_qubit(krauss: Union[Tuple[Any], Sequence[Any]],
        args: 'ApplyChannelArgs') -> np.ndarray:
    """"""
    for krauss_op in krauss:
        np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
        krauss_tensor = np.reshape(
                krauss_op.astype(args.target_tensor.dtype),
                (2,) * len(args.left_axes) * 2)
        linalg.targeted_left_multiply(
                krauss_tensor,
                args.target_tensor,
                args.left_axes,
                out=args.auxiliary_buffer1)
        # No need to transpose as we are acting on the tensor
        # representation of matrix, so transpose is done for us.
        linalg.targeted_left_multiply(
                np.conjugate(krauss_tensor),
                args.auxiliary_buffer1,
                args.right_axes,
                out=args.target_tensor)
        args.out_buffer += args.target_tensor
    return args.out_buffer
1243927
def dephasing_kraus_map(p=0.10):
    
    return [np.sqrt(1 - p) * np.eye(2), np.sqrt(p) * np.diag([1, -1])]
413270
def conjugate(self):
        """"""
        return self.__class__.create(
            *[arg.conjugate() for arg in reversed(self.args)])
1268400
public Complex multiply(Complex c)
    {
        Complex ret = new Complex(real, imag);
        ret.mutableMultiply(c);
        return ret;
    }
951120
def **(other)
      if other.is_a?(InternalComplex) or other.is_a?(Complex)
        r, theta = polar
        ore = other.real
        oim = other.imag
        nr = Math.exp ore * Math.log(r) - oim * theta
        ntheta = theta * ore + oim * Math.log(r)
        InternalComplex.polar nr, ntheta
      elsif InternalComplex.generic? other
        r, theta = polar
        InternalComplex.polar r ** other, theta * other
      else
        x, y = other.coerce self
        x ** y
      end
    end
502051
function() {

      // acos(c) = i * log(c - i * sqrt(1 - c^2))

      var a = this['re'];
      var b = this['im'];

      var t1 = new Complex(
              b * b - a * a + 1,
              -2 * a * b)['sqrt']();

      var t2 = new Complex(
              t1['re'] - b,
              t1['im'] + a)['log']();

      return new Complex(Math.PI / 2 - t2['im'], t2['re']);
    }
814456
function complexMultiply(a, b){
                return [(a[0] * b[0] - a[1] * b[1]), 
                        (a[0] * b[1] + a[1] * b[0])];
            }
1001103
def _complex_even(f, fx, x, h):
        
        n = len(x)
        ee = np.diag(h)
        hess = 2. * np.outer(h, h)
        for i in range(n):
            for j in range(i, n):
                hess[i, j] = (f(x + 1j * ee[i] + ee[j])
                              - f(x + 1j * ee[i] - ee[j])).imag / hess[j, i]
                hess[j, i] = hess[i, j]
        return hess
1169693
public Complex contraction() {
        int i, j;
        Complex result = new Complex(0d, 0d);
        for (i = 0; i < rows; i++)
            for (j = 0; j < columns; j++) {
                result.real += realmatrix[i][j];
                result.imag += imagmatrix[i][j];
            }
        return result;
    }
248413
def kraus_iscomplete(kraus: Kraus) -> bool:
    
    qubits = kraus.qubits
    N = kraus.qubit_nb

    ident = Gate(np.eye(2**N), qubits)  # FIXME

    tensors = [(op.H @ op @ ident).asoperator() for op in kraus.operators]
    tensors = [t*w for t, w in zip(tensors, kraus.weights)]

    tensor = reduce(np.add, tensors)
    res = Gate(tensor, qubits)

    return almost_identity(res)
589668
function() {

      // acot(c) = i / 2 log((c - i) / (c + i))

      var a = this['re'];
      var b = this['im'];

      if (b === 0) {
        return new Complex(Math.atan2(1, a), 0);
      }

      var d = a * a + b * b;
      return (d !== 0)
              ? new Complex(
                      a / d,
                      -b / d).atan()
              : new Complex(
                      (a !== 0) ? a / 0 : 0,
                      (b !== 0) ? -b / 0 : 0).atan();
    }
759036
def damping_kraus_map(p=0.10):
    
    damping_op = np.sqrt(p) * np.array([[0, 1],
                                        [0, 0]])

    residual_kraus = np.diag([1, np.sqrt(1 - p)])
    return [residual_kraus, damping_op]
678982
def inverse(self):
        
        return OperatorComp(self.right.inverse, self.left.inverse,
                            self.__tmp)