pygsti.tools.matrixtools.scale_columns

Contents

pygsti.tools.matrixtools.scale_columns#

scale_columns(m, scale_values)#

Scale each column of a matrix by a given value.

Usually used for normalization purposes, when the matrix columns represent vectors.

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

  • scale_values (numpy.ndarray) – A 1-dimensional array of scale values, one per column of m.

Returns:

A copy of m with scaled columns, possibly with different sparsity structure.

Return type:

numpy.ndarray or scipy sparse matrix