From db47c8a472ae0dee389d90009de21a4acec64c87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Aug 2023 04:40:47 +0000 Subject: [PATCH 1/4] Bump cpp/mqt-core from `b1c49b9` to `bc2d7d4` Bumps [cpp/mqt-core](https://github.com/cda-tum/mqt-core) from `b1c49b9` to `bc2d7d4`. - [Release notes](https://github.com/cda-tum/mqt-core/releases) - [Commits](https://github.com/cda-tum/mqt-core/compare/b1c49b9bfea04ee79bf7a36167e99413bda50d64...bc2d7d4d0cb9b99ecb2a32fd1ae85d9d399668d4) --- updated-dependencies: - dependency-name: cpp/mqt-core dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- cpp/mqt-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/mqt-core b/cpp/mqt-core index b1c49b9..bc2d7d4 160000 --- a/cpp/mqt-core +++ b/cpp/mqt-core @@ -1 +1 @@ -Subproject commit b1c49b9bfea04ee79bf7a36167e99413bda50d64 +Subproject commit bc2d7d4d0cb9b99ecb2a32fd1ae85d9d399668d4 From 9a75d1636a6065526731924764eb15dd872d0acf Mon Sep 17 00:00:00 2001 From: burgholzer Date: Fri, 11 Aug 2023 11:09:34 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A9=B9=20fix=20compiler=20warnings=20?= =?UTF-8?q?for=20verification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/module/QDDVer.cpp | 46 ++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/cpp/module/QDDVer.cpp b/cpp/module/QDDVer.cpp index b7f1644..a1829da 100644 --- a/cpp/module/QDDVer.cpp +++ b/cpp/module/QDDVer.cpp @@ -241,7 +241,7 @@ Napi::Value QDDVer::Load(const Napi::CallbackInfo& info) { std::stringstream ss{algo}; // the third parameter (how many operations to apply immediately) - unsigned int opNum = static_cast(info[2].As()); + auto opNum = static_cast(info[2].As()); // at this point opNum might be bigger than the number of operations the // algorithm has! @@ -249,11 +249,11 @@ Napi::Value QDDVer::Load(const Napi::CallbackInfo& info) { const bool process = static_cast(info[3].As()); // the fifth parameter (algo1) - bool algo1 = static_cast(info[4].As()); + const auto algo1 = static_cast(info[4].As()); try { // second parameter describes the format of the algorithm - const unsigned int formatCode = + const auto formatCode = static_cast(info[1].As()); qc::Format format; if (formatCode == 1) @@ -353,9 +353,9 @@ Napi::Value QDDVer::Load(const Napi::CallbackInfo& info) { } if (algo1 && opNum > qc1->getNops()) - opNum = qc1->getNops(); + opNum = static_cast(qc1->getNops()); else if (!algo1 && opNum > qc2->getNops()) - opNum = qc2->getNops(); + opNum = static_cast(qc2->getNops()); if (opNum > 0) { if (algo1) @@ -413,8 +413,7 @@ Napi::Value QDDVer::ToStart(const Napi::CallbackInfo& info) { Napi::TypeError::New(env, "arg1: Boolean expected!") .ThrowAsJavaScriptException(); } - bool algo1 = (bool)info[0].As(); - + const auto algo1 = static_cast(info[0].As()); if (algo1) { if (!ready1) { // Napi::Error::New(env, "No algorithm loaded as @@ -490,8 +489,7 @@ Napi::Value QDDVer::Prev(const Napi::CallbackInfo& info) { .ThrowAsJavaScriptException(); return state; } - bool algo1 = (bool)info[0].As(); - + const auto algo1 = static_cast(info[0].As()); if (algo1) { if (!ready1) { Napi::Error::New(env, "No algorithm loaded as algo1!") @@ -561,8 +559,7 @@ Napi::Value QDDVer::Next(const Napi::CallbackInfo& info) { .ThrowAsJavaScriptException(); return state; } - bool algo1 = (bool)info[0].As(); - + const auto algo1 = static_cast(info[0].As()); if (algo1) { if (!ready1) { Napi::Error::New(env, "No algorithm loaded as algo1!") @@ -638,8 +635,7 @@ Napi::Value QDDVer::ToEnd(const Napi::CallbackInfo& info) { .ThrowAsJavaScriptException(); return state; } - bool algo1 = (bool)info[0].As(); - + const auto algo1 = static_cast(info[0].As()); if (algo1) { if (!ready1) { Napi::Error::New(env, "No algorithm loaded as algo1!") @@ -729,15 +725,16 @@ Napi::Value QDDVer::ToLine(const Napi::CallbackInfo& info) { .ThrowAsJavaScriptException(); } - unsigned int param = (unsigned int)info[0].As(); - bool algo1 = (bool)info[1].As(); - + auto param = static_cast(info[0].As()); + const auto algo1 = static_cast(info[0].As()); if (algo1) { if (param > qc1->getNops()) - param = qc1->getNops(); // we can't go further than to the end + // we can't go further than to the end + param = static_cast(qc1->getNops()); } else { if (param > qc2->getNops()) - param = qc2->getNops(); // we can't go further than to the end + // we can't go further than to the end + param = static_cast(qc2->getNops()); } const unsigned int targetPos = param; @@ -864,10 +861,10 @@ void QDDVer::UpdateExportOptions(const Napi::CallbackInfo& info) { return; } - this->showColors = (bool)info[0].As(); - this->showEdgeLabels = (bool)info[1].As(); - this->showClassic = (bool)info[2].As(); - this->usePolarCoordinates = (bool)info[3].As(); + this->showColors = static_cast(info[0].As()); + this->showEdgeLabels = static_cast(info[1].As()); + this->showClassic = static_cast(info[2].As()); + this->usePolarCoordinates = static_cast(info[3].As()); } Napi::Value QDDVer::GetExportOptions(const Napi::CallbackInfo& info) { @@ -898,8 +895,8 @@ Napi::Value QDDVer::IsReady(const Napi::CallbackInfo& info) { Napi::TypeError::New(env, "arg1: Boolean expected!") .ThrowAsJavaScriptException(); } - bool algo1 = (bool)info[0].As(); + const auto algo1 = static_cast(info[0].As()); if (algo1) return Napi::Boolean::New(env, this->ready1); else @@ -919,8 +916,7 @@ void QDDVer::Unready(const Napi::CallbackInfo& info) { .ThrowAsJavaScriptException(); return; } - bool algo1 = (bool)info[0].As(); - + const auto algo1 = static_cast(info[0].As()); if (algo1) this->ready1 = false; else From f949653163e4f24801739654f85a0bffb0faacf6 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Fri, 11 Aug 2023 11:29:09 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=A9=B9=20fix=20compatibility=20with?= =?UTF-8?q?=20MQT=20Core?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/module/QDDVis.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cpp/module/QDDVis.cpp b/cpp/module/QDDVis.cpp index 62c27e9..ba456a5 100644 --- a/cpp/module/QDDVis.cpp +++ b/cpp/module/QDDVis.cpp @@ -63,14 +63,13 @@ void QDDVis::stepForward() { qc::MatrixDD currDD{}; if ((*iterator)->isClassicControlledOperation()) { auto startIndex = static_cast((*iterator)->getParameter().at(0)); - auto length = - static_cast((*iterator)->getParameter().at(1)); + auto length = static_cast((*iterator)->getParameter().at(1)); auto expectedValue = static_cast((*iterator)->getParameter().at(2)); std::size_t value = 0; - for (dd::QubitCount i = 0; i < length; ++i) { - value |= (measurements[startIndex + i] << i); + for (std::size_t i = 0; i < length; ++i) { + value |= (static_cast(measurements[startIndex + i]) << i); } if (value == expectedValue) { @@ -121,14 +120,13 @@ void QDDVis::stepBack() { qc::MatrixDD currDD{}; if ((*iterator)->isClassicControlledOperation()) { auto startIndex = static_cast((*iterator)->getParameter().at(0)); - auto length = - static_cast((*iterator)->getParameter().at(1)); + auto length = static_cast((*iterator)->getParameter().at(1)); auto expectedValue = static_cast((*iterator)->getParameter().at(2)); std::size_t value = 0; - for (dd::QubitCount i = 0; i < length; ++i) { - value |= (measurements[startIndex + i] << i); + for (std::size_t i = 0; i < length; ++i) { + value |= (static_cast(measurements[startIndex + i]) << i); } if (value == expectedValue) { From 49cadab18280e8c1d5e407679ba861fd86df9a89 Mon Sep 17 00:00:00 2001 From: burgholzer Date: Fri, 11 Aug 2023 11:29:20 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A9=B9=20fix=20compiler=20warnings=20?= =?UTF-8?q?for=20simulation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/module/QDDVis.cpp | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/cpp/module/QDDVis.cpp b/cpp/module/QDDVis.cpp index ba456a5..a247762 100644 --- a/cpp/module/QDDVis.cpp +++ b/cpp/module/QDDVis.cpp @@ -235,7 +235,8 @@ Napi::Value QDDVis::Load(const Napi::CallbackInfo& info) { try { // second parameter describes the format of the algorithm - const unsigned int formatCode = (unsigned int)info[1].As(); + const auto formatCode = + static_cast(info[1].As()); if (formatCode == 1) qc->import(ss, qc::Format::OpenQASM); else if (formatCode == 2) @@ -270,17 +271,16 @@ Napi::Value QDDVis::Load(const Napi::CallbackInfo& info) { Napi::Number::New(env, static_cast(qc->getNops()))); // the third parameter (how many operations to apply immediately) - unsigned int opNum = - (unsigned int)info[2] - .As(); // at this point opNum may be bigger than the - // number of operations the algorithm has! + auto opNum = static_cast( + info[2].As()); // at this point opNum may be bigger than the + // number of operations the algorithm has! if (opNum > qc->getNops()) - opNum = qc->getNops(); + opNum = static_cast(qc->getNops()); if (opNum > 0) { - atInitial = false; - const bool process = - (bool)info[3].As(); // the fourth parameter tells us to - // process iterated operations or not + atInitial = false; + const bool process = static_cast( + info[3].As()); // the fourth parameter tells us to + // process iterated operations or not if (process) { if (sim.p != nullptr) { dd->decRef(sim); @@ -456,12 +456,12 @@ Napi::Value QDDVis::Next(const Napi::CallbackInfo& info) { state.Set("changed", Napi::Boolean::New(env, true)); if ((*iterator)->getType() == qc::Reset) { - auto qubits = (*iterator)->getTargets(); - auto totalResets = qubits.size(); - auto qubitToReset = qubits.front(); - auto qubitsReset = 0; - auto [pzero, pone] = - dd->determineMeasurementProbabilities(sim, qubitToReset, true); + auto qubits = (*iterator)->getTargets(); + auto totalResets = qubits.size(); + auto qubitToReset = qubits.front(); + auto qubitsReset = 0; + auto [pzero, pone] = dd->determineMeasurementProbabilities( + sim, static_cast(qubitToReset), true); Napi::Object reset = Napi::Object::New(env); reset.Set("qubit", Napi::Number::New(env, qubitToReset)); @@ -487,8 +487,8 @@ Napi::Value QDDVis::Next(const Napi::CallbackInfo& info) { auto qubitToMeasure = qubits.front(); auto cbitToStore = cbits.front(); auto qubitsMeasured = 0; - auto [pzero, pone] = - dd->determineMeasurementProbabilities(sim, qubitToMeasure, true); + auto [pzero, pone] = dd->determineMeasurementProbabilities( + sim, static_cast(qubitToMeasure), true); Napi::Object measurement = Napi::Object::New(env); measurement.Set("qubit", Napi::Number::New(env, qubitToMeasure)); @@ -617,9 +617,10 @@ Napi::Value QDDVis::ToLine(const Napi::CallbackInfo& info) { return state; } - unsigned int param = (unsigned int)info[0].As(); + auto param = static_cast(info[0].As()); if (param > qc->getNops()) - param = qc->getNops(); // we can't go further than to the end + // we can't go further than to the end + param = static_cast(qc->getNops()); const unsigned int targetPos = param; try { @@ -792,10 +793,10 @@ void QDDVis::UpdateExportOptions(const Napi::CallbackInfo& info) { return; } - this->showColors = (bool)info[0].As(); - this->showEdgeLabels = (bool)info[1].As(); - this->showClassic = (bool)info[2].As(); - this->usePolarCoordinates = (bool)info[3].As(); + this->showColors = static_cast(info[0].As()); + this->showEdgeLabels = static_cast(info[1].As()); + this->showClassic = static_cast(info[2].As()); + this->usePolarCoordinates = static_cast(info[3].As()); } Napi::Value QDDVis::GetExportOptions(const Napi::CallbackInfo& info) { @@ -929,7 +930,8 @@ QDDVis::ConductIrreversibleOperation(const Napi::CallbackInfo& info) { } } else { // get target classical bit - auto cbit = obj.Get("cbit").As().Int64Value(); + auto cbit = static_cast( + obj.Get("cbit").As().Int64Value()); if (classicalValueToMeasure != "none") { bool measureOne = (classicalValueToMeasure == "1"); measureQubit(qubit, measureOne, pzero, pone);