Ejemplo n.º 1
0
void switch_lines(circuit& circ, const circuit& base, gate::line allocation[] ) {
    //reconfigure gates in base circ
    foreach( const gate& cg, base) {
        gate_details gate_d = calculate_gate_details(cg, LNN_OPTIMIZATION_GLOBAL_REORDER, 0, base);
        gate g = cg;

        //interferes the current gate the choosen line?
        if(gate_d.target != allocation[gate_d.target]) {
            g.remove_target(gate_d.target);
            g.add_target(allocation[gate_d.target]);
        }
        if(gate_d.control != allocation[gate_d.control]) {
            g.remove_control(gate_d.control);
            g.add_control(allocation[gate_d.control]);
        }

        circ.append_gate() = g;
    }