As discussed in #126 (review), control and target ordering is incorrect in the README and nonstandard in function declarations. They should probably be changed to control first, then target
|
* CNOTs must be in the form `cx q[n],q[m];` where `n` and `m` are non-negative. Target comes first, as per [OpenQASM convention (Fig 2)](https://arxiv.org/pdf/1707.03429.pdf) |
|
if(line.instruction == "cx") |
|
{ |
|
if(line.args.size() != 2) throw GateParseException{lstk::cat("cx gate must have 2 args")}; |
|
return gates::CNOT( |
|
get_index_arg(line.args.at(1)), |
|
get_index_arg(line.args.at(0)), |
|
determine_cnot_type(line.annotations), |
|
determine_cnot_ancilla_placement(line.annotations)); |
|
} |
|
|
|
if(line.instruction == "cz") |
|
{ |
|
if(line.args.size() != 2) throw GateParseException{lstk::cat("cz gate must have 2 args")}; |
|
return gates::CZ( |
|
get_index_arg(line.args.at(1)), |
|
get_index_arg(line.args.at(0)), |
|
determine_cnot_type(line.annotations), |
|
determine_cnot_ancilla_placement(line.annotations)); |
|
} |
|
inline constexpr ControlledGate CNOT( |
|
QubitNum target_qubit, |
|
QubitNum control_qubit, |
|
CNOTType cnot_type = CNOTType::ZX_WITH_MBM_CONTROL_FIRST, |
|
CNOTAncillaPlacement cnot_ancilla_placement = CNOTAncillaPlacement::ANCILLA_NEXT_TO_CONTROL |
|
){ |
|
return {control_qubit, X(target_qubit), cnot_type, cnot_ancilla_placement}; |
|
} |
|
|
|
inline constexpr ControlledGate CZ( |
|
QubitNum target_qubit, |
|
QubitNum control_qubit, |
|
CNOTType cnot_type = CNOTType::ZX_WITH_MBM_CONTROL_FIRST, |
|
CNOTAncillaPlacement cnot_ancilla_placement = CNOTAncillaPlacement::ANCILLA_NEXT_TO_CONTROL |
|
){ |
|
return {control_qubit, Z(target_qubit), cnot_type, cnot_ancilla_placement}; |
|
} |
|
|
|
inline constexpr ControlledGate CRZ( |
|
QubitNum target_qubit, QubitNum control_qubit, Fraction pi_fraction, CNOTType cnot_type, CNOTAncillaPlacement cnot_ancilla_placement){ |
|
return {control_qubit, RZ{target_qubit, pi_fraction}, cnot_type, cnot_ancilla_placement}; |
|
} |
|
|
As discussed in #126 (review), control and target ordering is incorrect in the README and nonstandard in function declarations. They should probably be changed to control first, then target
liblsqecc/README.md
Line 88 in d1c4e69
liblsqecc/src/gates/parse_gates.cpp
Lines 167 to 185 in d1c4e69
liblsqecc/include/lsqecc/gates/gates.hpp
Lines 121 to 143 in d1c4e69