QCHackers/tqec

Double-check AlternatingCornerSquareTemplate implementation

Closed this issue · 1 comments

Describe the bug

The AlternatingCornerSquareTemplate implementation does not adhere to the standard that the first plaquette provided to the instantiate method is at the top-right corner of an atomic template.

This "standard" of having the first plaquette provided to instantiate as the top-left plaquette is a good way to avoid issues from plaquettes not being placed as expected by the user. I think it has never been explicitly written anywhere in the code, but at the moment this "standard" is implicitly followed by all the atomic templates (with the exception of AlternatingCornerSquareTemplate).

Now, the question is the following: should we try to enforce that standard even with the AlternatingCornerSquareTemplate or not?

The issue with trying to enforce the standard is that, for convenience, AlternatingCornerSquareTemplate is implementing a family of 4 different templates (the 4 different possible location for the corner), and each member of this family of template has a different plaquette in the top-right corner.

UPPER_LEFT:
5  4  3  4
2  3  4  3
1  2  3  4
2  1  2  3

UPPER_RIGHT:
4  3  4  5
3  4  3  2
4  3  2  1
3  2  1  2

LOWER_LEFT:
2  1  2  3
1  2  3  4
2  3  4  3
5  4  3  4

LOWER_RIGHT:
3  2  1  2
4  3  2  1
3  4  3  2
4  3  4  5

So we have two solutions:

  1. (currently implemented) do not enforce the "standard" on this atomic template and add documentation to explicitly document that.
  2. enforce the "standard", renumbering the plaquettes of each member of the family, which might be even more confusing than 1.

Any thoughts / opinions?

Maybe it can have a function setCorner(value,position) which explicitly sets the corner and enforce the standard?