|
6 | 6 | #include <random>
|
7 | 7 | #include <vector>
|
8 | 8 |
|
9 |
| -#include "../include/clara.h" |
10 | 9 | #include "../include/experimental/experimental_test.h"
|
11 | 10 |
|
12 | 11 | /**
|
|
18 | 17 | */
|
19 | 18 |
|
20 | 19 | using namespace clara;
|
| 20 | +using namespace::experimental; |
21 | 21 | int main() {
|
22 |
| - std::cout << "testing testing \n"; |
23 |
| - |
24 |
| - // initialize bit circuit with 70 bits |
25 |
| - const idx bits = 70; |
26 |
| - experimental::Bit_circuit b{bits}; |
27 |
| - |
28 |
| - const idx trials = 20; |
29 |
| - |
30 |
| - // number of trials |
31 |
| - b.rand(); |
32 |
| - auto c = b; |
33 |
| - |
34 |
| - /** |
35 |
| - * random number generator `gen` is set up using |
36 |
| - * random_device for generating random indices. for each trial |
37 |
| - * vector `v` is filled wuth values from `0` to `bits-1`. the element |
38 |
| - * of `v` represent the indices of the `TOF` (Toffoli) operation. these indices |
39 |
| - * are store for later use in trials |
40 |
| - */ |
41 |
| - std::random_device rd; |
42 |
| - std::mt19937 gen{rd()}; |
43 |
| - std::vector<std::vector<idx>> indices(trials); |
44 |
| - |
45 |
| - for (idx i = 0; i < trials; ++i) { |
46 |
| - std::vector<idx> v(bits); |
47 |
| - std::iota(v.begin(), v.end(), 0); |
48 |
| - std::shuffle(v.begin(), v.end(), gen); |
49 |
| - std::vector<idx> tof(v.data(), v.data() + 3); |
50 |
| - indices[i] = tof; |
51 |
| - } |
52 |
| - |
53 |
| - /** |
54 |
| - * the first half of the trials is performed. the indices for each trials are |
55 |
| - * printed, and the `TOF` operations is applied to the `Bit_circuit` using |
56 |
| - * corresponding indices |
57 |
| - */ |
58 |
| - for (idx i = 0; i < trials; ++i) { |
59 |
| - std::cout << "first: "; |
60 |
| - for (auto&& elem : indices[i]) |
61 |
| - std::cout << elem << " "; |
62 |
| - std::cout << std::endl; |
63 |
| - b.TOF(indices[i]); |
64 |
| - } |
65 |
| - |
66 |
| - /** |
67 |
| - * the second half of the trials performed in reverse order. the indices for each |
68 |
| - * trial are again printed, and the `TOF` operation is applied to the `Bit_circuit` |
69 |
| - * using the corresponding indices |
70 |
| - */ |
71 |
| - for (idx i = trials; i-- > 0;) { |
72 |
| - std::cout << "second: "; |
73 |
| - for (auto&& elem : indices[i]) |
74 |
| - std::cout << elem << " "; |
75 |
| - std::cout << std::endl; |
76 |
| - b.TOF(indices[i]); |
77 |
| - } |
78 |
| - |
79 |
| - /** |
80 |
| - * the initail and final state are printed. the hamming weight (number of set bits) |
81 |
| - * of `b` is displayed. the count of NOT, X and TOF gates used in `b` is printed |
82 |
| - */ |
83 |
| - std::cout << "initial: " << b << std::endl; |
84 |
| - std::cout << "final: " << c << std::endl; |
85 |
| - std::cout << "hamming weight: " << b.count() << std::endl; |
86 |
| - |
87 |
| - std::cout << b.gate_count.NOT << " " << b.gate_count.X << " " << b.gate_count.TOF << std::endl; |
88 |
| - std::cout << (b == c) << std::endl; |
89 |
| - std::cout << (b != c) << std::endl; |
90 |
| - |
91 |
| - /** |
92 |
| - * various quantum states and projections are created and printed |
93 |
| - */ |
94 |
| - experimental::Dynamic_bitset bb(9); |
95 |
| - bb.set(1).set(3).set(8); |
96 |
| - std::cout << bb << std::endl; |
97 |
| - |
98 |
| - std::cout << "info: " << std::endl; |
99 |
| - std::cout << bb.to_string('o', 'X') << std::endl; |
100 |
| - |
101 |
| - experimental::Dynamic_bitset vlad(20); |
102 |
| - std::cout << vlad << std::endl; |
103 |
| - |
104 |
| - std::vector<unsigned int> vv(20); |
105 |
| - for (auto& elem : vv) { |
106 |
| - std::cout << elem; |
107 |
| - } |
108 |
| - std::cout << std::endl; |
109 |
| - |
110 |
| - ket x = (10_ket + 01_ket) / std::sqrt(2); |
111 |
| - std::cout << disp(x) << std::endl; |
112 |
| - |
113 |
| - bra y = (10_bra + 01_bra) / std::sqrt(2); |
114 |
| - std::cout << disp(x) << std::endl; |
115 |
| - |
116 |
| - cmat z = 110_prj; |
117 |
| - std::cout << disp(z) << std::endl; |
| 22 | + ClaraCircuit<int> claraCircuit(10, 10); |
| 23 | + claraCircuit.apply_all(gt.H); |
| 24 | + std::cout << claraCircuit.get_num_active_qubits() << std::endl; |
| 25 | + |
| 26 | + claraCircuit.measure({3, 1, 7}); |
| 27 | + std::cout << claraCircuit.get_num_active_qubits() << std::endl; |
| 28 | + // std::cout << claraCircuit.get_num_measured_qubits() << std::endl; |
| 29 | + // std::cout << claraCircuit.get_num_active_qubits() << std::endl; |
118 | 30 | }
|
0 commit comments