Commit 7f615c18 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

minor cleanup, update to qalloc for qcor


Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 6ac3bd82
......@@ -81,7 +81,7 @@ public:
bitIdxExpressions.insert({bit_idx, expr});
}
std::string getBitExpression(const std::size_t bit_idx) override {
return bitIdxExpressions[bit_idx];
return bitIdxExpressions.count(bit_idx) ? bitIdxExpressions[bit_idx] : "";
}
const InstructionParameter getParameter(const std::size_t idx) const override;
......
......@@ -28,6 +28,10 @@ public:
std::shared_ptr<Accelerator> acc) = 0;
virtual std::shared_ptr<IR> compile(const std::string &src) = 0;
virtual const std::string get_statement_terminator() {
return ";";
}
// By default, we assume this compiler can not parse a given
// source string. Subtypes implement this to indicate if
// they can or not
......
......@@ -10,7 +10,9 @@ template <typename T> struct empty_delete {
qreg::qreg(const int n) { buffer = xacc::qalloc(n).get(); }
qreg::qreg(const qreg &other) : buffer(other.buffer) {}
int qreg::operator[](const int &i) { return i; }
qubit qreg::operator[](const std::size_t &i) {
return std::make_pair(buffer->name(), i);
}
AcceleratorBuffer *qreg::results() { return buffer; }
std::map<std::string, int> qreg::counts() {
return buffer->getMeasurementCounts();
......
......@@ -19,6 +19,7 @@ namespace xacc {
class AcceleratorBuffer;
class Observable;
namespace internal_compiler {
using qubit = std::pair<std::string, std::size_t>;
class qreg {
protected:
......@@ -28,7 +29,7 @@ public:
qreg() = default;
qreg(const int n);
qreg (const qreg& other);
int operator[](const int &i);
qubit operator[](const std::size_t &i);
AcceleratorBuffer *results();
std::map<std::string, int> counts();
double exp_val_z();
......
......@@ -247,7 +247,7 @@ const std::string
translate(std::shared_ptr<CompositeInstruction> CompositeInstruction,
const std::string toLanguage);
void appendCompiled(std::shared_ptr<CompositeInstruction> composite, bool _override = false);
void appendCompiled(std::shared_ptr<CompositeInstruction> composite, bool _override = true);
std::shared_ptr<CompositeInstruction> getCompiled(const std::string name);
bool hasCompiled(const std::string name);
......
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