-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operator.power(n)
only works for integer n
#11454
Comments
I have assigned myself to the issue. However, any thoughts on |
The need of nth root of a operator may sound convincing if supporting general floating powers is in question |
Yes I think it can be supported. We just have to use the same code that is used in the Gate class now, which does in fact raise a matrix to a power using Also I think the "control" method should also work for operators. It amounts to increasing the dimension and making the new matrix a direct sum of Identity and U (if control is the lower qubit according to qiskit's little endian convention, otherwise a permutation of this matrix). |
Fractional-power To speak to Ali's other point: I think in the higher-abstraction-level world The (As a very much side note, can we stop referring to an "endianness" convention? It's at best misleading terminology, and it's not strictly related to the concepts here; the convention for "which qubit is the control?" is a separate question to "in which order do we perform the Kronecker product?" and "in which order do we label qubits?", and none of those are strictly about endianness.) |
I think all I'm saying for the Operator vs. UnitaryGate thing is that we should make it similar to how Cliffords are done now: >>>c = QuantumCircuit(2)
>>>c.append(random_clifford(2), [0, 1])
>>>c.append(random_unitary(4), [0, 1])
>>>print(type(c[0]))
>>>print(type(c[1]))
qiskit.quantum_info.operators.symplectic.clifford.Clifford
qiskit.circuit.library.generalized_gates.unitary.UnitaryGate The first one just uses Clifford, which is far better in my opinion as it gives access to the machinery we have around analyzing Cliffords and doesn't create unnecessary classes. The second one converts Ok we can call it something other than endianness :) I was trying to say that |
Oh yeah, I totally agree with all that - these to me are examples of a user interacting with the objects in an abstract mathematical way, so it's preferable that they stay as
|
Supporting Update: though let me first make sure that everyone agrees that the method |
Environment
What is happening?
In the description of the
Operator.power(n)
method:qiskit/qiskit/quantum_info/operators/operator.py
Lines 511 to 523 in 4b30598
the argument
power
is of typefloat
, however in practice this code only works for integer values ofn
.How can we reproduce the issue?
What should happen?
The
power
method ingate.py
:qiskit/qiskit/circuit/gate.py
Lines 64 to 75 in 4b30598
does work with floating-point powers and (as far as I can judge) could be moved to the
Operator
class.Any suggestions?
No response
The text was updated successfully, but these errors were encountered: