Skip to content

Commit

Permalink
Added Reset for a couple of simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanro committed Jan 17, 2025
1 parent af67da1 commit 3348aa9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions QCSim/QubitRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ namespace QC {
registerStorage(NrBasisStates - 1) = OneOverSqrt2;
}

void Reset()
{
setToBasisState(0);
}

// all states have equal amplitude, so measurement should give any state with equal probability
void setToEqualSuperposition()
{
Expand Down
23 changes: 23 additions & 0 deletions QCSim/StabilizerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ namespace QC {
}
}

void Reset()
{
for (size_t q = 0; q < stabilizerGenerators.size(); ++q)
{
for (size_t p = 0; p < stabilizerGenerators.size(); ++p)
{
if (p == q)
{
destabilizerGenerators[q].X[q] = true;
stabilizerGenerators[q].Z[q] = true;
}
else
{
destabilizerGenerators[q].X[p] = false;
stabilizerGenerators[q].Z[p] = false;
}

destabilizerGenerators[q].PhaseSign = false;
stabilizerGenerators[q].PhaseSign = false;
}
}
}

bool MeasureQubit(size_t qubit)
{
size_t p;
Expand Down

0 comments on commit 3348aa9

Please sign in to comment.