qstack.mathutils.matrix

Matrix operation utility functions.

qstack.mathutils.matrix.from_tril(mat_tril)[source]

Restore a symmetric matrix from its lower-triangular form.

Parameters:

mat_tril (numpy.ndarray) – 1D array containing matrix in lower-triangular form.

Returns:

2D symmetric matrix.

Return type:

numpy.ndarray

qstack.mathutils.matrix.sqrtm(m, eps=1e-13)[source]

Compute the matrix square root of a symmetric matrix.

Parameters:
  • m (numpy.ndarray) – 2D symmetric matrix.

  • eps (float) – Threshold for eigenvalues to be considered zero. Defaults to 1e-13.

Returns:

2D symmetric matrix, the square root of the input matrix.

Return type:

numpy.ndarray