aspcore.matrices.ensure_pos_semidef

aspcore.matrices.ensure_pos_semidef(mat)

Modifies mat to ensure it is positive semidefinite if it is not already. It does this by adding a scaled identity matrix to mat by iterating over gradually increasing scaling factors until the matrix is positive semidefinite.

This can be slow if many iterations are required. Assumes without checking that mat is hermitian. If you are unsure, use ensure_hermitian first.

Parameters:

mat (ndarray of shape (a, a) or (*tpl, a, a))

Returns:

mat

Return type:

same shape as input