QuTech-Delft / OpenQL

OpenQL: A Portable Quantum Programming Framework for Quantum Accelerators. https://dl.acm.org/doi/10.1145/3474222
https://openql.readthedocs.io
Other
99 stars 44 forks source link

gates are created by calling a constructor directly instead of using gate() #326

Open jvansomeren opened 4 years ago

jvansomeren commented 4 years ago

In several places in the OpenQL compiler, gates are created by calling the gate-specific built-in constructor directly instead of using the gate() interface. The latter is more general and allows configuring the gate in the configuration file. As last resort, gate() allocates the gate using the default constructor inside the kernel functionadd_default_gate_if_available when the option use_default_gates is on using the old method (such as c.push_back(new ql::rz(qubit,angle))).

But to make creating gates using gate() possible, the respective gates should be defined in the configuration file or the option use_default_gates should be on.

I propose: adding gates such as rx, ry and rz to the configuration files that are used to configure tests using rx, ry, rz; similarly for other gates.

Replace code such as (but not in add_default_gate_if_available since that is the default way):

    c.push_back(new ql::rz(qubit,angle));
    cycles_valid = false;

by

    k.gate("rz", {qubit}, {}, 0, angle);