unitaria.ControlledSubspace¶
- class unitaria.ControlledSubspace(case_zero: Subspace, case_one: Subspace)[source]¶
Bases:
SubspaceFactorSubspaceFactor where the most significant qubit determines the subspace corresponding to lower qubits
- Parameters:
case_zero – Embedding of lower qubits, if highest qubit is
|0>case_one – Embedding of lower qubits, if highest qubit is
|1>
- circuit(target: Sequence[int], flag: int, ancillae: Sequence[int]) Circuit[source]¶
A circuit which checks whether a state is inside the subspace.
The result of the check will be stored in the flag qubit. Specifically, this qubit will be flipped if the other qubits represent a state outside the embedded vector space.
- simplify() list[SubspaceFactor][source]¶
Returns a potentially simpler representation of this factor
Specifically, if
case_oneandcase_zeroagree in a number of lowest qubits, this common part can be factored out. E.g.>>> import unitaria as ut >>> ut.ControlledSubspace(ut.Subspace("##"), ut.Subspace("0#")).simplify() [ControlledSubspace(case_zero=Subspace(), case_one=Subspace()), ControlledSubspace(case_zero=Subspace("#"), case_one=Subspace("0"))]