capytaine.matrices.block module

This module implements block matrices to be used in Hierarchical Toeplitz matrices.

It takes inspiration from the following works:

class capytaine.matrices.block.BlockMatrix(blocks, _stored_block_shapes=None, check=True)[source]

Bases: object

A (2D) matrix, stored as a set of submatrices (or blocks).

Parameters:
  • blocks (list of list of matrices) – The blocks of the block matrix.

  • check (bool, optional) – Should the code perform sanity checks on the inputs? (default: True)

Variables:
  • shape (pair of ints) – shape of the full matrix

  • nb_blocks (pair of ints) –

    number of blocks in each directions. Example:

    AAAABB
    AAAABB  ->  nb_blocks = (1, 2)
    AAAABB
    

access_block_by_path(path)[source]

Access a diagonal block in a block matrix from the path of the corresponding leaf

all() bool[source]
property all_blocks: ndarray

The matrix of matrices. For a full block matrix, all the blocks are stored in memory.

any() bool[source]
astype(dtype: dtype) BlockMatrix[source]
property block_shapes: Tuple[List[int], List[int]]

The shapes of the blocks composing the BlockMatrix.

Example:

AAAABB
AAAABB  ->  block_shapes = ([3], [4, 2])
AAAABB
property density
display_color = <itertools.cycle object>
property dtype

The type of data of all of the subblocks.

fft_of_list(*, check=True)[source]

Compute the fft of a list of block matrices of the same type and shape. The output is a list of block matrices of the same shape as the input ones. The fft is computed element-wise, so the block structure does not cause any mathematical difficulty. Returns an array of BlockMatrices.

full_matrix(dtype=None) ndarray[source]

Flatten the block structure and return a full matrix.

matmat(other)[source]

Matrix-matrix product.

matvec(other)[source]

Matrix vector product. Named as such to be used as scipy LinearOperator.

max() Number[source]
min() Number[source]
ndim = 2
no_toeplitz()[source]

Recursively replace the block toeplitz matrices by usual block matrices. WARNING: the block matrices may still contain several references to the same block.

plot_shape()[source]

Plot the structure of the matrix using matplotlib.

rmatvec(other)[source]

Vector matrix product. Named as such to be used as scipy LinearOperator.

property sparcity
property stored_data_size

Return the number of entries actually stored in memory.

property str_shape