pygsti.tools.matrixtools.normalize_columns

pygsti.tools.matrixtools.normalize_columns#

normalize_columns(m, return_norms=False, ord=None)#

Normalizes the columns of a matrix.

Parameters:
  • m (numpy.ndarray or scipy sparse matrix) – The matrix.

  • return_norms (bool, optional) – If True, also return a 1D array containing the norms of the columns (before they were normalized).

  • ord (int or list of ints, optional) – The order of the norm. See numpy.linalg.norm(). An array of orders can be given to specify the norm on a per-column basis.

Returns:

  • normalized_m (numpy.ndarray) – The matrix after columns are normalized

  • column_norms (numpy.ndarray) – Only returned when return_norms=True, a 1-dimensional array of the pre-normalization norm of each column.