warp.sparse.bsr_from_triplets#
- warp.sparse.bsr_from_triplets(
- rows_of_blocks,
- cols_of_blocks,
- rows,
- columns,
- values,
- prune_numerical_zeros=True,
Construct a BSR matrix with values defined by coordinate-oriented (COO) triplets.
The first dimension of the three input arrays must match and indicates the number of COO triplets. This convenience constructor always builds compact storage. To build into reserved row capacity, allocate with
bsr_zeros()usingrow_capacityand then callbsr_set_from_triplets()withtopology="padded".This function sums duplicate coordinates. When
prune_numerical_zeros=True, it omits zero-valued input blocks. The returned matrix can therefore have fewer active blocks than input triplets, whilennzinitially remains equal to the input array length. CallBsrMatrix.nnz_sync()to obtain the exact compact count before slicingcolumnsandvalues. Entries beyond the active count are not part of the matrix and may be uninitialized. If nonzero duplicate blocks sum to zero, the result remains an active explicit-zero block until it is pruned bybsr_compress().Use
bsr_copy()to copy a matrix or change its scalar type or block shape. Usebsr_compress()to pack active blocks into compact storage and optionally prune explicit zeros. Neither operation requires converting the matrix back to COO.- Parameters:
rows_of_blocks (int) – Number of rows of blocks.
cols_of_blocks (int) – Number of columns of blocks.
rows (Array[int]) – Row index for each non-zero.
columns (Array[int]) – Columns index for each non-zero.
values (Array[Scalar | BlockType[Rows, Cols, Scalar]]) – Block values for each non-zero. Must be either a one-dimensional array with data type identical to the
destmatrix’s block type, or a 3d array with data type equal to thedestmatrix’s scalar type.prune_numerical_zeros (bool) – If
True, will ignore the zero-valued blocks.