Skip to content

Commit

Permalink
Allowed to save/restore the state of the clifford simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanro committed Nov 13, 2024
1 parent 40bcc34 commit 41716ac
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions QCSim/Clifford.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,24 @@ namespace QC {
return h.PhaseSign;
}

void SaveState()
{
savedDestabilizerGenerators = destabilizerGenerators;
savedStabilizerGenerators = stabilizerGenerators;
}

void RestoreSavedState()
{
destabilizerGenerators.swap(savedDestabilizerGenerators);
stabilizerGenerators.swap(savedStabilizerGenerators);
}

void ClearSavedState()
{
savedDestabilizerGenerators.clear();
savedStabilizerGenerators.clear();
}

private:
inline static bool XOR(bool a, bool b)
{
Expand Down Expand Up @@ -529,6 +547,9 @@ namespace QC {
std::vector<Generator> destabilizerGenerators;
std::vector<Generator> stabilizerGenerators;

std::vector<Generator> savedDestabilizerGenerators;
std::vector<Generator> savedStabilizerGenerators;

std::default_random_engine gen;
std::bernoulli_distribution rnd;
};
Expand Down

0 comments on commit 41716ac

Please sign in to comment.