Closed dehond closed 3 years ago
Hi @dehond, Yes, I think your proposed solution would make sense. A specific error message would be sufficient in my opinion.
I would appreciate it if you send a pull request.
Best, Christoph
Ok, @ChristophHotter, will do!
The problem Whenever I define a basis state using the
Ket()
method I've noticed that the data type of the state vector is left to be the same as what I put in, see the following example:I imagine it is maintained to use optimized methods for matrix multiplication and diagonalization, and most of the time it works great. When trying to solve time dependent problems I run into a problem, though. Trying the following, for instance
results in an
InexactError: Float64(0 - 1im)
with an enormous stacktrace that I have no hope of understanding. The problem goes away if I enforce the coefficients of the state vector to be complex, i.e. settingI've run into this problem several times but keep forgetting how to solve it because the error message is opaque to me. Every time I figure it out I think: "Darn it, I should really remember this next time!" but that invariably doesn't happen.
Proposed solution Would it be possible to have the
timeevolution
methods perform a check on the data type of the initial state, and have them convert it to complex if need be? Or at least throw an intelligible error message into the user's lap? In my view this would make the package more user friendly.I would be happy to give this a go and file a pull request.
Version data QuantumOptics v0.8.4 Julia 1.5.3