Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/python/verifier/verifier_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,24 @@ def search_phase_factor_to_check_equivalence(
# print(f'Checking phase factor {current_phase_factor_for_fingerprint}')
output_vec2_shifted = phase_shift(output_vec2, current_phase_factor_symbolic)
# verify v1[0] == v2[0] and v1[1] == v2[1]
x = sympy.symbols("x")
diff = any(
sympy.minimal_polynomial(v1[0] - v2[0], x) != x
or sympy.minimal_polynomial(v1[1] - v2[1], x) != x
v1[0] != v2[0] or v1[1] != v2[1]
for (v1, v2) in zip(output_vec1, output_vec2_shifted)
)
if diff: # simple v1[0] == v2[0] and v1[1] == v2[1] check doesn't work
try:
x = sympy.symbols("x")
diff = any(
sympy.minimal_polynomial(v1[0] - v2[0], x) != x
or sympy.minimal_polynomial(v1[1] - v2[1], x) != x
for (v1, v2) in zip(output_vec1, output_vec2_shifted)
)
except sympy.polys.polyerrors.NotAlgebraic:
diff = any(
sympy.simplify(v1[0] - v2[0]) != 0
or sympy.simplify(v1[1] - v2[1]) != 0
for (v1, v2) in zip(output_vec1, output_vec2_shifted)
)
if diff:
print(
f"sympy returns {[(sympy.simplify(v1[0] - v2[0]), sympy.simplify(v1[1] - v2[1])) for (v1, v2) in zip(output_vec1, output_vec2_shifted)]} for the following equivalence which passed random testing:"
Expand Down
4 changes: 3 additions & 1 deletion src/quartz/math/rational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ std::istream &operator>>(istream &cin, Rational &b) {
int ch;
while (cin) {
ch = cin.get();
if (!isspace(ch)) {
if (!isspace(ch) || ch == '"') { // filter out whitespace and '"'
cin.unget();
break;
}
Expand All @@ -922,6 +922,8 @@ std::istream &operator>>(istream &cin, Rational &b) {
if (isdigit(ch) || ch == '.' || ch == '-' || ch == '/' || ch == 'e' ||
ch == 'E' || ch == '+') {
s += (char)ch;
} else if (ch == '"') {
// filter out '"'
} else {
cin.unget();
break;
Expand Down
2 changes: 1 addition & 1 deletion src/test/test_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char **argv) {
}
}

ParamInfo param_info(/*num_input_symbolic_params=*/2, false);
ParamInfo param_info;
Context ctx({GateType::input_qubit, GateType::input_param, GateType::cx,
GateType::h, GateType::rz, GateType::x, GateType::add},
/*num_qubits=*/3, &param_info);
Expand Down
Loading