forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPauliTests.qs
39 lines (30 loc) · 1.29 KB
/
PauliTests.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Tests {
open Microsoft.Quantum.Primitive;
open Microsoft.Quantum.Canon;
operation MeasureWithScratchTest() : () {
body {
using (register = Qubit[2]) {
PrepareEntangledState([register[0]], [register[1]]);
X(register[1]);
let xxScratch = MeasureWithScratch([PauliX; PauliX], register);
let xx = Measure([PauliX; PauliX], register);
if (xx != xxScratch) {
fail "〈XX〉: MeasureWithScratch and Measure disagree";
}
let yyScratch = MeasureWithScratch([PauliY; PauliY], register);
let yy = Measure([PauliY; PauliY], register);
if (yy != yyScratch) {
fail "〈yy〉: MeasureWithScratch and Measure disagree";
}
let zzScratch = MeasureWithScratch([PauliZ; PauliZ], register);
let zz = Measure([PauliZ; PauliZ], register);
if (zz != zzScratch) {
fail "〈ZZ〉: MeasureWithScratch and Measure disagree";
}
ResetAll(register);
}
}
}
}