Commit 9f5d571f authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updating ibm docs

parent a846dc6b
......@@ -8,14 +8,16 @@ Installation
If you want support for the D-Wave Accelerator, you must install
`CppRestSDK <https://github.com/microsoft/cpprestsdk>`_ and OpenSSL. This
is required for these Accelerators to make remote HTTP Rest calls to their
respective server APIs. Here's how to install these as binaries on various popular platforms:
is required for making remote HTTP Rest calls to the D-Wave server APIs.
Here's how to install these as binaries on various popular platforms:
.. code::
$ (macosx) brew install cpprestsdk
$ (fedora) dnf install cpprest-devel openssl-devel
$ (ubuntu) apt-get install libcpprest-dev libssl-dev
$ (slack) slack install cpprestsdk
$ (slack) slack install openssl
The `D-Wave Plugin <https://github.com/ornl-qci/xacc-dwave>`_ provides
support to XACC for executing programs on the D-Wave QPU via the D-Wave Accelerator.
......@@ -26,6 +28,19 @@ To install this plugin, run the following
$ xacc-install-plugins.py -p xacc-dwave
.. note::
It has been observed on Mac OS X that the above command may fail
due to CMake incorrectly finding OpenSSL. If that happens, run the
following:
.. code::
$ xacc-install-plugins.py -p xacc-dwave -a OPENSSL_ROOT_DIR=/usr/local/opt/openssl
Homebrew creates the above OpenSSL root directory. If yours is different, then
set the ``OPENSSL_ROOT_DIR`` as such.
You have now installed the D-Wave plugin. It is located in ``$XACC_ROOT/lib/plugins/accelerator`` and ``$XACC_ROOT/lib/plugins/compilers``, where XACC_ROOT is your XACC install prefix.
Extensibility for Minor Graph Embedding Algorithms
......
......@@ -6,16 +6,18 @@ Installation
.. note::
If you want support for the D-Wave Accelerator, you must install
If you want support for the IBM Accelerator, you must install
`CppRestSDK <https://github.com/microsoft/cpprestsdk>`_ and OpenSSL. This
is required for these Accelerators to make remote HTTP Rest calls to their
respective server APIs. Here's how to install these as binaries on various popular platforms:
is required to make remote HTTP Rest calls to the IBM Quantum Experience
server APIs. Here's how to install these as binaries on various popular platforms:
.. code::
$ (macosx) brew install cpprestsdk
$ (fedora) dnf install cpprest-devel openssl-devel
$ (ubuntu) apt-get install libcpprest-dev libssl-dev
$ (slack) slack install cpprestsdk
$ (slack) slack install openssl
The `IBM Plugin <https://github.com/ornl-qci/xacc-ibm>`_ provides
......@@ -28,5 +30,132 @@ To install this plugin, run the following
$ xacc-install-plugins.py -p xacc-ibm
.. note::
It has been observed on Mac OS X that the above command may fail
due to CMake incorrectly finding OpenSSL. If that happens, run the
following:
.. code::
$ xacc-install-plugins.py -p xacc-ibm -a OPENSSL_ROOT_DIR=/usr/local/opt/openssl
Homebrew creates the above OpenSSL root directory. If yours is different, then
set the ``OPENSSL_ROOT_DIR`` as such.
You have now installed the IBM plugin. It is located in ``$XACC_ROOT/lib/plugins/accelerator``,
where ``XACC_ROOT`` is your XACC install prefix.
H2 VQE Example
--------------
Here we demonstrate how to use XACC to compute the expectation values for the
terms in the Hamiltonian modeling the
electronic structure of a simple Hydrogen molecule. The quantum
kernel code for this example can be found in `Scalable Quantum Simulation of Molecular Energies <https://arxiv.org/abs/1512.06860>`_.
.. note::
This example requires Scaffold. See `Install Scaffold <scaffold.html>`_ for
installation details.
.. code-block:: cpp
#include "XACC.hpp"
const std::string src(""
"__qpu__ initializeState(qbit qreg, float theta) {\n"
" Rx(qreg[0], 3.1415926);\n"
" Ry(qreg[1], 1.57079);\n"
" Rx(qreg[0], 7.8539752);\n"
" CNOT(qreg[1], qreg[0]);\n"
" Rz(qreg[0], theta);\n"
" CNOT(qreg[1], qreg[0]);\n"
" Ry(qreg[1], 7.8539752);\n"
" Rx(qreg[0], 1.57079);\n"
"}\n"
""
"__qpu__ g1Term (qbit qreg, float theta) {\n"
" initializeState(qreg, theta);\n"
" cbit creg[1];\n"
" creg[0] = MeasZ(qreg[0]);\n"
"}\n"
""
"__qpu__ g2Term (qbit qreg, float theta) {\n"
" initializeState(qreg, theta);\n"
" cbit creg[1];\n"
" creg[0] = MeasZ(qreg[1]);\n"
"}\n"
"__qpu__ g3Term (qbit qreg, float theta) {\n"
" initializeState(qreg, theta);\n"
" cbit creg[2];\n"
" creg[1] = MeasZ(qreg[1]);\n"
" creg[0] = MeasZ(qreg[0]);\n"
"}\n"
"__qpu__ g4Term(qbit qreg, float theta) {\n"
" initializeState(qreg, theta);\n"
" cbit creg[2];\n"
" Rx(qreg[1], 1.57079);\n"
" Rx(qreg[0], 1.57079);\n"
" creg[1] = MeasZ(qreg[1]);\n"
" creg[0] = MeasZ(qreg[0]);\n"
"}\n"
""
"__qpu__ g5Term(qbit qreg, float theta) {\n"
" initializeState(qreg, theta);\n"
" cbit creg[2];\n"
" H(qreg[1]);\n"
" creg[1] = MeasZ(qreg[1]);\n"
" H(qreg[0]);\n"
" creg[0] = MeasZ(qreg[0]);\n"
"}\n"
"");
int main (int argc, char** argv) {
// Initialize the XACC Framework
xacc::Initialize(argc, argv);
// Create a reference to the Rigetti
// QPU at api.rigetti.com/qvm
auto qpu = xacc::getAccelerator("ibm");
// Allocate a register of 3 qubits
auto qubitReg = qpu->createBuffer("qreg", 2);
// Create a Program
xacc::Program program(qpu, src);
// Request the quantum kernel representing
// the above source code
auto kernels = program.getKernels<float>();
std::ofstream file("out.csv");
file << "Angle, Z0, Z1, Z0Z1, Y0Y1, X0X1\n";
auto pi = 3.14159265359;
for (float theta = -pi; theta <= pi; theta += .2) {
file << theta;
// Skip the first kernel, it is the state prep
// kernel that all others will call anyway
for (int i = 1; i < kernels.size(); i++) {
file << ", ";
std::cout << "Executing Kernel " << i << "\n";
kernels[i](qubitReg, theta);
std::cout << "Done Executing Kernel " << i << "\n";
auto e = qubitReg->getExpectationValueZ();
qubitReg->resetBuffer();
file << e;
}
file << "\n";
file.flush();
}
file.close();
// Finalize the XACC Framework
xacc::Finalize();
return 0;
}
......@@ -51,7 +51,7 @@ configure and build XACC:
$ cmake ..
$ make install # can pass -jN for N = number of threads to use
This will install XACC to ``/usr/local/xacc``
This will build, test, and install XACC to ``/usr/local/xacc``
(Pass ``-DCMAKE_INSTALL_PREFIX=$YOURINSTALLPATH`` to install it somewhere else).
Set your PATH variable to include the XACC bin directory:
......@@ -138,14 +138,6 @@ install one with Spack, for example
$ spack load gcc
$ spack compiler find
Now install the dependencies with your specified C++14 compiler (mine
will be gcc 7.2.0)
.. code::
$ (with MPI support) spack install boost+mpi+graph ^mpich %gcc@7.2.0
$ (without MPI support) spack install boost+graph %gcc@7.2.0
XACC has not yet been accepted into the Spack (we will soon issue a PR
to get it shipped as part of Spack). So in order to install it with Spack
we have to download our custom package recipe from the XACC repository:
......@@ -155,15 +147,18 @@ we have to download our custom package recipe from the XACC repository:
$ cd $SPACK_ROOT/var/spack/repos/builtin/packages/ && mkdir xacc
$ cd xacc && wget https://github.com/ORNL-QCI/xacc/raw/master/cmake/spack/xacc/package.py .
Now we can run
Now we can run
.. code::
$ spack install xacc %gcc@7.2.0
$ (without MPI support) spack install xacc
$ (with MPI support) spack install xacc +mpi
$ (with specified compiler) spack install xacc %gcc@7.2.0
Once all these are installed, load them as environment modules
so they are available for the XACC build:
Update your PATH to point to the XACC ``bin`` directory:
.. code::
$ spack load boost
$ export PATH=$(spack location -i xacc)/bin:$PATH
We recommend you add this command to you ``.bashrc`` file (or equivalent).
......@@ -32,6 +32,12 @@ In order to use this installation, you must update your ``PYTHONPATH`` environme
$ export PYTHONPATH=$XACC_ROOT/lib/python:$PYTHONPATH
or if you installed XACC with Spack
.. code::
$ export PYTHONPATH=$(spack location -i xacc)/lib/python:$PYTHONPATH
We recommend placing this command in your home directory's ``.bashrc`` file (or equivalent).
Example Usage
......
......@@ -8,15 +8,16 @@ Installation
If you want support for the Rigetti Accelerator, you must install
`CppRestSDK <https://github.com/microsoft/cpprestsdk>`_ and OpenSSL. This
is required for these Accelerators to make remote HTTP Rest calls to their
respective server APIs. Here's how to install these as binaries on various popular platforms:
is required to make remote HTTP Rest calls to Forest
server APIs. Here's how to install these as binaries on various popular platforms:
.. code::
$ (macosx) brew install cpprestsdk
$ (fedora) dnf install cpprest-devel openssl-devel
$ (ubuntu) apt-get install libcpprest-dev libssl-dev
$ (slack) slack install cpprestsdk
$ (slack) slack instal openssl
The `Rigetti Plugin <https://github.com/ornl-qci/xacc-rigetti>`_ provides
support to XACC for compiling kernels writting in Quil, and executing programs
......@@ -28,6 +29,19 @@ To install this plugin, run the following
$ xacc-install-plugins.py -p xacc-rigetti
.. note::
It has been observed on Mac OS X that the above command may fail
due to CMake incorrectly finding OpenSSL. If that happens, run the
following:
.. code::
$ xacc-install-plugins.py -p xacc-rigetti -a OPENSSL_ROOT_DIR=/usr/local/opt/openssl
Homebrew creates the above OpenSSL root directory. If yours is different, then
set the ``OPENSSL_ROOT_DIR`` as such.
You have now installed the Rigetti plugin. It is located in ``$XACC_ROOT/lib/plugins/accelerator``
and ``$XACC_ROOT/lib/plugins/compilers``, where ``XACC_ROOT`` is your XACC install prefix.
......
......@@ -175,11 +175,13 @@
<p class="first admonition-title">Note</p>
<p>If you want support for the D-Wave Accelerator, you must install
<a class="reference external" href="https://github.com/microsoft/cpprestsdk">CppRestSDK</a> and OpenSSL. This
is required for these Accelerators to make remote HTTP Rest calls to their
respective server APIs. Here’s how to install these as binaries on various popular platforms:</p>
is required for making remote HTTP Rest calls to the D-Wave server APIs.
Here’s how to install these as binaries on various popular platforms:</p>
<div class="code last highlight-default"><div class="highlight"><pre><span></span>$ (macosx) brew install cpprestsdk
$ (fedora) dnf install cpprest-devel openssl-devel
$ (ubuntu) apt-get install libcpprest-dev libssl-dev
$ (slack) slack install cpprestsdk
$ (slack) slack install openssl
</pre></div>
</div>
</div>
......@@ -189,6 +191,17 @@ support to XACC for executing programs on the D-Wave QPU via the D-Wave Accelera
<div class="code highlight-default"><div class="highlight"><pre><span></span>$ xacc-install-plugins.py -p xacc-dwave
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>It has been observed on Mac OS X that the above command may fail
due to CMake incorrectly finding OpenSSL. If that happens, run the
following:</p>
<div class="code highlight-default"><div class="highlight"><pre><span></span>$ xacc-install-plugins.py -p xacc-dwave -a OPENSSL_ROOT_DIR=/usr/local/opt/openssl
</pre></div>
</div>
<p class="last">Homebrew creates the above OpenSSL root directory. If yours is different, then
set the <code class="docutils literal"><span class="pre">OPENSSL_ROOT_DIR</span></code> as such.</p>
</div>
<p>You have now installed the D-Wave plugin. It is located in <code class="docutils literal"><span class="pre">$XACC_ROOT/lib/plugins/accelerator</span></code> and <code class="docutils literal"><span class="pre">$XACC_ROOT/lib/plugins/compilers</span></code>, where XACC_ROOT is your XACC install prefix.</p>
</div>
<div class="section" id="extensibility-for-minor-graph-embedding-algorithms">
......
......@@ -101,6 +101,7 @@
<li class="toctree-l1"><a class="reference internal" href="rigetti.html">Rigetti Integration</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">IBM Integration</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#installation">Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="#h2-vqe-example">H2 VQE Example</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="dwave.html">D-Wave Integration</a></li>
......@@ -173,13 +174,15 @@
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If you want support for the D-Wave Accelerator, you must install
<p>If you want support for the IBM Accelerator, you must install
<a class="reference external" href="https://github.com/microsoft/cpprestsdk">CppRestSDK</a> and OpenSSL. This
is required for these Accelerators to make remote HTTP Rest calls to their
respective server APIs. Here’s how to install these as binaries on various popular platforms:</p>
is required to make remote HTTP Rest calls to the IBM Quantum Experience
server APIs. Here’s how to install these as binaries on various popular platforms:</p>
<div class="code last highlight-default"><div class="highlight"><pre><span></span>$ (macosx) brew install cpprestsdk
$ (fedora) dnf install cpprest-devel openssl-devel
$ (ubuntu) apt-get install libcpprest-dev libssl-dev
$ (slack) slack install cpprestsdk
$ (slack) slack install openssl
</pre></div>
</div>
</div>
......@@ -190,9 +193,132 @@ on the IBM Quantum Experience via the IBM Accelerator.</p>
<div class="code highlight-default"><div class="highlight"><pre><span></span>$ xacc-install-plugins.py -p xacc-ibm
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>It has been observed on Mac OS X that the above command may fail
due to CMake incorrectly finding OpenSSL. If that happens, run the
following:</p>
<div class="code highlight-default"><div class="highlight"><pre><span></span>$ xacc-install-plugins.py -p xacc-ibm -a OPENSSL_ROOT_DIR=/usr/local/opt/openssl
</pre></div>
</div>
<p class="last">Homebrew creates the above OpenSSL root directory. If yours is different, then
set the <code class="docutils literal"><span class="pre">OPENSSL_ROOT_DIR</span></code> as such.</p>
</div>
<p>You have now installed the IBM plugin. It is located in <code class="docutils literal"><span class="pre">$XACC_ROOT/lib/plugins/accelerator</span></code>,
where <code class="docutils literal"><span class="pre">XACC_ROOT</span></code> is your XACC install prefix.</p>
</div>
<div class="section" id="h2-vqe-example">
<h2>H2 VQE Example<a class="headerlink" href="#h2-vqe-example" title="Permalink to this headline"></a></h2>
<p>Here we demonstrate how to use XACC to compute the expectation values for the
terms in the Hamiltonian modeling the
electronic structure of a simple Hydrogen molecule. The quantum
kernel code for this example can be found in <a class="reference external" href="https://arxiv.org/abs/1512.06860">Scalable Quantum Simulation of Molecular Energies</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This example requires Scaffold. See <a class="reference external" href="scaffold.html">Install Scaffold</a> for
installation details.</p>
</div>
<div class="highlight-cpp"><div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&quot;XACC.hpp&quot;</span><span class="cp"></span>
<span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">src</span><span class="p">(</span><span class="s">&quot;&quot;</span>
<span class="s">&quot;__qpu__ initializeState(qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rx(qreg[0], 3.1415926);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Ry(qreg[1], 1.57079);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rx(qreg[0], 7.8539752);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; CNOT(qreg[1], qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rz(qreg[0], theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; CNOT(qreg[1], qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Ry(qreg[1], 7.8539752);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rx(qreg[0], 1.57079);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;&quot;</span>
<span class="s">&quot;__qpu__ g1Term (qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; initializeState(qreg, theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; cbit creg[1];</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[0] = MeasZ(qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;&quot;</span>
<span class="s">&quot;__qpu__ g2Term (qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; initializeState(qreg, theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; cbit creg[1];</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[0] = MeasZ(qreg[1]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;__qpu__ g3Term (qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; initializeState(qreg, theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; cbit creg[2];</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[1] = MeasZ(qreg[1]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[0] = MeasZ(qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;__qpu__ g4Term(qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; initializeState(qreg, theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; cbit creg[2];</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rx(qreg[1], 1.57079);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; Rx(qreg[0], 1.57079);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[1] = MeasZ(qreg[1]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[0] = MeasZ(qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;&quot;</span>
<span class="s">&quot;__qpu__ g5Term(qbit qreg, float theta) {</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; initializeState(qreg, theta);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; cbit creg[2];</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; H(qreg[1]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[1] = MeasZ(qreg[1]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; H(qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot; creg[0] = MeasZ(qreg[0]);</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;}</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="s">&quot;&quot;</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">main</span> <span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">**</span> <span class="n">argv</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Initialize the XACC Framework</span>
<span class="n">xacc</span><span class="o">::</span><span class="n">Initialize</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">);</span>
<span class="c1">// Create a reference to the Rigetti</span>
<span class="c1">// QPU at api.rigetti.com/qvm</span>
<span class="k">auto</span> <span class="n">qpu</span> <span class="o">=</span> <span class="n">xacc</span><span class="o">::</span><span class="n">getAccelerator</span><span class="p">(</span><span class="s">&quot;ibm&quot;</span><span class="p">);</span>
<span class="c1">// Allocate a register of 3 qubits</span>
<span class="k">auto</span> <span class="n">qubitReg</span> <span class="o">=</span> <span class="n">qpu</span><span class="o">-&gt;</span><span class="n">createBuffer</span><span class="p">(</span><span class="s">&quot;qreg&quot;</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
<span class="c1">// Create a Program</span>
<span class="n">xacc</span><span class="o">::</span><span class="n">Program</span> <span class="n">program</span><span class="p">(</span><span class="n">qpu</span><span class="p">,</span> <span class="n">src</span><span class="p">);</span>
<span class="c1">// Request the quantum kernel representing</span>
<span class="c1">// the above source code</span>
<span class="k">auto</span> <span class="n">kernels</span> <span class="o">=</span> <span class="n">program</span><span class="p">.</span><span class="n">getKernels</span><span class="o">&lt;</span><span class="kt">float</span><span class="o">&gt;</span><span class="p">();</span>
<span class="n">std</span><span class="o">::</span><span class="n">ofstream</span> <span class="n">file</span><span class="p">(</span><span class="s">&quot;out.csv&quot;</span><span class="p">);</span>
<span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Angle, Z0, Z1, Z0Z1, Y0Y1, X0X1</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span>
<span class="k">auto</span> <span class="n">pi</span> <span class="o">=</span> <span class="mf">3.14159265359</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">float</span> <span class="n">theta</span> <span class="o">=</span> <span class="o">-</span><span class="n">pi</span><span class="p">;</span> <span class="n">theta</span> <span class="o">&lt;=</span> <span class="n">pi</span><span class="p">;</span> <span class="n">theta</span> <span class="o">+=</span> <span class="mf">.2</span><span class="p">)</span> <span class="p">{</span>
<span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="n">theta</span><span class="p">;</span>
<span class="c1">// Skip the first kernel, it is the state prep</span>
<span class="c1">// kernel that all others will call anyway</span>
<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">kernels</span><span class="p">.</span><span class="n">size</span><span class="p">();</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;, &quot;</span><span class="p">;</span>
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Executing Kernel &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">i</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span>
<span class="n">kernels</span><span class="p">[</span><span class="n">i</span><span class="p">](</span><span class="n">qubitReg</span><span class="p">,</span> <span class="n">theta</span><span class="p">);</span>
<span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Done Executing Kernel &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">i</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span>
<span class="k">auto</span> <span class="n">e</span> <span class="o">=</span> <span class="n">qubitReg</span><span class="o">-&gt;</span><span class="n">getExpectationValueZ</span><span class="p">();</span>
<span class="n">qubitReg</span><span class="o">-&gt;</span><span class="n">resetBuffer</span><span class="p">();</span>
<span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="n">e</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">file</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span>
<span class="n">file</span><span class="p">.</span><span class="n">flush</span><span class="p">();</span>
<span class="p">}</span>
<span class="n">file</span><span class="p">.</span><span class="n">close</span><span class="p">();</span>
<span class="c1">// Finalize the XACC Framework</span>
<span class="n">xacc</span><span class="o">::</span><span class="n">Finalize</span><span class="p">();</span>
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
......
......@@ -217,6 +217,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="ibm.html">IBM Integration</a><ul>
<li class="toctree-l2"><a class="reference internal" href="ibm.html#installation">Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="ibm.html#h2-vqe-example">H2 VQE Example</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="dwave.html">D-Wave Integration</a><ul>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment