Skip to content
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ repos:

# Static type checking using mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.17.1
rev: v1.18.2
hooks:
- id: mypy
files: ^(python/mqt|test/python)
Expand Down Expand Up @@ -116,7 +116,7 @@ repos:

# Check for spelling
- repo: https://github.com/crate-ci/typos
rev: v1.36.3
rev: v1.38.0
hooks:
- id: typos

Expand All @@ -131,7 +131,7 @@ repos:

# Check best practices for scientific Python code
- repo: https://github.com/scientific-python/cookie
rev: 2024.08.19
rev: 2025.10.01
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
Expand All @@ -146,7 +146,7 @@ repos:

# Check the pyproject.toml file
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2025.09.12
rev: 2025.10.03
hooks:
- id: validate-pyproject

Expand Down
102 changes: 51 additions & 51 deletions include/dd/MDDPackage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class MDDPackage {
RefCount refCount{}; // reference count, how many active dd are using
// the node
QuantumRegister
varIndx{}; // variable index (nonterminal) value (-1 for terminal),
// index in the circuit endianness 0 from below
varIndex{}; // variable index (nonterminal) value (-1 for terminal),
// index in the circuit endianness 0 from below

static vNode
terminalNode; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
Expand Down Expand Up @@ -338,22 +338,22 @@ class MDDPackage {
auto& uniqueTable = getUniqueTable<Node>();

Edge<Node> newEdge{uniqueTable.getNode(), Complex::one};
newEdge.nextNode->varIndx = varidx;
newEdge.nextNode->varIndex = varidx;
newEdge.nextNode->edges = edges;

assert(newEdge.nextNode->refCount == 0);

for ([[maybe_unused]] const auto& edge : edges) {
assert(edge.nextNode->varIndx == varidx - 1 || edge.isTerminal());
assert(edge.nextNode->varIndex == varidx - 1 || edge.isTerminal());
}

// normalize it
newEdge = normalize(newEdge, cached);
assert(newEdge.nextNode->varIndx == varidx || newEdge.isTerminal());
assert(newEdge.nextNode->varIndex == varidx || newEdge.isTerminal());

// look it up in the unique tables
auto lookedUpEdge = uniqueTable.lookup(newEdge, false);
assert(lookedUpEdge.nextNode->varIndx == varidx ||
assert(lookedUpEdge.nextNode->varIndex == varidx ||
lookedUpEdge.isTerminal());

// set specific node properties for matrices
Expand All @@ -372,7 +372,7 @@ class MDDPackage {
std::vector<Edge<mNode>> edges{}; // edges out of this node
mNode* next{}; // used to link nodes in unique table
RefCount refCount{}; // reference count
QuantumRegister varIndx{}; // variable index (nonterminal) value (-1
QuantumRegister varIndex{}; // variable index (nonterminal) value (-1
// for terminal)
bool symmetric = false; // node is symmetric
bool identity = false; // node resembles identity
Expand Down Expand Up @@ -781,11 +781,11 @@ class MDDPackage {
QuantumRegister newSuccessor = 0;

if (x.isTerminal()) {
newSuccessor = y.nextNode->varIndx;
newSuccessor = y.nextNode->varIndex;
} else {
newSuccessor = x.nextNode->varIndx;
if (!y.isTerminal() && y.nextNode->varIndx > newSuccessor) {
newSuccessor = y.nextNode->varIndx;
newSuccessor = x.nextNode->varIndex;
if (!y.isTerminal() && y.nextNode->varIndex > newSuccessor) {
newSuccessor = y.nextNode->varIndex;
}
}

Expand All @@ -797,7 +797,7 @@ class MDDPackage {
for (auto i = 0U; i < x.nextNode->edges.size(); i++) {
Edge<Node> e1{};

if (!x.isTerminal() && x.nextNode->varIndx == newSuccessor) {
if (!x.isTerminal() && x.nextNode->varIndex == newSuccessor) {
e1 = x.nextNode->edges.at(i);

if (e1.weight != Complex::zero) {
Expand All @@ -811,7 +811,7 @@ class MDDPackage {
}

Edge<Node> e2{};
if (!y.isTerminal() && y.nextNode->varIndx == newSuccessor) {
if (!y.isTerminal() && y.nextNode->varIndex == newSuccessor) {
e2 = y.nextNode->edges.at(i);

if (e2.weight != Complex::zero) {
Expand All @@ -826,12 +826,12 @@ class MDDPackage {

edgeSum.at(i) = add2(e1, e2);

if (!x.isTerminal() && x.nextNode->varIndx == newSuccessor &&
if (!x.isTerminal() && x.nextNode->varIndex == newSuccessor &&
e1.weight != Complex::zero) {
complexNumber.returnToCache(e1.weight);
}

if (!y.isTerminal() && y.nextNode->varIndx == newSuccessor &&
if (!y.isTerminal() && y.nextNode->varIndex == newSuccessor &&
e2.weight != Complex::zero) {
complexNumber.returnToCache(e2.weight);
}
Expand Down Expand Up @@ -862,10 +862,10 @@ class MDDPackage {
QuantumRegister var = -1;

if (!x.isTerminal()) {
var = x.nextNode->varIndx;
var = x.nextNode->varIndex;
}
if (!y.isTerminal() && (y.nextNode->varIndx) > var) {
var = y.nextNode->varIndx;
if (!y.isTerminal() && (y.nextNode->varIndex) > var) {
var = y.nextNode->varIndex;
}

RightOperand e = multiply2(x, y, var, start);
Expand Down Expand Up @@ -934,8 +934,8 @@ class MDDPackage {

ResultEdge resultEdge{};

if (x.nextNode->varIndx == var &&
x.nextNode->varIndx == y.nextNode->varIndx) {
if (x.nextNode->varIndex == var &&
x.nextNode->varIndex == y.nextNode->varIndex) {
if (x.nextNode->identity) {
if constexpr (std::is_same_v<RightOperandNode, mNode>) {
// additionally check if y is the identity in case of matrix
Expand Down Expand Up @@ -982,19 +982,19 @@ class MDDPackage {
const std::size_t rows =
x.isTerminal()
? 1U
: registersSizes.at(static_cast<std::size_t>(x.nextNode->varIndx));
: registersSizes.at(static_cast<std::size_t>(x.nextNode->varIndex));
const std::size_t cols =
(std::is_same_v<RightOperandNode, mNode>)
? y.isTerminal() ? 1U
: registersSizes.at(static_cast<std::size_t>(
y.nextNode->varIndx))
y.nextNode->varIndex))
: 1U;
const std::size_t multiplicationBoundary =
x.isTerminal()
? (y.isTerminal() ? 1U
: registersSizes.at(static_cast<std::size_t>(
y.nextNode->varIndx)))
: registersSizes.at(static_cast<std::size_t>(x.nextNode->varIndx));
y.nextNode->varIndex)))
: registersSizes.at(static_cast<std::size_t>(x.nextNode->varIndex));

std::vector<ResultEdge> edge(multiplicationBoundary * cols,
ResultEdge::zero);
Expand All @@ -1006,14 +1006,14 @@ class MDDPackage {

for (auto k = 0U; k < multiplicationBoundary; k++) {
LEdge e1{};
if (!x.isTerminal() && x.nextNode->varIndx == var) {
if (!x.isTerminal() && x.nextNode->varIndex == var) {
e1 = x.nextNode->edges.at(rows * i + k);
} else {
e1 = xCopy;
}

REdge e2{};
if (!y.isTerminal() && y.nextNode->varIndx == var) {
if (!y.isTerminal() && y.nextNode->varIndex == var) {
e2 = y.nextNode->edges.at(j + cols * k);
} else {
e2 = yCopy;
Expand Down Expand Up @@ -1067,9 +1067,9 @@ class MDDPackage {

[[maybe_unused]] const auto before = complexNumber.cacheCount();

auto circWidth = x.nextNode->varIndx;
if (y.nextNode->varIndx > circWidth) {
circWidth = y.nextNode->varIndx;
auto circWidth = x.nextNode->varIndex;
if (y.nextNode->varIndex > circWidth) {
circWidth = y.nextNode->varIndex;
}
const ComplexValue ip =
innerProduct(x, y, static_cast<QuantumRegister>(circWidth + 1));
Expand Down Expand Up @@ -1119,13 +1119,13 @@ class MDDPackage {
for (auto i = 0U; i < registersSizes.at(static_cast<std::size_t>(width));
i++) {
vEdge e1{};
if (!x.isTerminal() && x.nextNode->varIndx == width) {
if (!x.isTerminal() && x.nextNode->varIndex == width) {
e1 = x.nextNode->edges.at(i);
} else {
e1 = xCopy;
}
vEdge e2{};
if (!y.isTerminal() && y.nextNode->varIndx == width) {
if (!y.isTerminal() && y.nextNode->varIndex == width) {
e2 = y.nextNode->edges.at(i);
e2.weight = ComplexNumbers::conj(e2.weight);
} else {
Expand Down Expand Up @@ -1207,30 +1207,30 @@ class MDDPackage {
std::vector<Edge<Node>> newEdges(x.nextNode->edges.size(),
dd::Edge<Node>::zero);

for (auto i = 0U;
i < registersSizes.at(static_cast<std::size_t>(x.nextNode->varIndx));
for (auto i = 0U; i < registersSizes.at(
static_cast<std::size_t>(x.nextNode->varIndex));
i++) {
newEdges.at(i + i * (registersSizes.at(static_cast<std::size_t>(
x.nextNode->varIndx)))) = y;
x.nextNode->varIndex)))) = y;
}
auto idx = incIdx ? static_cast<QuantumRegister>(y.nextNode->varIndx + 1)
: y.nextNode->varIndx;
auto idx = incIdx ? static_cast<QuantumRegister>(y.nextNode->varIndex + 1)
: y.nextNode->varIndex;

auto e = makeDDNode(idx, newEdges);

for (auto i = 0; i < x.nextNode->varIndx; ++i) {
for (auto i = 0; i < x.nextNode->varIndex; ++i) {
std::vector<Edge<Node>> eSucc(e.nextNode->edges.size(),
dd::Edge<Node>::zero);
for (auto j = 0U;
j <
registersSizes.at(static_cast<std::size_t>(e.nextNode->varIndx));
registersSizes.at(static_cast<std::size_t>(e.nextNode->varIndex));
j++) {
eSucc.at(j + j * (registersSizes.at(static_cast<std::size_t>(
e.nextNode->varIndx)))) = e;
e.nextNode->varIndex)))) = e;
}

idx = incIdx ? static_cast<QuantumRegister>(e.nextNode->varIndx + 1)
: e.nextNode->varIndx;
idx = incIdx ? static_cast<QuantumRegister>(e.nextNode->varIndex + 1)
: e.nextNode->varIndex;

e = makeDDNode(idx, eSucc);
}
Expand All @@ -1247,9 +1247,9 @@ class MDDPackage {
edge.at(i) = kronecker2(x.nextNode->edges.at(i), y, incIdx);
}

auto idx = incIdx ? static_cast<QuantumRegister>(y.nextNode->varIndx +
x.nextNode->varIndx + 1)
: x.nextNode->varIndx;
auto idx = incIdx ? static_cast<QuantumRegister>(y.nextNode->varIndex +
x.nextNode->varIndex + 1)
: x.nextNode->varIndex;
auto e = makeDDNode(idx, edge, true);
ComplexNumbers::mul(e.weight, e.weight, x.weight);
computeTable.insert(x, y, {e.nextNode, e.weight});
Expand Down Expand Up @@ -1593,7 +1593,7 @@ class MDDPackage {
ComplexNumbers::mul(tempCompNumb, tempCompNumb, currentEdge.weight);
const auto tmp =
static_cast<std::size_t>(pathElements.at(static_cast<std::size_t>(
currentEdge.nextNode->varIndx)) -
currentEdge.nextNode->varIndex)) -
'0');
assert(tmp <= currentEdge.nextNode->edges.size());
currentEdge = currentEdge.nextNode->edges.at(tmp);
Expand Down Expand Up @@ -1810,15 +1810,15 @@ class MDDPackage {
private:
// check whether node represents a symmetric matrix or the identity
void checkSpecialMatrices(mNode* node) {
if (node->varIndx == -1) {
if (node->varIndex == -1) {
return;
}

node->identity = false; // assume not identity
node->symmetric = false; // assume symmetric

// check if matrix is symmetric
auto basicDim = registersSizes.at(static_cast<std::size_t>(node->varIndx));
auto basicDim = registersSizes.at(static_cast<std::size_t>(node->varIndex));

for (auto i = 0UL; i < basicDim; i++) {
if (!node->edges.at(i * basicDim + i).nextNode->symmetric) {
Expand Down Expand Up @@ -1891,7 +1891,7 @@ class MDDPackage {

std::vector<mEdge> newEdge{};
auto basicDim =
registersSizes.at(static_cast<std::size_t>(edge.nextNode->varIndx));
registersSizes.at(static_cast<std::size_t>(edge.nextNode->varIndex));

// transpose sub-matrices and rearrange as required
for (auto i = 0U; i < basicDim; i++) {
Expand All @@ -1901,7 +1901,7 @@ class MDDPackage {
}
}
// create new top node
result = makeDDNode(edge.nextNode->varIndx, newEdge);
result = makeDDNode(edge.nextNode->varIndex, newEdge);
// adjust top weight
auto c = complexNumber.getTemporary();
ComplexNumbers::mul(c, result.weight, edge.weight);
Expand Down Expand Up @@ -1930,7 +1930,7 @@ class MDDPackage {
std::vector<mEdge> newEdge(edge.nextNode->edges.size(),
dd::Edge<mNode>::zero);
auto basicDim =
registersSizes.at(static_cast<std::size_t>(edge.nextNode->varIndx));
registersSizes.at(static_cast<std::size_t>(edge.nextNode->varIndex));

// conjugate transpose submatrices and rearrange as required
for (auto i = 0U; i < basicDim; ++i) {
Expand All @@ -1940,7 +1940,7 @@ class MDDPackage {
}
}
// create new top node
result = makeDDNode(edge.nextNode->varIndx, newEdge);
result = makeDDNode(edge.nextNode->varIndex, newEdge);

auto c = complexNumber.getTemporary();
// adjust top weight including conjugate
Expand Down
8 changes: 4 additions & 4 deletions include/dd/UniqueTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ class UniqueTable {

lookups++;
const auto key = static_cast<std::size_t>(hash(e.nextNode));
const auto v = e.nextNode->varIndx;
const auto v = e.nextNode->varIndex;

// successors of a node shall either have successive variable numbers
// or be terminals
for ([[maybe_unused]] const auto& edge : e.nextNode->edges) {
assert(edge.nextNode->varIndx == v - 1 || edge.isTerminal());
assert(edge.nextNode->varIndex == v - 1 || edge.isTerminal());
}

Node* p = tables[static_cast<std::size_t>(v)][key];
Expand All @@ -120,12 +120,12 @@ class UniqueTable {
hits++;

// variables should stay the same
assert(p->varIndx == e.nextNode->varIndx);
assert(p->varIndex == e.nextNode->varIndex);

// successors of a node shall either have successive variable
// numbers or be terminals
for ([[maybe_unused]] const auto& edge : e.nextNode->edges) {
assert(edge.nextNode->varIndx == v - 1 || edge.isTerminal());
assert(edge.nextNode->varIndex == v - 1 || edge.isTerminal());
}

return {p, e.weight};
Expand Down
Loading
Loading