# Experimental

Note

Functions here are untested and under-documented.

## Continuous Variables

This module contains a collection functions for calculating continuous variable quantities from fock-basis representation of the state of multi-mode fields.

correlation_matrix(basis, rho=None)

  Given a basis set of operators \(\{a\}_n\), calculate the correlation matrix:

  \[C_{mn} = \langle a_m a_n \rangle\]
  Parameters:
    basis list

      List of operators that defines the basis for the correlation matrix.

    rho Qobj, optional

      Density matrix for which to calculate the correlation matrix. If rho is None, then a matrix of correlation matrix operators is returned instead of expectation values of those operators.

  Returns:
    corr_mat ndarray

      A 2-dimensional array of correlation values or operators.

correlation_matrix_field(a1, a2, rho=None)

  Calculates the correlation matrix for given field operators \(a_1\) and \(a_2\). If a density matrix is given the expectation values are calculated, otherwise a matrix with operators is returned.

  Parameters:
    a1 Qobj

      Field operator for mode 1.

    a2 Qobj

      Field operator for mode 2.

    rho Qobj, optional

      Density matrix for which to calculate the covariance matrix.

  Returns:
    cov_mat ndarray

      Array of complex numbers or Qobj’s A 2-dimensional array of covariance values, or, if rho=0, a matrix of operators.

correlation_matrix_quadrature(

  a1,
  a2,
  rho=None,
  g=np.float64(1.4142135623730951),

)

  Calculate the quadrature correlation matrix with given field operators \(a_1\) and \(a_2\). If a density matrix is given the expectation values are calculated, otherwise a matrix with operators is returned.

  Parameters:
    a1 Qobj

      Field operator for mode 1.

    a2 Qobj

      Field operator for mode 2.

    rho Qobj, optional

      Density matrix for which to calculate the covariance matrix.

    g float, default: sqrt(2)

      Scaling factor for `a = 0.5 * g * (x + iy)`, default `g = sqrt(2)`. The value of `g` is related to the value of `hbar` in the commutation relation `[x, y] = i * hbar` via `hbar=2/g ** 2` giving the default value `hbar=1`.

  Returns:
    corr_mat ndarray

      Array of complex numbers or Qobj’s A 2-dimensional array of covariance values for the field quadratures, or, if rho=0, a matrix of operators.

covariance_matrix(basis, rho, symmetrized=True)

  Given a basis set of operators \(\{a\}_n\), calculate the covariance matrix:

  \[V_{mn} = \frac{1}{2}\langle a_m a_n + a_n a_m \rangle - \langle a_m \rangle \langle a_n\rangle\]

  or, if of the optional argument symmetrized=False,

  \[V_{mn} = \langle a_m a_n\rangle - \langle a_m \rangle \langle a_n\rangle\]
  Parameters:
    basis list

      List of operators that defines the basis for the covariance matrix.

    rho Qobj

      Density matrix for which to calculate the covariance matrix.

    symmetrized bool, default: True

      Flag indicating whether the symmetrized (default) or non-symmetrized correlation matrix is to be calculated.

  Returns:
    corr_mat ndarray

      A 2-dimensional array of covariance values.

logarithmic_negativity(V, g=np.float64(1.4142135623730951))

  Calculates the logarithmic negativity given a symmetrized covariance matrix, see `qutip.continuous_variables.covariance_matrix`. Note that the two-mode field state that is described by V must be Gaussian for this function to applicable.

  Parameters:
    V ndarray

      The covariance matrix.

    g float, default: sqrt(2)

      Scaling factor for `a = 0.5 * g * (x + iy)`, default `g = sqrt(2)`. The value of `g` is related to the value of `hbar` in the commutation relation `[x, y] = i * hbar` via `hbar=2/g ** 2` giving the default value `hbar=1`.

  Returns:
    N float

      The logarithmic negativity for the two-mode Gaussian state that is described by the the Wigner covariance matrix V.

wigner_covariance_matrix(

  a1=None,
  a2=None,
  R=None,
  rho=None,
  g=np.float64(1.4142135623730951),

)

  Calculates the Wigner covariance matrix \(V_{ij} = \frac{1}{2}(R_{ij} + R_{ji})\), given the quadrature correlation matrix \(R_{ij} = \langle R_{i} R_{j}\rangle - \langle R_{i}\rangle \langle R_{j}\rangle\), where \(R = (q_1, p_1, q_2, p_2)^T\) is the vector with quadrature operators for the two modes.

  Alternatively, if `R = None`, and if annihilation operators `a1` and `a2` for the two modes are supplied instead, the quadrature correlation matrix is constructed from the annihilation operators before then the covariance matrix is calculated.

  Parameters:
    a1 Qobj, optional

      Field operator for mode 1.

    a2 Qobj, optional

      Field operator for mode 2.

    R ndarray, optional

      The quadrature correlation matrix.

    rho Qobj, optional

      Density matrix for which to calculate the covariance matrix.

    g float, default: sqrt(2)

      Scaling factor for `a = 0.5 * g * (x + iy)`, default `g = sqrt(2)`. The value of `g` is related to the value of `hbar` in the commutation relation `[x, y] = i * hbar` via `hbar=2/g ** 2` giving the default value `hbar=1`.

  Returns:
    cov_mat ndarray

      A 2-dimensional array of covariance values.

## Distribution functions

class Distribution(data=None, xvecs=[], xlabels=[])

  A class for representation spatial distribution functions.

  The Distribution class can be used to prepresent spatial distribution functions of arbitray dimension (although only 1D and 2D distributions are used so far).

  It is indented as a base class for specific distribution function, and provide implementation of basic functions that are shared among all Distribution functions, such as visualization, calculating marginal distributions, etc.

  Parameters:
    data array_like

      Data for the distribution. The dimensions must match the lengths of the coordinate arrays in xvecs.

    xvecs list

      List of arrays that spans the space for each coordinate.

    xlabels list

      List of labels for each coordinate.

  marginal(dim=0)

    Calculate the marginal distribution function along the dimension dim. Return a new Distribution instance describing this reduced- dimensionality distribution.

    Parameters:
      dim int

        The dimension (coordinate index) along which to obtain the marginal distribution.

    Returns:
      d Distributions

        A new instances of Distribution that describes the marginal distribution.

  project(dim=0)

    Calculate the projection (max value) distribution function along the dimension dim. Return a new Distribution instance describing this reduced-dimensionality distribution.

    Parameters:
      dim int

        The dimension (coordinate index) along which to obtain the projected distribution.

    Returns:
      d Distributions

        A new instances of Distribution that describes the projection.

  visualize(
    fig=None,
    ax=None,
    figsize=(8, 6),
    colorbar=True,
    cmap=None,
    style='colormap',
    show_xlabel=True,
    show_ylabel=True,
  )

    Visualize the data of the distribution in 1D or 2D, depending on the dimensionality of the underlaying distribution.

    Parameters:

    figmatplotlib Figure instance

      If given, use this figure instance for the visualization,

    axmatplotlib Axes instance

      If given, render the visualization using this axis instance.

    figsizetuple

      Size of the new Figure instance, if one needs to be created.

    colorbar: Bool

      Whether or not the colorbar (in 2D visualization) should be used.

    cmap: matplotlib colormap instance

      If given, use this colormap for 2D visualizations.

    stylestring

      Type of visualization: ‘colormap’ (default) or ‘surface’.

    Returns:
      fig, ax tuple

        A tuple of matplotlib figure and axes instances.