capytaine.tools.block_circulant_matrices module

Implementation of block circulant matrices to be used for optimizing resolution with symmetries.

class capytaine.tools.block_circulant_matrices.BlockCirculantMatrix(blocks: List[Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]])[source]

Bases: object

Data-sparse representation of a block matrix of the following form

( a d c b ) ( b a d c ) ( c b a d ) ( d c b a )

where a, b, c and d are matrices of the same shape.

Parameters:

blocks (iterable of matrix-like) – The first column of blocks [a, b, c, d, …] Each block should have the same shape.

block_diagonalize() BlockDiagonalMatrix[source]
solve(b: ndarray) ndarray[source]
class capytaine.tools.block_circulant_matrices.BlockDiagonalMatrix(blocks)[source]

Bases: object

Data-sparse representation of a block matrix of the following form

( a 0 0 0 ) ( 0 b 0 0 ) ( 0 0 c 0 ) ( 0 0 0 d )

where a, b, c and d are matrices of the same shape.

Parameters:

blocks (iterable of matrix-like) – The blocks [a, b, c, d, …]

solve(b: ndarray) ndarray[source]
class capytaine.tools.block_circulant_matrices.LUDecomposedBlockCirculantMatrix(bcm: BlockCirculantMatrix, *, overwrite_a: bool = False)[source]

Bases: object

solve(b: ndarray) ndarray[source]
class capytaine.tools.block_circulant_matrices.LUDecomposedBlockDiagonalMatrix(bdm: BlockDiagonalMatrix, *, overwrite_a: bool = False)[source]

Bases: object

LU decomposition of a BlockDiagonalMatrix, stored as the LU decomposition of each block.

solve(b: ndarray) ndarray[source]
class capytaine.tools.block_circulant_matrices.LUDecomposedMatrix(A: ndarray[tuple[Any, ...], dtype[_ScalarT]], *, overwrite_a: bool = False)[source]

Bases: object

solve(b: ndarray) ndarray[source]
capytaine.tools.block_circulant_matrices.circular_permutation(l: List, i: int) List[source]
capytaine.tools.block_circulant_matrices.ending_dimensions_at_the_beginning(a)[source]

Transform an array of shape (…, n, m) into (n, m, …). Invert of leading_dimensions_at_the_end

capytaine.tools.block_circulant_matrices.has_been_lu_decomposed(A)[source]
capytaine.tools.block_circulant_matrices.leading_dimensions_at_the_end(a)[source]

Transform an array of shape (n, m, …) into (…, n, m). Invert of leading_dimensions_at_the_end

capytaine.tools.block_circulant_matrices.lu_decompose(A: ndarray | BlockDiagonalMatrix | BlockCirculantMatrix, *, overwrite_a: bool = False)[source]