match_global_phase

forest.benchmarking.compilation.match_global_phase(a: numpy.ndarray, b: numpy.ndarray) → Tuple[numpy.ndarray, numpy.ndarray]

Phases the given matrices so that they agree on the phase of one entry.

To maximize precision, the position with the largest entry from one of the matrices is used when attempting to compute the phase difference between the two matrices.

Parameters:
  • a – The first matrix
  • b – The second matrix
Returns:

A tuple (a’, b’) where a’ == b’ implies a == b*exp(i t) for some t.