microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billti/num2-sim

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/noisy_simulator/src/density_matrix_simulator/tests.rs

88lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use super::DensityMatrixSimulator;
5use crate::tests::{noiseless_tests, noisy_tests};
6
7#[test]
8fn check_measuring_plus_state_yields_zero_with_50_percent_probability() {
9 noiseless_tests::check_measuring_plus_state_yields_zero_with_50_percent_probability::<
10 DensityMatrixSimulator,
11 >();
12}
13
14#[test]
15fn check_measuring_plus_state_yields_one_with_50_percent_probability() {
16 noiseless_tests::check_measuring_plus_state_yields_one_with_50_percent_probability::<
17 DensityMatrixSimulator,
18 >();
19}
20
21#[test]
22fn check_bell_pair_sampling_yields_same_outcome_for_both_qubits() {
23 // We perform the test 100 times because of the probabilistic nature of the MZ measurement.
24 for seed in 0..20 {
25 noiseless_tests::check_bell_pair_sampling_yields_same_outcome_for_both_qubits::<
26 DensityMatrixSimulator,
27 >(seed);
28 }
29}
30
31#[test]
32fn check_bell_pair_projection_on_mz0_yields_50_percent_probability_trace() {
33 noiseless_tests::check_bell_pair_projection_on_mz0_yields_50_percent_probability_trace::<
34 DensityMatrixSimulator,
35 >();
36}
37
38#[test]
39fn check_bell_pair_projection_on_mz1_yields_50_percent_probability_trace() {
40 noiseless_tests::check_bell_pair_projection_on_mz1_yields_50_percent_probability_trace::<
41 DensityMatrixSimulator,
42 >();
43}
44
45#[test]
46#[should_panic(expected = "operation should fail: ProbabilityZeroEvent")]
47fn check_bell_pair_projection_on_oposite_directions_yields_an_error() {
48 noiseless_tests::check_bell_pair_projection_on_oposite_directions_yields_an_error::<
49 DensityMatrixSimulator,
50 >();
51}
52
53#[test]
54fn check_crx_gate_projection_on_mz0_yields_right_probabilities() {
55 noiseless_tests::check_crx_gate_projection_on_mz0_yields_right_probabilities::<
56 DensityMatrixSimulator,
57 >();
58}
59
60#[test]
61fn check_crx_gate_projection_on_mz1_yields_right_probabilities() {
62 noiseless_tests::check_crx_gate_projection_on_mz1_yields_right_probabilities::<
63 DensityMatrixSimulator,
64 >();
65}
66
67#[test]
68fn check_two_consecutive_mz_yield_same_outcome() {
69 // We perform the test 100 times because of the probabilistic nature of the MZ measurement.
70 for seed in 0..100 {
71 noiseless_tests::check_two_consecutive_mz_yield_same_outcome::<DensityMatrixSimulator>(
72 seed,
73 );
74 }
75}
76
77#[test]
78fn check_alternating_mz_and_mx_yield_right_probabilities() {
79 noiseless_tests::check_alternating_mz_and_mx_yield_right_probabilities::<DensityMatrixSimulator>(
80 );
81}
82
83#[test]
84fn check_noisy_identity_yields_same_qubit_with_right_probability() {
85 noisy_tests::check_noisy_identity_yields_same_qubit_with_right_probability::<
86 DensityMatrixSimulator,
87 >();
88}
89