# Strawberry Fields source code

**URL:** <https://discuss.pennylane.ai/t/strawberry-fields-source-code/415>\
**Category:** Strawberry Fields\
**Created:** [June 2, 2020, 1:40pm UTC](https://discuss.pennylane.ai/t/strawberry-fields-source-code/415 "2020-06-02T13:40:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![valeria](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@valeria](https://discuss.pennylane.ai/u/valeria)\
**Post date:** [June 2, 2020, 1:40pm UTC](https://discuss.pennylane.ai/t/strawberry-fields-source-code/415/1 "2020-06-02T13:40:19Z")

</div>

Hi,

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

> <https://github.com/XanaduAI/strawberryfields/blob/8f3cf68246fc50942d94f219a4e61f6fa2935225/strawberryfields/backends/gaussianbackend/gaussiancircuit.py>

  
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!

---

<div class="post-metadata">

**Author:** ![Nicolas\_Quesada](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nicolas_quesada/32/118_2.png) [@Nicolas\_Quesada](https://discuss.pennylane.ai/u/Nicolas_Quesada)\
**Post date:** [June 2, 2020, 4:28pm UTC](https://discuss.pennylane.ai/t/strawberry-fields-source-code/415/2 "2020-06-02T16:28:45Z")

</div>

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 ([https://journals.aps.org/pra/abstract/10.1103/PhysRevA.49.1567](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.49.1567))

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. [https://the-walrus.readthedocs.io/en/latest/code/symplectic.html](https://the-walrus.readthedocs.io/en/latest/code/symplectic.html))

Hope this answers your question,

Nicolas

---

<div class="post-metadata">

**Author:** ![valeria](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@valeria](https://discuss.pennylane.ai/u/valeria)\
**Post date:** [June 3, 2020, 10:24am UTC](https://discuss.pennylane.ai/t/strawberry-fields-source-code/415/3 "2020-06-03T10:24:25Z")

</div>

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