def H(state, qubit):
    """
    Applies a Hadamard gate (H) rotation to stabilizers and destabilizers

    Same as H1 in some places in PECOS.

    X + Z

    X -> Z
    Z -> X
    W -> -W
    Y -> -Y
    """
    stabs = state.stabs
    stabs.signs_minus ^= stabs.col_x[qubit] & stabs.col_z[qubit]
    for g in state.gen_list:
        xonly = g.col_x[qubit] - g.col_z[qubit]
        zonly = g.col_z[qubit] - g.col_x[qubit]
        for i in xonly:
            g.row_x[i].discard(qubit)
            g.row_z[i].add(qubit)
        for i in zonly:
            g.row_z[i].discard(qubit)
            g.row_x[i].add(qubit)
        g.col_x[qubit], g.col_z[qubit] = g.col_z[qubit], g.col_x[qubit]
