warp.sparse.bsr_diag#

warp.sparse.bsr_diag(
diag=None,
rows_of_blocks=None,
cols_of_blocks=None,
block_type=None,
device=None,
)[source]#

Create and return a block-diagonal BSR matrix from an given block value or array of block values.

Parameters:
  • diag (_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar] | Array[_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar]] | None) –

    Specifies the values for diagonal blocks. Can be one of:

    • A Warp array of type A.values.dtype: Each element defines one block of the diagonal

    • A constant value of type A.values.dtype: This value is assigned to all diagonal blocks

  • rows_of_blocks (int | None) – If not None, the new number of rows of blocks

  • cols_of_blocks (int | None) – If not None, the new number of columns of blocks

  • block_type (_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar] | None) – If diag is None, block type of the matrix. Otherwise deduced from diag

  • device – If diag is not a Warp array, device on which to allocate the matrix. Otherwise deduced from diag

Return type:

BsrMatrix[_MatrixBlockType[Rows, Cols, Scalar] | _ScalarBlockType[Scalar]]

The shape of the matrix will be defined one of the following, in this order:

  • rows_of_blocks and cols_of_blocks, if provided. If only one is given, the second is assumed equal.

  • The first dimension of diag if diag is an array.