pygsti.tools.matrixtools.minweight_match_realmxeigs#
- minweight_match_realmxeigs(a, b, metricfn=None, pass_indices_to_metricfn=False, eps=1e-09)#
Matches the elements of a and b, whose elements are assumed to either real or one-half of a conjugate pair.
Matching is performed by minimizing the weight between elements, defined as the sum of metricfn(x,y) over all (x,y) pairs (x in a and y in b). If straightforward matching fails to preserve eigenvalue conjugacy relations, then real and conjugate- pair eigenvalues are matched separately to ensure relations are preserved (but this can result in a sub-optimal matching). A ValueError is raised when the elements of a and b have incompatible conjugacy structures (#’s of conjugate vs. real pairs).
- Parameters:
a (numpy.ndarray) – First 1D array to match.
b (numpy.ndarray) – Second 1D array to match.
metricfn (function, optional) – A function of two float parameters, x and y,which defines the cost associated with matching x with y. If None, abs(x-y) is used.
pass_indices_to_metricfn (bool, optional) – If True, the metric function is passed two indices into the a and b arrays, respectively, instead of the values.
eps (float, optional) – Tolerance when checking if eigenvalues are equal to each other.
- Returns:
pairs – A list of 2-tuple pairs of indices (ix,iy) giving the indices into a and b respectively of each matched pair.
- Return type:
list