Пример #1
0
    def test_NoiseModelEqualityBitFlip(self):
        '''
        Checks that ``NoiseModel`` equality works for equivalent bit flip maps.
        '''
        prob = 0.5
        fair_bit_flip = [
            np.sqrt(prob) * np.array([[1, 0], [0, 1]]),
            np.sqrt(1 - prob) * np.array([[0, 1], [1, 0]])
        ]

        self.assertEqual(NoiseModel(fair_bit_flip), b_flip_map(prob))
Пример #2
0
    def test_NoiseModelArgElementsShapeMismatch(self):
        '''
        ``NoiseModel`` throws a ``WrongShapeError`` if
        the shape of any of the matricies in the list of Kraus operators don't
        match all the rest.
        '''

        kraus_ops_mismatch = [np.zeros((5, 2)), np.zeros((3, 17))]
        someNoiseModel = NoiseModel()

        self.assertRaises(WrongShapeError, NoiseModel, kraus_ops_mismatch)
        self.assertRaises(WrongShapeError, someNoiseModel.setKrausOperators,
                          kraus_ops_mismatch)
Пример #3
0
    def test_NoiseModelInequalityBitFlip(self):
        '''
        Checks that ``NoiseModel`` equality works for inequivalent bit flip
        maps.
        '''
        prob_1 = 0.9
        prob_2 = 0.4
        unfair_bit_flip = [
            np.sqrt(prob_1) * np.array([[1, 0], [0, 1]]),
            np.sqrt(1 - prob_1) * np.array([[0, 1], [1, 0]])
        ]

        self.assertNotEqual(NoiseModel(unfair_bit_flip), b_flip_map(prob_2))
Пример #4
0
def b_flip_map(prob=0.1):
    '''
    Bit flip.

    Parameters
    ----------
    prob : numeric, between 0 and 1
        Probability characterizing the likelihood of the outcomes represented
        by the various Kraus operators.

    Returns
    -------
    NoiseModel
        Container of ndarray matrix representations of the Kraus operators in
        the corresponding quantum operation.
    '''

    static = np.sqrt(1 - prob) * np.array([[1, 0], [0, 1]])
    flip = np.sqrt(prob) * np.array([[0, 1], [1, 0]])

    return NoiseModel([static, flip])
Пример #5
0
def phase_map(prob=0.1):
    '''
    Phase damping.

    Parameters
    ----------
    prob : numeric, between 0 and 1
        Probability characterizing the likelihood of the outcomes represented
        by the various Kraus operators.

    Returns
    -------
    NoiseModel
        Container of ndarray matrix representations of the Kraus operators in
        the corresponding quantum operation.
    '''

    phase_1 = np.array([[1, 0], [0, np.sqrt(1 - prob)]])
    phase_2 = np.array([[0, 0], [0, np.sqrt(prob)]])

    return NoiseModel([phase_1, phase_2])
Пример #6
0
def depolarization_map(prob=0.1):
    '''
    Depolarizing channel.

    Parameters
    ----------
    prob : numeric, between 0 and 1
        Probability characterizing the likelihood of the outcomes represented
        by the various Kraus operators.

    Returns
    -------
    NoiseModel
        Container of ndarray matrix representations of the Kraus operators in
        the corresponding quantum operation.
    '''

    dep_i = np.sqrt(1 - 3.0 * prob / 4) * np.array([[1, 0], [0, 1]])
    dep_x = np.sqrt(1.0 * prob / 4) * np.array([[0, 1], [1, 0]])
    dep_y = np.sqrt(1.0 * prob / 4) * np.array([[0, -1j], [1j, 0]])
    dep_z = np.sqrt(1.0 * prob / 4) * np.array([[1, 0], [0, -1]])

    return NoiseModel([dep_i, dep_x, dep_y, dep_z])
Пример #7
0
 def setUp(self):
     self.test_noise_model = NoiseModel()