fips.linalg.DiagonalOperator#

class fips.linalg.DiagonalOperator(values)[source]#

Bases: LinearOperator

A square matrix that is zero off its main diagonal, held as the diagonal.

Parameters:

values (ArrayLike) – The diagonal, 1D. It is copied, and the copy is read-only.

Raises:

ValueError – If values is not 1D.

Examples

>>> from fips.linalg import DiagonalOperator
>>> D = DiagonalOperator([2.0, 4.0])
>>> D.solve([1.0, 1.0])
array([0.5 , 0.25])
>>> D.trace()
6.0

Attributes

values

The diagonal, a read-only array.

Methods

dense()

Return the form as a dense NumPy array.

diagonal()

Return a copy of the diagonal.

logdet()

Return the sum of the logarithms of the diagonal.

solve(B)

Solve self @ X = B by dividing each row of B by the diagonal.

sqrt()

Return the diagonal of square roots.

Inherited

From LinearOperator: dot, trace