-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtranspile_test.cpp
More file actions
66 lines (53 loc) · 1.51 KB
/
transpile_test.cpp
File metadata and controls
66 lines (53 loc) · 1.51 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
# This code is part of Qiskit.
#
# (C) Copyright IBM 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
*/
// Test program for sampler
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include "circuit/quantumcircuit.hpp"
#include "primitives/backend_sampler_v2.hpp"
#ifdef QRMI_ROOT
#include "service/qiskit_runtime_service_qrmi.hpp"
#else
#include "service/qiskit_runtime_service_c.hpp"
#endif
#include "compiler/transpiler.hpp"
using namespace Qiskit::circuit;
using namespace Qiskit::providers;
using namespace Qiskit::primitives;
using namespace Qiskit::compiler;
int main()
{
auto service = Qiskit::service::QiskitRuntimeService();
auto backend = service.backend("ibm_torino");
QuantumRegister qr(10);
ClassicalRegister cr(10);
QuantumCircuit circ(qr, cr);
circ.h(0);
for (int i=0;i<9;i++) {
circ.cx(i, i+1);
}
circ.rzz(0.1, 0, 1);
for (int i=0;i<10;i++) {
circ.measure(i,i);
}
std::cout << "input circuit" << std::endl;
circ.draw();
auto transpiled = transpile(circ, backend);
std::cout << "transpiled circuit" << std::endl;
transpiled.draw();
return 0;
}