Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MQT Core Dependency #264

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ShorFastSimulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ShorFastSimulator: public Simulator<Config> {

[[nodiscard]] std::pair<std::uint32_t, std::uint32_t> postProcessing(const std::string& sample) const;

void applyGate(dd::GateMatrix matrix, qc::Qubit target);
void applyGate(dd::GateMatrix matrix, dd::Qubit target);

std::vector<std::map<dd::vNode*, dd::vEdge>> nodesOnLevel;

Expand Down
4 changes: 2 additions & 2 deletions include/ShorSimulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class ShorSimulator: public Simulator<Config> {

void uAEmulate(std::uint64_t a, std::int32_t q);

void applyGate(dd::GateMatrix matrix, dd::Qubit target, const dd::Controls& controls);
void applyGate(dd::GateMatrix matrix, dd::Qubit target, const qc::Controls& controls);

void applyGate(dd::GateMatrix matrix, dd::Qubit target, dd::Control control);
void applyGate(dd::GateMatrix matrix, dd::Qubit target, qc::Control control);

void applyGate(dd::GateMatrix matrix, dd::Qubit target);

Expand Down
10 changes: 5 additions & 5 deletions src/ShorFastSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ std::map<std::string, std::size_t> ShorFastSimulator<Config>::simulate([[maybe_u
std::string measurements(2 * requiredBits, '0');

for (std::size_t i = 0; i < 2 * requiredBits; i++) {
applyGate(dd::Hmat, static_cast<qc::Qubit>(nQubits - 1));
applyGate(dd::Hmat, static_cast<dd::Qubit>(nQubits - 1));

if (verbose) {
std::clog << "[ " << (i + 1) << "/" << 2 * requiredBits << " ] uAEmulate2(" << as[i] << ") "
Expand All @@ -73,18 +73,18 @@ std::map<std::string, std::size_t> ShorFastSimulator<Config>::simulate([[maybe_u
double qR = cosine(1, -q);
double qI = sine(1, -q);
const dd::GateMatrix qm{dd::complex_one, dd::complex_zero, dd::complex_zero, {qR, qI}};
applyGate(qm, static_cast<qc::Qubit>(nQubits - 1));
applyGate(qm, static_cast<dd::Qubit>(nQubits - 1));
}
q *= 2;
}

applyGate(dd::Hmat, static_cast<qc::Qubit>(nQubits - 1));
applyGate(dd::Hmat, static_cast<dd::Qubit>(nQubits - 1));

measurements[i] = Simulator<Config>::measureOneCollapsing(static_cast<qc::Qubit>(nQubits - 1), false);
Simulator<Config>::dd->garbageCollect();

if (measurements[i] == '1') {
applyGate(dd::Xmat, static_cast<qc::Qubit>(nQubits - 1));
applyGate(dd::Xmat, static_cast<dd::Qubit>(nQubits - 1));
}
}

Expand Down Expand Up @@ -310,7 +310,7 @@ dd::mEdge ShorFastSimulator<Config>::addConstMod(std::uint64_t a) {
}

template<class Config>
void ShorFastSimulator<Config>::applyGate(dd::GateMatrix matrix, qc::Qubit target) {
void ShorFastSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target) {
numberOfOperations++;
const dd::Edge gate = Simulator<Config>::dd->makeGateDD(matrix, static_cast<dd::QubitCount>(nQubits), static_cast<dd::Qubit>(target));
const dd::Edge tmp = Simulator<Config>::dd->multiply(gate, Simulator<Config>::rootEdge);
Expand Down
12 changes: 6 additions & 6 deletions src/ShorSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ std::map<std::string, std::size_t> ShorSimulator<Config>::simulate([[maybe_unuse
double qR = cosine(1, -q);
double qI = sine(1, -q);
const dd::GateMatrix qm{dd::complex_one, dd::complex_zero, dd::complex_zero, {qR, qI}};
applyGate(qm, static_cast<dd::Qubit>(nQubits - 1 - static_cast<std::size_t>(i)), dd::Control{static_cast<dd::Qubit>(nQubits - 1 - static_cast<std::size_t>(j))});
applyGate(qm, static_cast<dd::Qubit>(nQubits - 1 - static_cast<std::size_t>(i)), qc::Control{static_cast<qc::Qubit>(nQubits - 1 - static_cast<std::size_t>(j))});
q *= 2;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ dd::mEdge ShorSimulator<Config>::addConstMod(std::uint64_t a) {
f4.w = dd::ComplexNumbers::neg(f4.w);
const dd::Edge tmp = Simulator<Config>::dd->add(Simulator<Config>::dd->multiply(f, f4), Simulator<Config>::dd->multiply(Simulator<Config>::dd->multiply(Simulator<Config>::dd->transpose(f2), f), diff2));

return tmp.p->e[0];
return tmp.p->e[0]; // NOLINT(clang-analyzer-core.CallAndMessage) Function Pointer is not null
}

template<class Config>
Expand Down Expand Up @@ -430,16 +430,16 @@ void ShorSimulator<Config>::uAEmulate(std::uint64_t a, std::int32_t q) {

template<class Config>
void ShorSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target) {
applyGate(matrix, target, dd::Controls{});
applyGate(matrix, target, qc::Controls{});
}

template<class Config>
void ShorSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target, dd::Control control) {
applyGate(matrix, target, dd::Controls{control});
void ShorSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target, qc::Control control) {
applyGate(matrix, target, qc::Controls{control});
}

template<class Config>
void ShorSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target, const dd::Controls& controls) {
void ShorSimulator<Config>::applyGate(dd::GateMatrix matrix, dd::Qubit target, const qc::Controls& controls) {
const dd::Edge gate = Simulator<Config>::dd->makeGateDD(matrix, static_cast<dd::QubitCount>(nQubits), controls, target);
const dd::Edge tmp = Simulator<Config>::dd->multiply(gate, Simulator<Config>::rootEdge);
Simulator<Config>::dd->incRef(tmp);
Expand Down