Exponential of Pauli object requires conversion to Matrix
dieris opened this issue · 3 comments
expm(X)
does not convert a Pauli (X
) to a matrix.
Need to type expm(complex(X))
I was under the impression that maybe there would be a way to make this work through type promotion, but that does not appear to be the case -- is that right, @blakejohnson ?
It seems like right now we don't even support addition between a Pauli object and a matrix (without explicit conversion) -- although multiplication between a Pauli object and a matrix is supported.
The tricky things is that we want 1im*Pauli(j)
to be a Pauli object, and in order to do that, we forbid multiplication by anything that is not 1
,-1
,1im
,-1im
. So you would not be able to write im*(0.5*X+0.2*Y)
for example, much less the exponential of that.
Perhaps we can define a macro that will define Pauli matrices of type Matrix{Complex128}
, something like
@paulimatrices(I,X,Y,Z,2)
that would define the matrices
II
IX
IY
IZ
...
you would still be able to access the Pauli objects using Pauli.X
, Pauli.Y
, etc. Maybe we can make some sort of prefix optional too
@paulimatrices(I,X,Y,Z,2,prefix=m)
that would define the matrices
mII
mIX
mIY
mIZ
...
It would be easy enough to add a method to expm
so that the conversion step would be unnecessary, but I suspect that wouldn't be enough, because then we'd want things like expm(im*pi/2*X)
to work and that runs into the multiplication issue you mention.
Maybe a better solution is to have a special internal method for Number * Pauli
that returns a Pauli
and have the usual operator return a Matrix
?
Closed by #5.