Skip to content

Commit

Permalink
Recommended fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeisakov committed Jan 4, 2022
1 parent 6460deb commit 2b57cab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/fuser_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,24 @@ class BasicGateFuser final : public Fuser<IO, Gate> {
const GatesLat& gates_lat) {
for (unsigned q : gate.qubits) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
IO::errorf("fuser: gate qubit %u is out of range "
"(should be smaller than %u).\n", q, max_qubit1);
return false;
}
if (!gates_lat[q].empty() && gate.time <= gates_lat[q].back()->time) {
IO::errorf("gate is out of time order.\n");
IO::errorf("fuser: gate at time %u is out of time order.\n", gate.time);
return false;
}
}

for (unsigned q : gate.controlled_by) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
IO::errorf("fuser: gate qubit %u is out of range "
"(should be smaller than %u).\n", q, max_qubit1);
return false;
}
if (!gates_lat[q].empty() && gate.time <= gates_lat[q].back()->time) {
IO::errorf("gate is out of time order.\n");
IO::errorf("fuser: gate at time %u is out of time order.\n", gate.time);
return false;
}
}
Expand Down
10 changes: 6 additions & 4 deletions lib/fuser_mqubit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,24 +1055,26 @@ class MultiQubitGateFuser final : public Fuser<IO, Gate> {
const GatesLat& gates_lat) {
for (unsigned q : gate.qubits) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
IO::errorf("fuser: gate qubit %u is out of range "
"(should be smaller than %u).\n", q, max_qubit1);
return false;
}
if (gates_lat[q] != nullptr
&& gate.time <= gates_lat[q]->val->parent->time) {
IO::errorf("gate is out of time order.\n");
IO::errorf("fuser: gate at time %u is out of time order.\n", gate.time);
return false;
}
}

for (unsigned q : gate.controlled_by) {
if (q >= max_qubit1) {
IO::errorf("gate qubits are out of range.\n");
IO::errorf("fuser: gate qubit %u is out of range "
"(should be smaller than %u).\n", q, max_qubit1);
return false;
}
if (gates_lat[q] != nullptr
&& gate.time <= gates_lat[q]->val->parent->time) {
IO::errorf("gate is out of time order.\n");
IO::errorf("fuser: gate at time %u is out of time order.\n", gate.time);
return false;
}
}
Expand Down

0 comments on commit 2b57cab

Please sign in to comment.