+ | State data |
+ {
+ config.ExperimentalSimulatorStabilizerStateVisualizationStyle switch
+ {
+ StabilizerStateVisualizationStyle.MatrixWithDestabilizers =>
+ $@"$$\left(\begin{{array}}{{{colspec}}}{
+ string.Join(
+ "\\\\\n",
+ Enumerable
+ .Range(0, data.Shape[0])
+ .Select(
+ idxRow =>
+ (
+ idxRow == nQubits
+ ? "\\hline\n"
+ : ""
+ ) + string.Join(" & ",
+ Enumerable.Range(0, data.Shape[1])
+ .Select(
+ idxCol => data[idxRow, idxCol] ? "1" : "0"
+ )
+ )
+ )
+ )
+ }\end{{array}}\right)$$",
+ StabilizerStateVisualizationStyle.MatrixWithoutDestabilizers =>
+ $@"$$\left(\begin{{array}}{{{colspec}}}{
+ string.Join(
+ "\\\\\n",
+ Enumerable
+ .Range(nQubits, data.Shape[0] / 2)
+ .Select(
+ idxRow => string.Join(" & ",
+ Enumerable.Range(0, data.Shape[1])
+ .Select(
+ idxCol => data[idxRow, idxCol] ? "1" : "0"
+ )
+ )
+ )
+ )
+ }\end{{array}}\right)$$",
+ // FIXME: include phases in each!
+ StabilizerStateVisualizationStyle.DenseGroupPresentation =>
+ $@"$$\left\langle {
+ string.Join(
+ ", ",
+ Enumerable
+ .Range(nQubits, data.Shape[0] / 2)
+ .Select(
+ idxRow =>
+ (data[idxRow, 2 * nQubits] == true ? "-" : "") +
+ string.Join("",
+ Enumerable.Range(0, nQubits)
+ .Select(idxQubit =>
+ {
+ (bool x, bool z) = (data[idxRow, idxQubit], data[idxRow, nQubits + idxQubit]);
+ return (x, z) switch
+ {
+ (false, false) => "𝟙",
+ (true, false) => "X",
+ (false, true) => "Z",
+ (true, true) => "Y"
+ };
+ })
+ )
+ )
+ )
+ } \right\rangle$$",
+ StabilizerStateVisualizationStyle.SparseGroupPresentation =>
+ $@"$$\left\langle {
+ string.Join(
+ ", ",
+ Enumerable
+ .Range(nQubits, data.Shape[0] / 2)
+ .Select(
+ idxRow =>
+ (data[idxRow, 2 * nQubits] == true ? "-" : "") +
+ string.Join("",
+ Enumerable.Range(0, nQubits)
+ .Select(idxQubit =>
+ {
+ (bool x, bool z) = (data[idxRow, idxQubit], data[idxRow, nQubits + idxQubit]);
+ return (x, z) switch
+ {
+ (false, false) => "",
+ (true, false) => $"X_{{{idxQubit}}}",
+ (false, true) => $"Z_{{{idxQubit}}}",
+ (true, true) => $"Y_{{{idxQubit}}}"
+ };
+ })
+ )
+ )
+ )
+ } \right\rangle$$",
+ var unknown => throw new Exception($"Invalid visualization style {unknown}.")
+ }
+ } |
+
+