Skip to content

Commit

Permalink
Bump cpp/mqt-core from b1c49b9 to bc2d7d4 (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Aug 11, 2023
2 parents e7b07b2 + 49cadab commit e260f48
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 59 deletions.
46 changes: 21 additions & 25 deletions cpp/module/QDDVer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,19 @@ 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<unsigned int>(info[2].As<Napi::Number>());
auto opNum = static_cast<unsigned int>(info[2].As<Napi::Number>());
// at this point opNum might be bigger than the number of operations the
// algorithm has!

// the fourth parameter tells us to process iterated operations or not
const bool process = static_cast<bool>(info[3].As<Napi::Boolean>());

// the fifth parameter (algo1)
bool algo1 = static_cast<bool>(info[4].As<Napi::Boolean>());
const auto algo1 = static_cast<bool>(info[4].As<Napi::Boolean>());

try {
// second parameter describes the format of the algorithm
const unsigned int formatCode =
const auto formatCode =
static_cast<unsigned int>(info[1].As<Napi::Number>());
qc::Format format;
if (formatCode == 1)
Expand Down Expand Up @@ -353,9 +353,9 @@ Napi::Value QDDVer::Load(const Napi::CallbackInfo& info) {
}

if (algo1 && opNum > qc1->getNops())
opNum = qc1->getNops();
opNum = static_cast<unsigned int>(qc1->getNops());
else if (!algo1 && opNum > qc2->getNops())
opNum = qc2->getNops();
opNum = static_cast<unsigned int>(qc2->getNops());

if (opNum > 0) {
if (algo1)
Expand Down Expand Up @@ -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<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1) {
if (!ready1) {
// Napi::Error::New(env, "No algorithm loaded as
Expand Down Expand Up @@ -490,8 +489,7 @@ Napi::Value QDDVer::Prev(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException();
return state;
}
bool algo1 = (bool)info[0].As<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1) {
if (!ready1) {
Napi::Error::New(env, "No algorithm loaded as algo1!")
Expand Down Expand Up @@ -561,8 +559,7 @@ Napi::Value QDDVer::Next(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException();
return state;
}
bool algo1 = (bool)info[0].As<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1) {
if (!ready1) {
Napi::Error::New(env, "No algorithm loaded as algo1!")
Expand Down Expand Up @@ -638,8 +635,7 @@ Napi::Value QDDVer::ToEnd(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException();
return state;
}
bool algo1 = (bool)info[0].As<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1) {
if (!ready1) {
Napi::Error::New(env, "No algorithm loaded as algo1!")
Expand Down Expand Up @@ -729,15 +725,16 @@ Napi::Value QDDVer::ToLine(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException();
}

unsigned int param = (unsigned int)info[0].As<Napi::Number>();
bool algo1 = (bool)info[1].As<Napi::Boolean>();

auto param = static_cast<unsigned int>(info[0].As<Napi::Number>());
const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
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<unsigned int>(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<unsigned int>(qc2->getNops());
}
const unsigned int targetPos = param;

Expand Down Expand Up @@ -864,10 +861,10 @@ void QDDVer::UpdateExportOptions(const Napi::CallbackInfo& info) {
return;
}

this->showColors = (bool)info[0].As<Napi::Boolean>();
this->showEdgeLabels = (bool)info[1].As<Napi::Boolean>();
this->showClassic = (bool)info[2].As<Napi::Boolean>();
this->usePolarCoordinates = (bool)info[3].As<Napi::Boolean>();
this->showColors = static_cast<bool>(info[0].As<Napi::Boolean>());
this->showEdgeLabels = static_cast<bool>(info[1].As<Napi::Boolean>());
this->showClassic = static_cast<bool>(info[2].As<Napi::Boolean>());
this->usePolarCoordinates = static_cast<bool>(info[3].As<Napi::Boolean>());
}

Napi::Value QDDVer::GetExportOptions(const Napi::CallbackInfo& info) {
Expand Down Expand Up @@ -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<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1)
return Napi::Boolean::New(env, this->ready1);
else
Expand All @@ -919,8 +916,7 @@ void QDDVer::Unready(const Napi::CallbackInfo& info) {
.ThrowAsJavaScriptException();
return;
}
bool algo1 = (bool)info[0].As<Napi::Boolean>();

const auto algo1 = static_cast<bool>(info[0].As<Napi::Boolean>());
if (algo1)
this->ready1 = false;
else
Expand Down
66 changes: 33 additions & 33 deletions cpp/module/QDDVis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ void QDDVis::stepForward() {
qc::MatrixDD currDD{};
if ((*iterator)->isClassicControlledOperation()) {
auto startIndex = static_cast<dd::Qubit>((*iterator)->getParameter().at(0));
auto length =
static_cast<dd::QubitCount>((*iterator)->getParameter().at(1));
auto length = static_cast<std::size_t>((*iterator)->getParameter().at(1));
auto expectedValue =
static_cast<std::size_t>((*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<std::size_t>(measurements[startIndex + i]) << i);
}

if (value == expectedValue) {
Expand Down Expand Up @@ -121,14 +120,13 @@ void QDDVis::stepBack() {
qc::MatrixDD currDD{};
if ((*iterator)->isClassicControlledOperation()) {
auto startIndex = static_cast<dd::Qubit>((*iterator)->getParameter().at(0));
auto length =
static_cast<dd::QubitCount>((*iterator)->getParameter().at(1));
auto length = static_cast<std::size_t>((*iterator)->getParameter().at(1));
auto expectedValue =
static_cast<std::size_t>((*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<std::size_t>(measurements[startIndex + i]) << i);
}

if (value == expectedValue) {
Expand Down Expand Up @@ -237,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<Napi::Number>();
const auto formatCode =
static_cast<unsigned int>(info[1].As<Napi::Number>());
if (formatCode == 1)
qc->import(ss, qc::Format::OpenQASM);
else if (formatCode == 2)
Expand Down Expand Up @@ -272,17 +271,16 @@ Napi::Value QDDVis::Load(const Napi::CallbackInfo& info) {
Napi::Number::New(env, static_cast<double>(qc->getNops())));

// the third parameter (how many operations to apply immediately)
unsigned int opNum =
(unsigned int)info[2]
.As<Napi::Number>(); // at this point opNum may be bigger than the
// number of operations the algorithm has!
auto opNum = static_cast<unsigned int>(
info[2].As<Napi::Number>()); // 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<unsigned int>(qc->getNops());
if (opNum > 0) {
atInitial = false;
const bool process =
(bool)info[3].As<Napi::Boolean>(); // the fourth parameter tells us to
// process iterated operations or not
atInitial = false;
const bool process = static_cast<bool>(
info[3].As<Napi::Boolean>()); // the fourth parameter tells us to
// process iterated operations or not
if (process) {
if (sim.p != nullptr) {
dd->decRef(sim);
Expand Down Expand Up @@ -458,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<dd::Qubit>(qubitToReset), true);

Napi::Object reset = Napi::Object::New(env);
reset.Set("qubit", Napi::Number::New(env, qubitToReset));
Expand All @@ -489,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<dd::Qubit>(qubitToMeasure), true);

Napi::Object measurement = Napi::Object::New(env);
measurement.Set("qubit", Napi::Number::New(env, qubitToMeasure));
Expand Down Expand Up @@ -619,9 +617,10 @@ Napi::Value QDDVis::ToLine(const Napi::CallbackInfo& info) {
return state;
}

unsigned int param = (unsigned int)info[0].As<Napi::Number>();
auto param = static_cast<unsigned int>(info[0].As<Napi::Number>());
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<unsigned int>(qc->getNops());
const unsigned int targetPos = param;

try {
Expand Down Expand Up @@ -794,10 +793,10 @@ void QDDVis::UpdateExportOptions(const Napi::CallbackInfo& info) {
return;
}

this->showColors = (bool)info[0].As<Napi::Boolean>();
this->showEdgeLabels = (bool)info[1].As<Napi::Boolean>();
this->showClassic = (bool)info[2].As<Napi::Boolean>();
this->usePolarCoordinates = (bool)info[3].As<Napi::Boolean>();
this->showColors = static_cast<bool>(info[0].As<Napi::Boolean>());
this->showEdgeLabels = static_cast<bool>(info[1].As<Napi::Boolean>());
this->showClassic = static_cast<bool>(info[2].As<Napi::Boolean>());
this->usePolarCoordinates = static_cast<bool>(info[3].As<Napi::Boolean>());
}

Napi::Value QDDVis::GetExportOptions(const Napi::CallbackInfo& info) {
Expand Down Expand Up @@ -931,7 +930,8 @@ QDDVis::ConductIrreversibleOperation(const Napi::CallbackInfo& info) {
}
} else {
// get target classical bit
auto cbit = obj.Get("cbit").As<Napi::Number>().Int64Value();
auto cbit = static_cast<std::size_t>(
obj.Get("cbit").As<Napi::Number>().Int64Value());
if (classicalValueToMeasure != "none") {
bool measureOne = (classicalValueToMeasure == "1");
measureQubit(qubit, measureOne, pzero, pone);
Expand Down
2 changes: 1 addition & 1 deletion cpp/mqt-core
Submodule mqt-core updated 53 files
+1 −0 .clang-tidy
+1 −1 .github/workflows/emulated-wheels.yml
+1 −1 .github/workflows/wheels.yml
+3 −3 .pre-commit-config.yaml
+1 −1 extern/googletest
+1 −1 extern/pybind11
+3 −2 include/CircuitOptimizer.hpp
+2 −3 include/QuantumComputation.hpp
+10 −0 include/algorithms/WState.hpp
+15 −14 include/dd/ComputeTable.hpp
+15 −11 include/dd/DDDefinitions.hpp
+13 −1 include/dd/Export.hpp
+1 −2 include/dd/FunctionalityConstruction.hpp
+44 −36 include/dd/Node.hpp
+125 −133 include/dd/NoiseFunctionality.hpp
+69 −74 include/dd/Operations.hpp
+375 −400 include/dd/Package.hpp
+5 −4 include/dd/StochasticNoiseOperationTable.hpp
+10 −10 include/dd/UnaryComputeTable.hpp
+19 −22 include/dd/UniqueTable.hpp
+6 −31 include/operations/NonUnitaryOperation.hpp
+1 −9 include/operations/OpType.hpp
+4 −0 include/operations/Operation.hpp
+2 −0 src/CMakeLists.txt
+22 −35 src/CircuitOptimizer.cpp
+8 −8 src/QuantumComputation.cpp
+25 −0 src/algorithms/WState.cpp
+4 −3 src/dd/Edge.cpp
+26 −25 src/dd/FunctionalityConstruction.cpp
+6 −0 src/dd/MemoryManager.cpp
+5 −26 src/dd/Node.cpp
+2 −3 src/dd/Operations.cpp
+36 −39 src/dd/Simulation.cpp
+20 −14 src/dd/UniqueTableStatistics.cpp
+26 −116 src/operations/NonUnitaryOperation.cpp
+8 −0 src/operations/Operation.cpp
+15 −7 src/operations/StandardOperation.cpp
+3 −21 src/parsers/QASMParser.cpp
+2 −1 test/CMakeLists.txt
+49 −65 test/algorithms/eval_dynamic_circuits.cpp
+145 −158 test/algorithms/test_bernsteinvazirani.cpp
+8 −13 test/algorithms/test_entanglement.cpp
+5 −5 test/algorithms/test_grcs.cpp
+4 −8 test/algorithms/test_grover.cpp
+23 −30 test/algorithms/test_qft.cpp
+52 −75 test/algorithms/test_qpe.cpp
+4 −5 test/algorithms/test_random_clifford.cpp
+42 −0 test/algorithms/test_wstate.cpp
+3 −4 test/dd/test_dd_functionality.cpp
+7 −13 test/dd/test_dd_noise_functionality.cpp
+115 −71 test/dd/test_package.cpp
+6 −8 test/unittests/test_ecc_functionality.cpp
+0 −2 test/unittests/test_qfr_functionality.cpp

0 comments on commit e260f48

Please sign in to comment.