Strawberry Fields source code


I was reading Strawberry Fields source code on GitHub and I found something that captured my attention. In

I see that you define the covariance matrices in term of two matrices N and M: what do they represent? In which way are they related to the “standard” covariance matrix for the Wigner function?

Thanks in advance!

Hi Valeria — Thanks for you question. The M and N matrices are the normal ordered moments of the destruction operators.

As described in lines 39-40 of the file you mentioned they are defined as

N_{i,j} =\langle a_i^\dagger a_j \rangle
M_{i,j} = \langle a_i a_j \rangle

They have the nice property of being independent of \hbar and are zero for the multimode vacuum state.

They are also related to the A and B matrices in Eq. 2.37 of the classical paper by Simon, Mukunda and Dutta (

If you want to convert between M and N and the standard quadrature covariance matrix V you can use the method scovmaxp to go from M and N to V and you can use fromscovmat to do the opposite.

Also, if you want to play directly with the standard covariance matrices in the quadrature formalism I’d recommend you to have a look at the symplectic module of The Walrus (cf.

Hope this answers your question,



Dear Nicolas,
thank you for your reply, it is exactly what I was looking for.