Skip to content

Commit

Permalink
Tidying up
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Claudino <[email protected]>
  • Loading branch information
danclaudino committed Jun 20, 2024
1 parent 62d658e commit 57e3b12
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 98 deletions.
3 changes: 0 additions & 3 deletions python/py_observable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@
* Alexander J. McCaskey - initial API and implementation
*******************************************************************************/
#include "py_observable.hpp"
//#include "Observable.hpp"
#include "Observable.hpp"
#include "PauliOperator.hpp"
#include "FermionOperator.hpp"
//#include "Utils.hpp"
#include "xacc_service.hpp"
#include "py_heterogeneous_map.hpp"
#include "ObservableTransform.hpp"
//#include <memory>

using namespace xacc::quantum;

Expand Down
1 change: 0 additions & 1 deletion quantum/observable/fermion/FermionOperator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class FermionOperator
const HeterogeneousMap &extra_data) override;

std::shared_ptr<Observable> normalOrder() override;


std::vector<std::shared_ptr<CompositeInstruction>> getMeasurementBasisRotations() override;

Expand Down
94 changes: 0 additions & 94 deletions quantum/observable/pauli/PauliOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,100 +238,6 @@ PauliOperator::observe(std::shared_ptr<CompositeInstruction> function) {
return observed;
}

/*
std::vector<std::shared_ptr<CompositeInstruction>>
PauliOperator::observe(std::shared_ptr<CompositeInstruction> function) {
// Create a new GateQIR to hold the spin based terms
auto gateRegistry = xacc::getService<IRProvider>("quantum");
std::vector<std::shared_ptr<CompositeInstruction>> observed;
int counter = 0;
auto pi = xacc::constants::pi;
// If the incoming function has instructions that have
// their buffer_names set, then we need to set the
// new measurement instructions buffer names to be the same.
// Here we assume that all instructions have the same buffer name
std::string buf_name = "";
if (function->nInstructions() > 0 &&
!function->getInstruction(0)->getBufferNames().empty()) {
buf_name = function->getInstruction(0)->getBufferNames()[0];
}
// Populate GateQIR now...
for (auto &inst : terms) {
Term spinInst = inst.second;
auto gateFunction =
gateRegistry->createComposite(inst.first, function->getVariables());
gateFunction->setCoefficient(spinInst.coeff());
if (function->hasChildren()) {
gateFunction->addInstruction(function->clone());
}
for (auto arg : function->getArguments()) {
gateFunction->addArgument(arg, 0);
}
// Loop over all terms in the Spin Instruction
// and create instructions to run on the Gate QPU.
std::vector<std::shared_ptr<xacc::Instruction>> measurements;
auto termsMap = spinInst.ops();
std::vector<std::pair<int, std::string>> terms;
for (auto &kv : termsMap) {
if (kv.second != "I" && !kv.second.empty()) {
terms.push_back({kv.first, kv.second});
}
}
for (int i = terms.size() - 1; i >= 0; i--) {
auto qbit = terms[i].first;
int t = qbit;
std::size_t tt = t;
auto gateName = terms[i].second;
auto meas = gateRegistry->createInstruction("Measure",
std::vector<std::size_t>{tt});
if (!buf_name.empty())
meas->setBufferNames({buf_name});
xacc::InstructionParameter classicalIdx(qbit);
meas->setParameter(0, classicalIdx);
measurements.push_back(meas);
if (gateName == "X") {
auto hadamard =
gateRegistry->createInstruction("H", std::vector<std::size_t>{tt});
if (!buf_name.empty())
hadamard->setBufferNames({buf_name});
gateFunction->addInstruction(hadamard);
} else if (gateName == "Y") {
auto rx =
gateRegistry->createInstruction("Rx", std::vector<std::size_t>{tt});
if (!buf_name.empty())
rx->setBufferNames({buf_name});
InstructionParameter p(pi / 2.0);
rx->setParameter(0, p);
gateFunction->addInstruction(rx);
}
}
if (!spinInst.isIdentity()) {
for (auto m : measurements) {
gateFunction->addInstruction(m);
}
}
observed.push_back(gateFunction);
counter++;
}
return observed;
}
*/

std::vector<std::shared_ptr<CompositeInstruction>>
PauliOperator::observe(std::shared_ptr<CompositeInstruction> function,
const HeterogeneousMap &grouping_options) {
Expand Down

0 comments on commit 57e3b12

Please sign in to comment.