def reverse_gate(b, g): if b.get_size() != g.get_size(): return vec = b.get_vector() mat = g.get_matrix() result = mat.inv() * vec return bus.arbitrary_wire(b.get_size(), result)
def apply_gate(b, g): if b.get_size() != g.get_size(): return vec = b.get_vector() mat = g.get_matrix() result = mat * vec return bus.arbitrary_wire(b.get_size(), result)