Subtracting a diagonal matrix from an ill-conditioned one

131 Views Asked by At

I've written Python 3 + NumPy code where I perform the following calculation:

$$(B - \lambda I)^{-1}$$

where $B$ is a symmetric negative semidefinite matrix where some elements can be huge (greater than 1e25). When subtracting the diagonal matrix, floating-point does not have enough precision to perform the operation. Is there any matrix decomposition or trick that overcomes this problem?

The only solution I see now is rewriting the package using a different library with more precision than NumPy. Thanks in advance!