sf.apps.train.rescale_adjacency

rescale_adjacency(A, n_mean, threshold)[source]

Rescale an adjacency matrix so that it can be mapped to GBS.

An adjacency matrix must have singular values not exceeding one if it can be mapped to GBS. Arbitrary adjacency matrices must first be rescaled to satisfy this condition.

This function rescales an input adjacency matrix \(A\) so that the corresponding gaussian state has:

  • a mean number of clicks equal to n_mean when threshold=True;

  • a mean number of photons equal to n_mean when threshold=False.

Example usage:

>>> a = np.ones((3, 3))
>>> rescale_adjacency(a, 2, True)
array([[0.32232919, 0.32232919, 0.32232919],
       [0.32232919, 0.32232919, 0.32232919],
       [0.32232919, 0.32232919, 0.32232919]])
Parameters
  • A (array) – the adjacency matrix to rescale

  • n_mean (float) – the target mean number of clicks or mean number of photons

  • threshold (bool) – determines whether rescaling is for a target mean number of clicks or photons

Returns

the rescaled adjacency matrix

Return type

array