-
Notifications
You must be signed in to change notification settings - Fork 1
Description
When you want to "build up" an operator that acts on multiple qubits, you'll often find yourself in a situation where you'll have to write
in order to "embed" a single qubit operator on a larger Hilbert space.
In squin, you'd do something like
x = squin.op.x()
id_lhs = squin.op.identity(sites=i)
id_rhs = squin.op.identity(sites=n - i - 1)
x_i = squin.op.kron(id_lhs, squin.op.kron(x, id_rhs))
Unfortunately, you can't use this approach unless n
and i
are actual constant values. That means you can neither define a short-hand embed(n: int, idx: int, op: Op)
(which we'd probably want as part of stdlib) nor can you use the above in a for loop. Also, you can't define an operator for different n
.
To solve this, we'll have to make sites
an argument rather than an attribute. The obvious downside is that a couple of different analysis will have a more difficult implementation, since you won't always be able to infer the number of sites from the identity anymore.