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
xacc
Commits
33cc54ca
Commit
33cc54ca
authored
Jul 01, 2019
by
Mccaskey, Alex
Browse files
adding xacc observe example
Signed-off-by:
Alex McCaskey
<
mccaskeyaj@ornl.gov
>
parent
01cdc8c3
Pipeline
#61768
failed with stages
in 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tools/compiler/examples/deuteron_with_observation.cpp
0 → 100644
View file @
33cc54ca
#include
"xacc_runtime.hpp"
#include
<iostream>
__qpu__
void
ansatz
(
qbit
&
q
,
double
t0
)
{
X
(
0
);
Ry
(
t0
,
1
);
CX
(
1
,
0
);
}
int
main
(
int
argc
,
char
**
argv
)
{
xacc
::
Initialize
(
argc
,
argv
);
auto
hamiltonian
=
xacc
::
getObservable
(
"pauli"
,
"5.907 - 2.1433 X0X1 "
"- 2.1433 Y0Y1"
"+ .21829 Z0 - 6.125 Z1"
);
for
(
auto
&
t
:
xacc
::
linspace
(
-
3.14
,
3.14
,
40
))
{
// Allocate a register of 2 qubits
qbit
q
=
xacc
::
qalloc
(
2
);
#pragma xacc observe hamiltonian
ansatz
(
q
,
t
);
auto
energy
=
q
->
getInformation
(
"observation"
);
std
::
cout
<<
"E("
<<
t
<<
") = "
<<
mpark
::
get
<
double
>
(
energy
)
<<
"
\n
"
;
}
xacc
::
Finalize
();
return
0
;
}
\ No newline at end of file
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