Bug Description
It seems that qutip.gates.phasegate somehow neglects the imaginary part in the phase gate if the angle is such that it points to lower half of the complex plane, i.e. for angles between pi and 2pi. Printing the created Qobj looks okay, but taking the Hermitian transpose .dag() actually doesn't change anything, and .diag() outputs only real numbers.
Code to Reproduce the Bug
import numpy as np
import qutip as qt
pg = qt.gates.phasegate(4*np.pi/3)
print(pg)
print(pg.dag())
print(pg.diag())
Code Output
Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=CSR, isherm=True
Qobj data =
[[ 1. +0.j 0. +0.j ]
[ 0. +0.j -0.5-0.8660254j]]
Quantum object: dims=[[2], [2]], shape=(2, 2), type='oper', dtype=CSR, isherm=True
Qobj data =
[[ 1. +0.j 0. +0.j ]
[ 0. +0.j -0.5-0.8660254j]]
[ 1. -0.5]
Expected Behaviour
Taking the .dag() should change the sign of the imaginary part in [1,1] element. For Qutip version 4.7.3 this works as it should.
Your Environment
QuTiP Version: 5.1.1
Numpy Version: 1.26.4
Scipy Version: 1.14.1
Cython Version: None
Matplotlib Version: 3.6.3
Python Version: 3.11.11
Number of CPUs: 8
BLAS Info: Generic
INTEL MKL Ext: None
Platform Info: Windows (AMD64)
Additional Context
No response
Bug Description
It seems that
qutip.gates.phasegatesomehow neglects the imaginary part in the phase gate if the angle is such that it points to lower half of the complex plane, i.e. for angles between pi and 2pi. Printing the created Qobj looks okay, but taking the Hermitian transpose.dag()actually doesn't change anything, and.diag()outputs only real numbers.Code to Reproduce the Bug
Code Output
Expected Behaviour
Taking the
.dag()should change the sign of the imaginary part in [1,1] element. For Qutip version 4.7.3 this works as it should.Your Environment
Additional Context
No response