pygeon.utils.bmat module

Block matrix utilities.

pygeon.utils.bmat.replace_nones_with_zeros(mat)[source]

Replace each None in the block matrix by a zero sparse matrix of the right shape. This is done in-place.

Parameters:

mat (np.ndarray) – The block matrix to modify.

Returns:

This function modifies the input matrix in-place.

Return type:

None

pygeon.utils.bmat.find_row_col_lengths(mat)[source]

Find shapes of the blocks in mat.

Parameters:

mat (np.ndarray) – The input matrix.

Returns:

A tuple containing two numpy arrays - rows and cols, representing the lengths of rows and columns respectively.

Return type:

tuple

pygeon.utils.bmat.transpose(mat)[source]

Compute the transpose of a block matrix.

This function should be used instead of mat.T, because mat.T does not transpose the blocks themselves.

Parameters:

mat (np.ndarray) – The block matrix to be transposed.

Returns:

The transposed block matrix.

Return type:

np.ndarray

pygeon.utils.bmat.multiply(A, B)[source]

Compute the multiplication of two block matrices. The @-symbol does not always work because numpy misunderstands the dimensions

Parameters:
  • A (np.ndarray) – The first block matrix in the product.

  • B (np.ndarray) – The second block matrix in the product.

Returns:

The product block matrix.

Return type:

np.ndarray