quantum-compiler / quartz

The Quartz Quantum Compiler
Apache License 2.0
76 stars 19 forks source link

[gate] Support general controlled gates #105

Closed xumingkuan closed 10 months ago

xumingkuan commented 1 year ago

We assumed all controlled gates to be controlling on the |1> state. It can be useful to also support controlled gates on the |0> state, like the CX[0](q_0, q_1) gate on the left.

q_0: ──o────■──
     ┌─┴─┐┌─┴─┐
q_1: ┤ X ├┤ X ├
     └───┘└───┘

To support them, I am thinking to add a class GeneralControlledGate : public Gate, which stores a std::vector<bool> of the states of the control qubits, and a Gate * pointer to the controlled gate object.

I am going to support them in the simulator branch first before merging into the master branch.