pint.utils.get_phiinv

pint.utils.get_phiinv(phi: ndarray) ndarray[source]

Invert the phi (noise covariance) matrix in a numerically stable way.

The input is cast down to double precision before inverting. The precision of the noise parameters is not important, and double precision allows the use of the more stable Cholesky decomposition for inversion. Cholesky-based inversion is used for symmetric positive-definite matrices, with a fallback to direct inversion when the Cholesky factorization fails. A one-dimensional phi is interpreted as the diagonal of a diagonal matrix and inverted element-wise.

Parameters:

phi (array-like) – The phi matrix to invert. If one-dimensional, it is treated as the diagonal elements of a diagonal matrix; if two-dimensional, it is treated as a symmetric positive-definite covariance matrix.

Returns:

phiinv – The inverse of phi, in double precision.

Return type:

numpy.ndarray