pygsti.tools.matrixtools.safe_norm

Contents

pygsti.tools.matrixtools.safe_norm#

safe_norm(a, part=None)#

Get the frobenius norm of a matrix or vector, a, when it is either a dense array or a sparse matrix.

Parameters:
  • a (ndarray or scipy.sparse matrix) – The matrix or vector to take the norm of.

  • part ({None,'real','imag'}) – If not None, return the norm of the real or imaginary part of a.

Return type:

float