Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
qcor
Commits
1af5b5ce
Commit
1af5b5ce
authored
Sep 10, 2020
by
Mccaskey, Alex
Browse files
adding hadamard test example
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
20546261
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
examples/hadamard_test/simple_hadamard_test.cpp
0 → 100644
View file @
1af5b5ce
#include
<iomanip>
__qpu__
void
x_gate
(
qreg
q
)
{
X
(
q
[
1
]);
}
__qpu__
void
h_gate
(
qreg
q
)
{
H
(
q
[
1
]);
}
__qpu__
void
htest
(
qreg
q
)
{
// Create the superposition on the first qubit
H
(
q
[
0
]);
// create the |1> on the second qubit
x_gate
(
q
);
// create superposition on second qubit
// h_gate(q);
// apply ctrl-U
x_gate
::
ctrl
(
q
[
0
],
q
);
// add the last hadamard
H
(
q
[
0
]);
// measure
Measure
(
q
[
0
]);
}
int
main
()
{
auto
q
=
qalloc
(
2
);
htest
(
q
);
q
.
print
();
auto
count1
=
q
.
counts
().
find
(
"1"
)
->
second
;
auto
count2
=
q
.
counts
().
find
(
"0"
)
->
second
;
std
::
cout
<<
"<X> = "
<<
std
::
setprecision
(
12
)
<<
std
::
fabs
((
count1
-
count2
)
/
(
double
)(
count1
+
count2
))
<<
"
\n
"
;
}
\ No newline at end of file
handlers/token_collector/xasm/generated/xasm_single.interp
View file @
1af5b5ce
...
...
@@ -123,4 +123,4 @@ string
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 53, 241, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 3, 2, 3, 2, 5, 2, 31, 10, 2, 3, 3, 3, 3, 5, 3, 35, 10, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 5, 6, 46, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 52, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 75, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 83, 10, 6, 3, 6, 3, 6, 5, 6, 87, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 101, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 108, 10, 6, 3, 6, 5, 6, 111, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 131, 10, 6, 3, 7, 3, 7, 5, 7, 135, 10, 7, 3, 7, 5, 7, 138, 10, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 7, 9, 145, 10, 9, 12, 9, 14, 9, 148, 11, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 169, 10, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 7, 10, 228, 10, 10, 12, 10, 14, 10, 231, 11, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 2, 3, 18, 15, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 2, 6, 3, 2, 8, 9, 3, 2, 21, 22, 3, 2, 23, 26, 3, 2, 41, 46, 2, 273, 2, 30, 3, 2, 2, 2, 4, 34, 3, 2, 2, 2, 6, 36, 3, 2, 2, 2, 8, 38, 3, 2, 2, 2, 10, 130, 3, 2, 2, 2, 12, 137, 3, 2, 2, 2, 14, 139, 3, 2, 2, 2, 16, 141, 3, 2, 2, 2, 18, 168, 3, 2, 2, 2, 20, 232, 3, 2, 2, 2, 22, 234, 3, 2, 2, 2, 24, 236, 3, 2, 2, 2, 26, 238, 3, 2, 2, 2, 28, 31, 5, 4, 3, 2, 29, 31, 5, 6, 4, 2, 30, 28, 3, 2, 2, 2, 30, 29, 3, 2, 2, 2, 31, 3, 3, 2, 2, 2, 32, 35, 5, 8, 5, 2, 33, 35, 5, 10, 6, 2, 34, 32, 3, 2, 2, 2, 34, 33, 3, 2, 2, 2, 35, 5, 3, 2, 2, 2, 36, 37, 7, 47, 2, 2, 37, 7, 3, 2, 2, 2, 38, 39, 5, 22, 12, 2, 39, 40, 7, 3, 2, 2, 40, 41, 5, 16, 9, 2, 41, 42, 7, 4, 2, 2, 42, 43, 7, 5, 2, 2, 43, 9, 3, 2, 2, 2, 44, 46, 7, 6, 2, 2, 45, 44, 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 48, 5, 12, 7, 2, 48, 51, 5, 18, 10, 2, 49, 50, 7, 7, 2, 2, 50, 52, 5, 18, 10, 2, 51, 49, 3, 2, 2, 2, 51, 52, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 54, 7, 5, 2, 2, 54, 131, 3, 2, 2, 2, 55, 56, 5, 18, 10, 2, 56, 57, 7, 8, 2, 2, 57, 58, 7, 5, 2, 2, 58, 131, 3, 2, 2, 2, 59, 60, 5, 18, 10, 2, 60, 61, 7, 9, 2, 2, 61, 62, 7, 5, 2, 2, 62, 131, 3, 2, 2, 2, 63, 64, 7, 10, 2, 2, 64, 65, 7, 3, 2, 2, 65, 66, 5, 12, 7, 2, 66, 67, 5, 18, 10, 2, 67, 68, 7, 7, 2, 2, 68, 69, 5, 18, 10, 2, 69, 74, 7, 5, 2, 2, 70, 71, 5, 18, 10, 2, 71, 72, 5, 14, 8, 2, 72, 73, 5, 18, 10, 2, 73, 75, 3, 2, 2, 2, 74, 70, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 82, 7, 5, 2, 2, 77, 78, 5, 18, 10, 2, 78, 79, 9, 2, 2, 2, 79, 83, 3, 2, 2, 2, 80, 81, 9, 2, 2, 2, 81, 83, 5, 18, 10, 2, 82, 77, 3, 2, 2, 2, 82, 80, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 86, 7, 4, 2, 2, 85, 87, 7, 11, 2, 2, 86, 85, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 131, 3, 2, 2, 2, 88, 131, 7, 12, 2, 2, 89, 90, 5, 18, 10, 2, 90, 91, 7, 3, 2, 2, 91, 92, 5, 16, 9, 2, 92, 93, 7, 4, 2, 2, 93, 94, 7, 5, 2, 2, 94, 131, 3, 2, 2, 2, 95, 96, 7, 13, 2, 2, 96, 97, 7, 3, 2, 2, 97, 98, 5, 16, 9, 2, 98, 100, 7, 4, 2, 2, 99, 101, 7, 11, 2, 2, 100, 99, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 131, 3, 2, 2, 2, 102, 103, 7, 14, 2, 2, 103, 104, 7, 3, 2, 2, 104, 105, 5, 16, 9, 2, 105, 107, 7, 4, 2, 2, 106, 108, 7, 11, 2, 2, 107, 106, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 131, 3, 2, 2, 2, 109, 111, 7, 6, 2, 2, 110, 109, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 113, 5, 12, 7, 2, 113, 114, 5, 18, 10, 2, 114, 115, 7, 7, 2, 2, 115, 116, 7, 3, 2, 2, 116, 117, 5, 18, 10, 2, 117, 118, 7, 15, 2, 2, 118, 119, 5, 18, 10, 2, 119, 120, 7, 4, 2, 2, 120, 121, 7, 16, 2, 2, 121, 122, 5, 18, 10, 2, 122, 123, 7, 17, 2, 2, 123, 124, 5, 18, 10, 2, 124, 125, 7, 5, 2, 2, 125, 131, 3, 2, 2, 2, 126, 127, 7, 18, 2, 2, 127, 131, 7, 5, 2, 2, 128, 129, 7, 19, 2, 2, 129, 131, 7, 5, 2, 2, 130, 45, 3, 2, 2, 2, 130, 55, 3, 2, 2, 2, 130, 59, 3, 2, 2, 2, 130, 63, 3, 2, 2, 2, 130, 88, 3, 2, 2, 2, 130, 89, 3, 2, 2, 2, 130, 95, 3, 2, 2, 2, 130, 102, 3, 2, 2, 2, 130, 110, 3, 2, 2, 2, 130, 126, 3, 2, 2, 2, 130, 128, 3, 2, 2, 2, 131, 11, 3, 2, 2, 2, 132, 134, 7, 20, 2, 2, 133, 135, 9, 3, 2, 2, 134, 133, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 138, 3, 2, 2, 2, 136, 138, 5, 18, 10, 2, 137, 132, 3, 2, 2, 2, 137, 136, 3, 2, 2, 2, 138, 13, 3, 2, 2, 2, 139, 140, 9, 4, 2, 2, 140, 15, 3, 2, 2, 2, 141, 146, 5, 18, 10, 2, 142, 143, 7, 27, 2, 2, 143, 145, 5, 18, 10, 2, 144, 142, 3, 2, 2, 2, 145, 148, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 17, 3, 2, 2, 2, 148, 146, 3, 2, 2, 2, 149, 150, 8, 10, 1, 2, 150, 169, 5, 22, 12, 2, 151, 152, 7, 29, 2, 2, 152, 169, 5, 18, 10, 14, 153, 154, 7, 3, 2, 2, 154, 155, 5, 18, 10, 2, 155, 156, 7, 4, 2, 2, 156, 169, 3, 2, 2, 2, 157, 158, 5, 20, 11, 2, 158, 159, 7, 3, 2, 2, 159, 160, 5, 18, 10, 2, 160, 161, 7, 4, 2, 2, 161, 169, 3, 2, 2, 2, 162, 169, 5, 26, 14, 2, 163, 169, 5, 24, 13, 2, 164, 169, 7, 50, 2, 2, 165, 169, 7, 37, 2, 2, 166, 167, 7, 40, 2, 2, 167, 169, 5, 18, 10, 3, 168, 149, 3, 2, 2, 2, 168, 151, 3, 2, 2, 2, 168, 153, 3, 2, 2, 2, 168, 157, 3, 2, 2, 2, 168, 162, 3, 2, 2, 2, 168, 163, 3, 2, 2, 2, 168, 164, 3, 2, 2, 2, 168, 165, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 169, 229, 3, 2, 2, 2, 170, 171, 12, 24, 2, 2, 171, 172, 7, 28, 2, 2, 172, 228, 5, 18, 10, 25, 173, 174, 12, 23, 2, 2, 174, 175, 7, 29, 2, 2, 175, 228, 5, 18, 10, 24, 176, 177, 12, 22, 2, 2, 177, 178, 7, 22, 2, 2, 178, 228, 5, 18, 10, 23, 179, 180, 12, 21, 2, 2, 180, 181, 7, 30, 2, 2, 181, 228, 5, 18, 10, 22, 182, 183, 12, 20, 2, 2, 183, 184, 7, 31, 2, 2, 184, 228, 5, 18, 10, 21, 185, 186, 12, 19, 2, 2, 186, 187, 7, 32, 2, 2, 187, 228, 5, 18, 10, 20, 188, 189, 12, 13, 2, 2, 189, 190, 7, 34, 2, 2, 190, 228, 5, 18, 10, 14, 191, 192, 12, 5, 2, 2, 192, 193, 7, 38, 2, 2, 193, 228, 5, 18, 10, 6, 194, 195, 12, 4, 2, 2, 195, 196, 7, 39, 2, 2, 196, 228, 5, 18, 10, 5, 197, 198, 12, 18, 2, 2, 198, 199, 7, 24, 2, 2, 199, 200, 5, 18, 10, 2, 200, 201, 7, 23, 2, 2, 201, 228, 3, 2, 2, 2, 202, 203, 12, 17, 2, 2, 203, 204, 7, 31, 2, 2, 204, 205, 5, 18, 10, 2, 205, 206, 7, 3, 2, 2, 206, 207, 5, 16, 9, 2, 207, 208, 7, 4, 2, 2, 208, 228, 3, 2, 2, 2, 209, 210, 12, 16, 2, 2, 210, 211, 7, 33, 2, 2, 211, 212, 5, 18, 10, 2, 212, 213, 7, 3, 2, 2, 213, 214, 7, 4, 2, 2, 214, 228, 3, 2, 2, 2, 215, 216, 12, 15, 2, 2, 216, 217, 7, 33, 2, 2, 217, 218, 5, 18, 10, 2, 218, 219, 7, 3, 2, 2, 219, 220, 5, 16, 9, 2, 220, 221, 7, 4, 2, 2, 221, 228, 3, 2, 2, 2, 222, 223, 12, 10, 2, 2, 223, 224, 7, 35, 2, 2, 224, 225, 5, 18, 10, 2, 225, 226, 7, 36, 2, 2, 226, 228, 3, 2, 2, 2, 227, 170, 3, 2, 2, 2, 227, 173, 3, 2, 2, 2, 227, 176, 3, 2, 2, 2, 227, 179, 3, 2, 2, 2, 227, 182, 3, 2, 2, 2, 227, 185, 3, 2, 2, 2, 227, 188, 3, 2, 2, 2, 227, 191, 3, 2, 2, 2, 227, 194, 3, 2, 2, 2, 227, 197, 3, 2, 2, 2, 227, 202, 3, 2, 2, 2, 227, 209, 3, 2, 2, 2, 227, 215, 3, 2, 2, 2, 227, 222, 3, 2, 2, 2, 228, 231, 3, 2, 2, 2, 229, 227, 3, 2, 2, 2, 229, 230, 3, 2, 2, 2, 230, 19, 3, 2, 2, 2, 231, 229, 3, 2, 2, 2, 232, 233, 9, 5, 2, 2, 233, 21, 3, 2, 2, 2, 234, 235, 7, 48, 2, 2, 235, 23, 3, 2, 2, 2, 236, 237, 7, 49, 2, 2, 237, 25, 3, 2, 2, 2, 238, 239, 7, 51, 2, 2, 239, 27, 3, 2, 2, 2, 19, 30, 34, 45, 51, 74, 82, 86, 100, 107, 110, 130, 134, 137, 146, 168, 227, 229]
\ No newline at end of file
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 53, 246, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 3, 2, 3, 2, 5, 2, 31, 10, 2, 3, 3, 3, 3, 5, 3, 35, 10, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 5, 6, 46, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 52, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 75, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 83, 10, 6, 3, 6, 3, 6, 5, 6, 87, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 101, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 108, 10, 6, 3, 6, 5, 6, 111, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 136, 10, 6, 3, 7, 3, 7, 5, 7, 140, 10, 7, 3, 7, 5, 7, 143, 10, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 7, 9, 150, 10, 9, 12, 9, 14, 9, 153, 11, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 5, 10, 174, 10, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 7, 10, 233, 10, 10, 12, 10, 14, 10, 236, 11, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 2, 3, 18, 15, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 2, 6, 3, 2, 8, 9, 3, 2, 21, 22, 3, 2, 23, 26, 3, 2, 41, 46, 2, 279, 2, 30, 3, 2, 2, 2, 4, 34, 3, 2, 2, 2, 6, 36, 3, 2, 2, 2, 8, 38, 3, 2, 2, 2, 10, 135, 3, 2, 2, 2, 12, 142, 3, 2, 2, 2, 14, 144, 3, 2, 2, 2, 16, 146, 3, 2, 2, 2, 18, 173, 3, 2, 2, 2, 20, 237, 3, 2, 2, 2, 22, 239, 3, 2, 2, 2, 24, 241, 3, 2, 2, 2, 26, 243, 3, 2, 2, 2, 28, 31, 5, 4, 3, 2, 29, 31, 5, 6, 4, 2, 30, 28, 3, 2, 2, 2, 30, 29, 3, 2, 2, 2, 31, 3, 3, 2, 2, 2, 32, 35, 5, 8, 5, 2, 33, 35, 5, 10, 6, 2, 34, 32, 3, 2, 2, 2, 34, 33, 3, 2, 2, 2, 35, 5, 3, 2, 2, 2, 36, 37, 7, 47, 2, 2, 37, 7, 3, 2, 2, 2, 38, 39, 5, 22, 12, 2, 39, 40, 7, 3, 2, 2, 40, 41, 5, 16, 9, 2, 41, 42, 7, 4, 2, 2, 42, 43, 7, 5, 2, 2, 43, 9, 3, 2, 2, 2, 44, 46, 7, 6, 2, 2, 45, 44, 3, 2, 2, 2, 45, 46, 3, 2, 2, 2, 46, 47, 3, 2, 2, 2, 47, 48, 5, 12, 7, 2, 48, 51, 5, 18, 10, 2, 49, 50, 7, 7, 2, 2, 50, 52, 5, 18, 10, 2, 51, 49, 3, 2, 2, 2, 51, 52, 3, 2, 2, 2, 52, 53, 3, 2, 2, 2, 53, 54, 7, 5, 2, 2, 54, 136, 3, 2, 2, 2, 55, 56, 5, 18, 10, 2, 56, 57, 7, 8, 2, 2, 57, 58, 7, 5, 2, 2, 58, 136, 3, 2, 2, 2, 59, 60, 5, 18, 10, 2, 60, 61, 7, 9, 2, 2, 61, 62, 7, 5, 2, 2, 62, 136, 3, 2, 2, 2, 63, 64, 7, 10, 2, 2, 64, 65, 7, 3, 2, 2, 65, 66, 5, 12, 7, 2, 66, 67, 5, 18, 10, 2, 67, 68, 7, 7, 2, 2, 68, 69, 5, 18, 10, 2, 69, 74, 7, 5, 2, 2, 70, 71, 5, 18, 10, 2, 71, 72, 5, 14, 8, 2, 72, 73, 5, 18, 10, 2, 73, 75, 3, 2, 2, 2, 74, 70, 3, 2, 2, 2, 74, 75, 3, 2, 2, 2, 75, 76, 3, 2, 2, 2, 76, 82, 7, 5, 2, 2, 77, 78, 5, 18, 10, 2, 78, 79, 9, 2, 2, 2, 79, 83, 3, 2, 2, 2, 80, 81, 9, 2, 2, 2, 81, 83, 5, 18, 10, 2, 82, 77, 3, 2, 2, 2, 82, 80, 3, 2, 2, 2, 82, 83, 3, 2, 2, 2, 83, 84, 3, 2, 2, 2, 84, 86, 7, 4, 2, 2, 85, 87, 7, 11, 2, 2, 86, 85, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 136, 3, 2, 2, 2, 88, 136, 7, 12, 2, 2, 89, 90, 5, 18, 10, 2, 90, 91, 7, 3, 2, 2, 91, 92, 5, 16, 9, 2, 92, 93, 7, 4, 2, 2, 93, 94, 7, 5, 2, 2, 94, 136, 3, 2, 2, 2, 95, 96, 7, 13, 2, 2, 96, 97, 7, 3, 2, 2, 97, 98, 5, 16, 9, 2, 98, 100, 7, 4, 2, 2, 99, 101, 7, 11, 2, 2, 100, 99, 3, 2, 2, 2, 100, 101, 3, 2, 2, 2, 101, 136, 3, 2, 2, 2, 102, 103, 7, 14, 2, 2, 103, 104, 7, 3, 2, 2, 104, 105, 5, 16, 9, 2, 105, 107, 7, 4, 2, 2, 106, 108, 7, 11, 2, 2, 107, 106, 3, 2, 2, 2, 107, 108, 3, 2, 2, 2, 108, 136, 3, 2, 2, 2, 109, 111, 7, 6, 2, 2, 110, 109, 3, 2, 2, 2, 110, 111, 3, 2, 2, 2, 111, 112, 3, 2, 2, 2, 112, 113, 5, 12, 7, 2, 113, 114, 5, 18, 10, 2, 114, 115, 7, 7, 2, 2, 115, 116, 7, 3, 2, 2, 116, 117, 5, 18, 10, 2, 117, 118, 7, 15, 2, 2, 118, 119, 5, 18, 10, 2, 119, 120, 7, 4, 2, 2, 120, 121, 7, 16, 2, 2, 121, 122, 5, 18, 10, 2, 122, 123, 7, 17, 2, 2, 123, 124, 5, 18, 10, 2, 124, 125, 7, 5, 2, 2, 125, 136, 3, 2, 2, 2, 126, 127, 7, 18, 2, 2, 127, 136, 7, 5, 2, 2, 128, 129, 7, 19, 2, 2, 129, 136, 7, 5, 2, 2, 130, 131, 5, 18, 10, 2, 131, 132, 7, 7, 2, 2, 132, 133, 5, 18, 10, 2, 133, 134, 7, 5, 2, 2, 134, 136, 3, 2, 2, 2, 135, 45, 3, 2, 2, 2, 135, 55, 3, 2, 2, 2, 135, 59, 3, 2, 2, 2, 135, 63, 3, 2, 2, 2, 135, 88, 3, 2, 2, 2, 135, 89, 3, 2, 2, 2, 135, 95, 3, 2, 2, 2, 135, 102, 3, 2, 2, 2, 135, 110, 3, 2, 2, 2, 135, 126, 3, 2, 2, 2, 135, 128, 3, 2, 2, 2, 135, 130, 3, 2, 2, 2, 136, 11, 3, 2, 2, 2, 137, 139, 7, 20, 2, 2, 138, 140, 9, 3, 2, 2, 139, 138, 3, 2, 2, 2, 139, 140, 3, 2, 2, 2, 140, 143, 3, 2, 2, 2, 141, 143, 5, 18, 10, 2, 142, 137, 3, 2, 2, 2, 142, 141, 3, 2, 2, 2, 143, 13, 3, 2, 2, 2, 144, 145, 9, 4, 2, 2, 145, 15, 3, 2, 2, 2, 146, 151, 5, 18, 10, 2, 147, 148, 7, 27, 2, 2, 148, 150, 5, 18, 10, 2, 149, 147, 3, 2, 2, 2, 150, 153, 3, 2, 2, 2, 151, 149, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 17, 3, 2, 2, 2, 153, 151, 3, 2, 2, 2, 154, 155, 8, 10, 1, 2, 155, 174, 5, 22, 12, 2, 156, 157, 7, 29, 2, 2, 157, 174, 5, 18, 10, 14, 158, 159, 7, 3, 2, 2, 159, 160, 5, 18, 10, 2, 160, 161, 7, 4, 2, 2, 161, 174, 3, 2, 2, 2, 162, 163, 5, 20, 11, 2, 163, 164, 7, 3, 2, 2, 164, 165, 5, 18, 10, 2, 165, 166, 7, 4, 2, 2, 166, 174, 3, 2, 2, 2, 167, 174, 5, 26, 14, 2, 168, 174, 5, 24, 13, 2, 169, 174, 7, 50, 2, 2, 170, 174, 7, 37, 2, 2, 171, 172, 7, 40, 2, 2, 172, 174, 5, 18, 10, 3, 173, 154, 3, 2, 2, 2, 173, 156, 3, 2, 2, 2, 173, 158, 3, 2, 2, 2, 173, 162, 3, 2, 2, 2, 173, 167, 3, 2, 2, 2, 173, 168, 3, 2, 2, 2, 173, 169, 3, 2, 2, 2, 173, 170, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 174, 234, 3, 2, 2, 2, 175, 176, 12, 24, 2, 2, 176, 177, 7, 28, 2, 2, 177, 233, 5, 18, 10, 25, 178, 179, 12, 23, 2, 2, 179, 180, 7, 29, 2, 2, 180, 233, 5, 18, 10, 24, 181, 182, 12, 22, 2, 2, 182, 183, 7, 22, 2, 2, 183, 233, 5, 18, 10, 23, 184, 185, 12, 21, 2, 2, 185, 186, 7, 30, 2, 2, 186, 233, 5, 18, 10, 22, 187, 188, 12, 20, 2, 2, 188, 189, 7, 31, 2, 2, 189, 233, 5, 18, 10, 21, 190, 191, 12, 19, 2, 2, 191, 192, 7, 32, 2, 2, 192, 233, 5, 18, 10, 20, 193, 194, 12, 13, 2, 2, 194, 195, 7, 34, 2, 2, 195, 233, 5, 18, 10, 14, 196, 197, 12, 5, 2, 2, 197, 198, 7, 38, 2, 2, 198, 233, 5, 18, 10, 6, 199, 200, 12, 4, 2, 2, 200, 201, 7, 39, 2, 2, 201, 233, 5, 18, 10, 5, 202, 203, 12, 18, 2, 2, 203, 204, 7, 24, 2, 2, 204, 205, 5, 18, 10, 2, 205, 206, 7, 23, 2, 2, 206, 233, 3, 2, 2, 2, 207, 208, 12, 17, 2, 2, 208, 209, 7, 31, 2, 2, 209, 210, 5, 18, 10, 2, 210, 211, 7, 3, 2, 2, 211, 212, 5, 16, 9, 2, 212, 213, 7, 4, 2, 2, 213, 233, 3, 2, 2, 2, 214, 215, 12, 16, 2, 2, 215, 216, 7, 33, 2, 2, 216, 217, 5, 18, 10, 2, 217, 218, 7, 3, 2, 2, 218, 219, 7, 4, 2, 2, 219, 233, 3, 2, 2, 2, 220, 221, 12, 15, 2, 2, 221, 222, 7, 33, 2, 2, 222, 223, 5, 18, 10, 2, 223, 224, 7, 3, 2, 2, 224, 225, 5, 16, 9, 2, 225, 226, 7, 4, 2, 2, 226, 233, 3, 2, 2, 2, 227, 228, 12, 10, 2, 2, 228, 229, 7, 35, 2, 2, 229, 230, 5, 18, 10, 2, 230, 231, 7, 36, 2, 2, 231, 233, 3, 2, 2, 2, 232, 175, 3, 2, 2, 2, 232, 178, 3, 2, 2, 2, 232, 181, 3, 2, 2, 2, 232, 184, 3, 2, 2, 2, 232, 187, 3, 2, 2, 2, 232, 190, 3, 2, 2, 2, 232, 193, 3, 2, 2, 2, 232, 196, 3, 2, 2, 2, 232, 199, 3, 2, 2, 2, 232, 202, 3, 2, 2, 2, 232, 207, 3, 2, 2, 2, 232, 214, 3, 2, 2, 2, 232, 220, 3, 2, 2, 2, 232, 227, 3, 2, 2, 2, 233, 236, 3, 2, 2, 2, 234, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 19, 3, 2, 2, 2, 236, 234, 3, 2, 2, 2, 237, 238, 9, 5, 2, 2, 238, 21, 3, 2, 2, 2, 239, 240, 7, 48, 2, 2, 240, 23, 3, 2, 2, 2, 241, 242, 7, 49, 2, 2, 242, 25, 3, 2, 2, 2, 243, 244, 7, 51, 2, 2, 244, 27, 3, 2, 2, 2, 19, 30, 34, 45, 51, 74, 82, 86, 100, 107, 110, 135, 139, 142, 151, 173, 232, 234]
\ No newline at end of file
handlers/token_collector/xasm/generated/xasm_singleParser.cpp
View file @
1af5b5ce
This diff is collapsed.
Click to expand it.
handlers/token_collector/xasm/xasm_single.g4
View file @
1af5b5ce
...
...
@@ -33,6 +33,7 @@ cinst
| 'const'? type_name=cpp_type var_name=exp '=' '(' exp '==' exp ')' '?' exp ':' exp ';'
| 'break' ';'
| 'return' ';'
| exp '=' exp ';'
;
cpp_type
...
...
runtime/kernel/quantum_kernel.hpp
View file @
1af5b5ce
...
...
@@ -159,8 +159,40 @@ public:
parent_kernel
->
addInstruction
(
ctrlKernel
->
getInstruction
(
instId
)
->
clone
());
}
// Need to reset and point current program to the parent
quantum
::
set_current_program
(
parent_kernel
);
}
// Create the controlled version of this quantum kernel
static
void
ctrl
(
std
::
shared_ptr
<
CompositeInstruction
>
parent_kernel
,
qubit
ctrl_qbit
,
Args
...
args
)
{
int
ctrl_bit
=
(
int
)
ctrl_qbit
.
second
;
// instantiate and don't let it call the destructor
Derived
derived
(
args
...);
derived
.
disable_destructor
=
true
;
// run the operator()(args...) call to get the the functor
// as a CompositeInstruction (derived.parent_kernel)
derived
(
args
...);
// Use the controlled gate module of XACC to transform
auto
tempKernel
=
qcor
::
__internal__
::
create_composite
(
"temp_control"
);
tempKernel
->
addInstruction
(
derived
.
parent_kernel
);
auto
ctrlKernel
=
qcor
::
__internal__
::
create_ctrl_u
();
ctrlKernel
->
expand
({{
"U"
,
tempKernel
},
{
"control-idx"
,
ctrl_bit
},
{
"control-buffer"
,
ctrl_qbit
.
first
}});
for
(
int
instId
=
0
;
instId
<
ctrlKernel
->
nInstructions
();
++
instId
)
{
parent_kernel
->
addInstruction
(
ctrlKernel
->
getInstruction
(
instId
)
->
clone
());
}
// Need to reset and point current program to the parent
quantum
::
set_current_program
(
parent_kernel
);
}
virtual
~
QuantumKernel
()
{}
};
...
...
runtime/observable/qcor_observable.cpp
View file @
1af5b5ce
...
...
@@ -6,6 +6,22 @@
namespace
qcor
{
PauliOperator
operator
+
(
double
coeff
,
PauliOperator
&
op
)
{
return
PauliOperator
(
coeff
)
+
op
;
}
PauliOperator
operator
+
(
PauliOperator
&
op
,
double
coeff
)
{
return
PauliOperator
(
coeff
)
+
op
;
}
PauliOperator
operator
-
(
double
coeff
,
PauliOperator
&
op
)
{
return
-
1.0
*
coeff
+
op
;
}
PauliOperator
operator
-
(
PauliOperator
&
op
,
double
coeff
)
{
return
-
1.0
*
coeff
+
op
;
}
PauliOperator
X
(
int
idx
)
{
return
PauliOperator
({{
idx
,
"X"
}});
}
PauliOperator
Y
(
int
idx
)
{
return
PauliOperator
({{
idx
,
"Y"
}});
}
...
...
runtime/observable/qcor_observable.hpp
View file @
1af5b5ce
...
...
@@ -20,20 +20,10 @@ PauliOperator SM(int idx);
PauliOperator
allZs
(
const
int
nQubits
);
// Expose extra algebra needed for pauli operators
template
<
typename
T
>
PauliOperator
operator
+
(
T
coeff
,
PauliOperator
&
op
)
{
return
PauliOperator
(
coeff
)
+
op
;
}
template
<
typename
T
>
PauliOperator
operator
+
(
PauliOperator
&
op
,
T
coeff
)
{
return
PauliOperator
(
coeff
)
+
op
;
}
template
<
typename
T
>
PauliOperator
operator
-
(
T
coeff
,
PauliOperator
&
op
)
{
return
-
1.0
*
coeff
+
op
;
}
template
<
typename
T
>
PauliOperator
operator
-
(
PauliOperator
&
op
,
T
coeff
)
{
return
-
1.0
*
coeff
+
op
;
}
PauliOperator
operator
+
(
double
coeff
,
PauliOperator
&
op
);
PauliOperator
operator
+
(
PauliOperator
&
op
,
double
coeff
);
PauliOperator
operator
-
(
double
coeff
,
PauliOperator
&
op
);
PauliOperator
operator
-
(
PauliOperator
&
op
,
double
coeff
);
// Public observe function, returns expected value of Observable
template
<
typename
...
Args
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment