fips.linalg.BlockDiagonalOperator#
- class fips.linalg.BlockDiagonalOperator(*args, **kwargs)[source]#
Bases:
LinearOperatorA square matrix made of forms on its diagonal blocks, zero between them.
A covariance whose blocks are independent (a flux block with Kronecker factors and a diagonal bias block, say) keeps each block in its own form: products, solves, the diagonal and the log-determinant go block by block, and the full matrix is formed only by
dense().- Parameters:
blocks (sequence of LinearOperator, SciPy sparse matrix or 2D array) – The diagonal blocks, in order, each square. A form is kept as it is (it holds its own copy); an array or a sparse matrix is copied, as
as_linear_operator()does.- Raises:
ValueError – If there is no block or a block is not square.
Examples
>>> import numpy as np >>> from fips.linalg import BlockDiagonalOperator, DiagonalOperator >>> S = BlockDiagonalOperator( ... [np.array([[2.0, 1.0], [1.0, 2.0]]), DiagonalOperator([4.0])] ... ) >>> S.dense() array([[2., 1., 0.], [1., 2., 0.], [0., 0., 4.]]) >>> S.solve(np.array([3.0, 3.0, 4.0])) array([1., 1., 1.])
Attributes
The diagonal blocks, each in its own form. |
Methods
|
Return the form as a dense NumPy array. |
|
Return the main diagonal, block by block. |
|
Return the sum of the blocks' log-determinants. |
|
Solve |
|
Return the square root of each block. |
Inherited
From LinearOperator: dot, trace