Commit a8b8bf5d authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

restructure on commongates to remove xacc.hpp inclusion, fix gate clone to clone buffernames


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent de6c5ce7
Pipeline #107455 passed with stage
in 22 minutes and 55 seconds
......@@ -20,6 +20,7 @@ using namespace rapidjson;
#include "JsonVisitor.hpp"
#include "IRProvider.hpp"
#include "IRToGraphVisitor.hpp"
#include "xacc_service.hpp"
namespace xacc {
namespace quantum {
......
......@@ -18,7 +18,6 @@
#include "InstructionIterator.hpp"
#include "Utils.hpp"
#include "expression_parsing_util.hpp"
#include "xacc_service.hpp"
#include <limits>
#include <memory>
#include <stdexcept>
......
#include "CommonGates.hpp"
#include "xacc.hpp"
namespace xacc {
namespace quantum {
bool IfStmt::expand(const HeterogeneousMap &runtimeOptions) {
auto buffer = xacc::getBuffer(bufferName);
if ((*buffer)[bitIdx]) {
for (auto &i : instructions) {
i->enable();
}
} else {
// Note: although sub-instructions are initially disabled,
// we need to disable here as well just in case we run multiple shots
// and they may be enabled in the previous run.
disable();
}
return true;
}
} // namespace quantum
} // namespace xacc
\ No newline at end of file
......@@ -15,7 +15,6 @@
#include "Gate.hpp"
#include "Circuit.hpp"
#include "xacc.hpp"
namespace xacc {
namespace quantum {
......@@ -86,21 +85,8 @@ public:
Circuit::addInstruction(instruction);
}
bool expand(const HeterogeneousMap &runtimeOptions) override {
auto buffer = xacc::getBuffer(bufferName);
if ((*buffer)[bitIdx]) {
for (auto &i : instructions) {
i->enable();
}
} else {
// Note: although sub-instructions are initially disabled,
// we need to disable here as well just in case we run multiple shots
// and they may be enabled in the previous run.
disable();
}
return true;
}
bool expand(const HeterogeneousMap &runtimeOptions) override;
void disable() override {
for (auto &i : instructions) {
i->disable();
......
......@@ -29,7 +29,7 @@ Gate::Gate(std::string name, std::vector<std::size_t> qubts,
: gateName(name), qbits(qubts), parameters(params) {}
Gate::Gate(const Gate &inst)
: gateName(inst.gateName), qbits(inst.qbits), parameters(inst.parameters),
arguments(inst.arguments), enabled(inst.enabled) {}
arguments(inst.arguments), enabled(inst.enabled), buffer_names(inst.buffer_names) {}
const std::string Gate::name() const { return gateName; }
const std::string Gate::description() const {
......
......@@ -17,6 +17,7 @@
#include "ObservableTransform.hpp"
#include "xacc_service.hpp"
#include <Utils.hpp>
namespace xacc {
namespace quantum {
......@@ -97,7 +98,7 @@ void FermionOperator::clear() { terms.clear(); }
std::vector<std::shared_ptr<CompositeInstruction>>
FermionOperator::observe(std::shared_ptr<CompositeInstruction> function) {
auto transform = xacc::getService<ObservableTransform>("jw");
return transform->transform(shared_from_this())->observe(function);
return transform->transform(xacc::as_shared_ptr(this))->observe(function);
}
const std::string FermionOperator::toString() {
......
......@@ -14,6 +14,8 @@
#include "Circuit.hpp"
#include "IRProvider.hpp"
#include "Observable.hpp"
#include "xacc_service.hpp"
namespace xacc {
namespace circuits {
......
......@@ -11,6 +11,7 @@
* Thien Nguyen - initial API and implementation
*******************************************************************************/
#include "ControlledGateApplicator.hpp"
#include "xacc_service.hpp"
namespace xacc {
namespace circuits {
......
......@@ -11,7 +11,7 @@
* Thien Nguyen - initial API and implementation
*******************************************************************************/
#pragma once
#include "xacc.hpp"
#include "AllGateVisitor.hpp"
using namespace xacc::quantum;
......
......@@ -208,6 +208,7 @@ VQE::execute(const std::shared_ptr<AcceleratorBuffer> buffer,
for (auto &f : kernels) {
kernelNames.push_back(f->name());
std::complex<double> coeff = f->getCoefficient();
// std::cout << f->name() << "\n" << f->toString() <<"\n";
int nFunctionInstructions = 0;
if (f->getInstruction(0)->isComposite()) {
......
......@@ -13,6 +13,8 @@
#include "xacc.hpp"
#include <gtest/gtest.h>
#include "Circuit.hpp"
#include "xacc_service.hpp"
using namespace xacc;
TEST(ExpTester, checkSimple) {
......
......@@ -13,6 +13,7 @@
#include "xacc.hpp"
#include <gtest/gtest.h>
#include "Circuit.hpp"
#include "xacc_service.hpp"
using namespace xacc;
......
......@@ -12,6 +12,7 @@
*******************************************************************************/
#include "InverseQFT.hpp"
#include <memory>
#include "xacc_service.hpp"
namespace xacc {
......
......@@ -13,6 +13,7 @@
#include "xacc.hpp"
#include <gtest/gtest.h>
#include "Circuit.hpp"
#include "xacc_service.hpp"
using namespace xacc;
......
......@@ -13,6 +13,7 @@
#include "xacc.hpp"
#include <gtest/gtest.h>
#include "Circuit.hpp"
#include "xacc_service.hpp"
using namespace xacc;
......
......@@ -13,10 +13,17 @@ qreg::qreg(const qreg &other) : buffer(other.buffer) {}
qubit qreg::operator[](const std::size_t i) {
return std::make_pair(buffer->name(), i);
}
qreg &qreg::operator=(const qreg &q) {
buffer = q.buffer;
return *this;
}
AcceleratorBuffer *qreg::results() { return buffer; }
std::map<std::string, int> qreg::counts() {
return buffer->getMeasurementCounts();
}
std::string qreg::name() { return buffer->name(); }
double qreg::exp_val_z() { return buffer->getExpectationValueZ(); }
void qreg::reset() { buffer->resetBuffer(); }
void qreg::setName(const char *name) { buffer->setName(name); }
......
......@@ -30,6 +30,7 @@ public:
qreg(const int n);
qreg (const qreg& other);
qubit operator[](const std::size_t i);
qreg& operator=(const qreg& q);
AcceleratorBuffer *results();
std::map<std::string, int> counts();
double exp_val_z();
......@@ -38,6 +39,7 @@ public:
void addChild(qreg& q);
void setName(const char *name);
void setNameAndStore(const char *name);
std::string name();
void store();
void print();
double weighted_sum(Observable* obs);
......
Markdown is supported
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