capytaine.matrices.builders module

This module contains some helpful functions to create block matrices.

capytaine.matrices.builders.cut_matrix(full_matrix, x_shapes, y_shapes, check=False)[source]

Transform a numpy array into a block matrix of numpy arrays.

Parameters:
  • full_matrix (numpy array) – The matrix to split into blocks.

  • x_shapes (sequence of int) – The columns at which to split the blocks.

  • y_shapes (sequence of int) – The lines at which to split the blocks.

  • check (bool, optional) – Check to dimensions and type of the matrix after creation (default: False).

Returns:

The same matrix as the input one but in block form.

Return type:

BlockMatrix

capytaine.matrices.builders.full_like(A, value, dtype=<class 'numpy.float64'>)[source]

A matrix of the same kind and shape as A but filled with a single value.

capytaine.matrices.builders.identity_like(A, dtype=<class 'numpy.float64'>)[source]

A identity matrix of the same kind and shape as A.

capytaine.matrices.builders.ones_like(A, dtype=<class 'numpy.float64'>)[source]

A matrix of the same kind and shape as A but filled with ones.

capytaine.matrices.builders.random_block_matrix(x_shapes, y_shapes, rng=Generator(PCG64) at 0x7F462C094580)[source]

A random block matrix.

capytaine.matrices.builders.zeros_like(A, dtype=<class 'numpy.float64'>)[source]

A matrix of the same kind and shape as A but filled with zeros.