Browse Source

Simplify measurement table

Dunno why it was ever `complex`
master
Pete Shadbolt 8 years ago
parent
commit
c793418517
4 changed files with 9 additions and 13 deletions
  1. +4
    -8
      abp/build_tables.py
  2. +1
    -3
      abp/tables.py
  3. +1
    -2
      static/scripts/tables.js
  4. +3
    -0
      tests/test_conjugation.py

+ 4
- 8
abp/build_tables.py View File

@@ -24,8 +24,7 @@ var tables = {{
times_table : {times_table}, times_table : {times_table},
cz_table : {cz_table}, cz_table : {cz_table},
clifford : {by_name}, clifford : {by_name},
measurement_table_real : {measurement_table_real},
measurement_table_imag : {measurement_table_imag}
measurement_table: {measurement_table}
}}; }};
""" """


@@ -39,13 +38,11 @@ conjugation_table = np.array({conjugation_table}, dtype=int)
times_table = np.array({times_table}, dtype=int) times_table = np.array({times_table}, dtype=int)
cz_table = np.array({cz_table}, dtype=int) cz_table = np.array({cz_table}, dtype=int)
by_name = {by_name} by_name = {by_name}
measurement_table_real = np.array({measurement_table_real}, dtype=complex)
measurement_table_imag = np.array({measurement_table_imag}, dtype=complex)
measurement_table = np.array({measurement_table}, dtype=int)
unitaries_real = np.array({unitaries_real}, dtype=complex) unitaries_real = np.array({unitaries_real}, dtype=complex)
unitaries_imag = np.array({unitaries_imag}, dtype=complex) unitaries_imag = np.array({unitaries_imag}, dtype=complex)


# Reconstruct # Reconstruct
measurement_table = measurement_table_real + 1j*measurement_table_imag
unitaries = unitaries_real + 1j*unitaries_imag unitaries = unitaries_real + 1j*unitaries_imag
""" """


@@ -149,7 +146,7 @@ def get_measurement_table():
Compute a table of transform * operation * transform^dagger Compute a table of transform * operation * transform^dagger
This is pretty unintelligible right now, we should probably compute the phase from unitaries instead This is pretty unintelligible right now, we should probably compute the phase from unitaries instead
""" """
measurement_table = np.zeros((4, 24, 2), dtype=complex)
measurement_table = np.zeros((4, 24, 2), dtype=int)
for operator, unitary in it.product(range(4), range(24)): for operator, unitary in it.product(range(4), range(24)):
measurement_table[operator, unitary] = get_measurement_entry( measurement_table[operator, unitary] = get_measurement_entry(
operator, unitary) operator, unitary)
@@ -204,8 +201,7 @@ def human_readable(data):
"times_table": json.dumps(data["times_table"].tolist()), "times_table": json.dumps(data["times_table"].tolist()),
"cz_table": json.dumps(data["cz_table"].tolist()), "cz_table": json.dumps(data["cz_table"].tolist()),
"by_name": json.dumps(data["by_name"]), "by_name": json.dumps(data["by_name"]),
"measurement_table_real": json.dumps(data["measurement_table"].real.tolist()),
"measurement_table_imag": json.dumps(data["measurement_table"].imag.tolist())}
"measurement_table": json.dumps(data["measurement_table"].tolist())}




def write_python(data): def write_python(data):


+ 1
- 3
abp/tables.py
File diff suppressed because it is too large
View File


+ 1
- 2
static/scripts/tables.js
File diff suppressed because it is too large
View File


+ 3
- 0
tests/test_conjugation.py View File

@@ -12,10 +12,13 @@ def test_conjugation():
operation = graphsim.LocCliffOp(operation_index) operation = graphsim.LocCliffOp(operation_index)


phase = operation.conjugate(transform).ph phase = operation.conjugate(transform).ph
if phase == 1:
print phase
phase = [1, 0, -1][phase] phase = [1, 0, -1][phase]
new_operation = operation.op new_operation = operation.op


NEW_OPERATION, PHASE = clifford.conjugate(operation_index, transform_index) NEW_OPERATION, PHASE = clifford.conjugate(operation_index, transform_index)
print PHASE
assert new_operation == NEW_OPERATION assert new_operation == NEW_OPERATION
assert PHASE == phase assert PHASE == phase



Loading…
Cancel
Save