Defines a composite gate that is generated by the logical addition of one or more gates.
Examples
You can create the union of two gates by combining them with how=’or’.
>>> union_gate = CompositeGate(gate1, 'or', gate2)
However,
There is a shorthand to do the same operation
>>> union_gate = gate1 | gate2
Similarly, if you wanted the intersection:
>>> intersection_gate = CompositeGate(gate1, 'and', gate2)
With the shorthand
>>> intersection_gate = gate1 & gate2
As another example, let’s invert a gate.
The longway:
>>> inverted_gate = CompositeGate(gate1, 'invert')
The shortway:
>>> inverted_gate = ~gate1
Warning
When using the shorthand notation you must use the syntax ‘~’, ‘&’, ‘|’. Do NOT use ‘and’, ‘or’, ‘not’.
Instead of using this class directly to create composite gates, it is recommended you use the shorthand syntax presented directly above.
Parameters: |
|
---|
Instead of using this class directly to create composite gates, it is recommended you use the shorthand syntax presented directly above.
Parameters: |
|
---|
Methods
__init__(gate1, how[, gate2]) | Instead of using this class directly to create composite gates, it is recommended you use the shorthand syntax presented directly above. |
plot([flip, ax_channels, ax]) | Plots the gate. |
Attributes
name |