Closed tguillaume closed 3 years ago
Hi @tguillaume --- Thanks for catching this bug! Since you already have a solution, would you mind making a PR with your proposed fix?
With #556 merged, closing this, thank you so much @tguillaume @nquesada! 🙂
The functions
strawberryfields.ops.Catstate
andstrawberryfields.utils.states.cat_state
do not work properly with a large Fock dimension cut-off. For example, when I try to runstrawberryfields.utils.states.cat_state(a=4, p=0, fock_dim=50)
, the returned Fock probabilities over n=16 are zero.Inside these functions, the ket's array is initialized as type int32 due to (I think) an earlier use of np.arange with int32 argument. As a result, some of the maths that is performed further on in the function evaluates to 0 when the number is sufficiently large.
I was able to fix this by initializing the array describing the ket as a float, e.g.
k = np.arange(fock_dim, dtype='float')
orl = np.arange(D, dtype='float').