fips.linalg.DenseOperator#

class fips.linalg.DenseOperator(array)[source]#

Bases: LinearOperator

A matrix held as a dense 2D NumPy array.

Parameters:

array (ArrayLike) – The matrix. It is copied, and the copy is read-only: changing array afterwards leaves the form as it was.

Raises:

ValueError – If array is not 2D.

Examples

>>> import numpy as np
>>> from fips.linalg import DenseOperator
>>> A = DenseOperator(np.array([[2.0, 1.0], [1.0, 2.0]]))
>>> A @ np.array([1.0, 0.0])
array([2., 1.])
>>> A.solve(np.array([3.0, 3.0]))
array([1., 1.])

Attributes

array

The matrix, a read-only array.

Methods

dense()

Return the read-only array the form holds, not a copy.

solve(B)

Solve self @ X = B by Cholesky, falling back to LDL^T (see LinearOperator.solve()).

trace()

Return the sum of the main diagonal.

Inherited

From LinearOperator: diagonal, dot, logdet, sqrt