unitaria.ControlledSubspace

class unitaria.ControlledSubspace(case_zero: Subspace, case_one: Subspace)[source]

Bases: SubspaceFactor

SubspaceFactor 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.

clean_ancilla_count() int[source]
dimension() int[source]

The dimension of the subspace

simplify() list[SubspaceFactor][source]

Returns a potentially simpler representation of this factor

Specifically, if case_one and case_zero agree 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"))]
total_qubits() int[source]

The number of qubits of the state space in which the subspace lives

The dimension of the state space is 2 ** total_qubits

case_one: Subspace
case_zero: Subspace